diff --git a/conts/posix/SConstruct b/conts/posix/SConstruct new file mode 100644 index 0000000..baf0b34 --- /dev/null +++ b/conts/posix/SConstruct @@ -0,0 +1,90 @@ +# -*- mode: python; coding: utf-8; -*- +# +# Codezero -- Virtualization microkernel for embedded systems. +# +# Copyright © 2009 B Labs Ltd +# +import os, shelve, sys +from os.path import * + +PROJRELROOT = '../../' + +sys.path.append(PROJRELROOT) + +from config.projpaths import * +from config.configuration import * + +config = configuration_retrieve() +arch = config.arch + + +LIBL4_RELDIR = 'conts/libl4' +KERNEL_INCLUDE = join(PROJROOT, 'include') +LIBL4_DIR = join(PROJROOT, LIBL4_RELDIR) +LIBL4_INCLUDE = join(LIBL4_DIR, 'include') +LIBL4_LIBPATH = join(BUILDDIR, LIBL4_RELDIR) + +# Locally important paths are here +LIBC_RELDIR = 'conts/libc' +LIBC_DIR = join(PROJROOT, LIBC_RELDIR) +LIBC_LIBPATH = join(BUILDDIR, LIBC_RELDIR) +LIBC_INCLUDE = [join(LIBC_DIR, 'include'), \ + join(LIBC_DIR, 'include/arch' + '/' + arch)] + +LIBMEM_RELDIR = 'conts/libmem' +LIBMEM_DIR = join(PROJROOT, LIBMEM_RELDIR) +LIBMEM_LIBPATH = join(BUILDDIR, LIBMEM_RELDIR) +LIBMEM_INCLUDE = LIBMEM_DIR + +LIBPOSIX_RELDIR = 'conts/posix/libposix' +LIBPOSIX_DIR = join(PROJROOT, LIBPOSIX_RELDIR) +LIBPOSIX_INCLUDE_SERVER = join(LIBPOSIX_DIR, 'include') +LIBPOSIX_INCLUDE_USERSPACE = join(LIBPOSIX_DIR, 'include/posix') +LIBPOSIX_LIBPATH = join(BUILDDIR, LIBPOSIX_RELDIR) + +env = Environment(CC = 'arm-none-linux-gnueabi-gcc', + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', \ + '-std=gnu99', '-Wall', '-Werror'], + LINKFLAGS = ['-nostdlib'], \ + ASFLAGS = ['-D__ASSEMBLY__'], + PROGSUFFIX = '.elf', + ENV = {'PATH' : os.environ['PATH']}, + LIBS = ['gcc', 'libl4', 'c-userspace', 'libmm', 'libmc', 'gcc'], + CPPPATH = ['include', LIBC_INCLUDE, KERNEL_INCLUDE, LIBL4_INCLUDE, LIBMEM_INCLUDE], + LIBPATH = [LIBC_LIBPATH, LIBL4_LIBPATH, LIBMEM_LIBPATH, LIBPOSIX_LIBPATH], + CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h') + +contid = ARGUMENTS.get('cont', '0') + +libposix = SConscript('libposix/SConscript', \ + exports = { 'config' : config, 'env' : env, 'contid' : contid}, duplicate = 0, \ + variant_dir = join(BUILDDIR, 'conts' + '/posix' + '/libposix')) + +mm0_env = env.Clone() +mm0_env.Append(CPPPATH = LIBPOSIX_INCLUDE_SERVER) +mm0 = SConscript('mm0/SConscript', \ + exports = { 'config' : config, 'env' : mm0_env, 'contid' : contid}, duplicate = 0, \ + variant_dir = join(BUILDDIR, 'cont' + str(contid) + '/posix' + '/mm0')) + +fs0_env = env.Clone() +fs0_env.Append(CPPPATH = LIBPOSIX_INCLUDE_SERVER) +fs0 = SConscript('fs0/SConscript', \ + exports = { 'config' : config, 'env' : fs0_env, 'contid' : contid}, duplicate = 0, \ + variant_dir = join(BUILDDIR, 'cont' + str(contid) + '/posix' + '/fs0')) + +test0_env = env.Clone() +test0_env.Replace(CPPPATH = [LIBPOSIX_INCLUDE_USERSPACE, 'include', LIBC_INCLUDE, KERNEL_INCLUDE, LIBL4_INCLUDE, LIBMEM_INCLUDE]) +test0_env.Append(CCFLAGS = '-nostdinc') +test0 = SConscript('test0/SConscript', \ + exports = { 'config' : config, 'environment' : test0_env, 'contid' : contid}, duplicate = 0, \ + variant_dir = join(BUILDDIR, 'cont' + str(contid) + '/posix' + '/test0')) + +Depends(fs0, libposix) +Depends(test0, libposix) + +Alias('libposix', libposix) +Alias('mm0', mm0) +Alias('fs0', fs0) +Alias('test0', test0) + +Default([mm0, fs0, libposix, test0]) diff --git a/conts/posix/bootdesc/SConscript b/conts/posix/bootdesc/SConscript new file mode 100644 index 0000000..6dd82a5 --- /dev/null +++ b/conts/posix/bootdesc/SConscript @@ -0,0 +1,97 @@ +# -*- mode: python; coding: utf-8; -*- + +# Codezero -- a microkernel for embedded systems. +# +# Copyright © 2009 B Labs Ltd +# +# This program is free software: you can redistribute it and/or modify it under the terms of the GNU +# General Public License as published by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even +# the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public +# License for more details. +# +# You should have received a copy of the GNU General Public License along with this program. If not, see +# . +# +# Author: Russel Winder + +import os.path +import subprocess +import shutil + +Import('environment', 'images') + +e = environment.Clone() +e.Append(LINKFLAGS = ['-T' + e['posixServicesDirectory'] + '/bootdesc/linker.lds']) +e.Append(CPPPATH = ['#' + e['includeDirectory']]) + +bootdescTemplate = \ +''' +/* This file is autogenerated, do not edit by hand. */ + +/* Supervisor task at load time. */ +struct svc_image { + char name[16]; + unsigned int phys_start; + unsigned int phys_end; +} __attribute__((__packed__)); + +/* Supervisor task descriptor at load time */ +struct bootdesc { + int desc_size; + int total_images; + struct svc_image images[]; +} __attribute__((__packed__)); + +struct bootdesc bootdesc = { + .desc_size = sizeof(struct bootdesc) + sizeof(struct svc_image) * %s, + .total_images = %s, + .images = { +%s + }, +}; +''' + +imageTemplate = \ +''' [%s] = { + .name = "%s", + .phys_start = %s, + .phys_end = %s, + }, +''' + +def generateLocationData(image): + process = subprocess.Popen('tools/pyelf/readelf.py --lma-start-end ' + image.path, shell=True, stdout=subprocess.PIPE) + assert process.wait() == 0 + return (process.stdout.readline().strip(), process.stdout.readline().strip().split()[1], process.stdout.readline().strip().split()[1]) + +def generateBootdesc(target, source, env): + ''' + Extracts name, start, end information from the kernel and each svc task. + Uses this information to produce bootdesc.c + ''' + with open(target[0].path, 'w' ) as f: + imagesString = '' + numberOfImages = len(source) - 1 + for index in range(1, len(source)): + imagesString += imageTemplate % ((index - 1,) + generateLocationData(source[index])) + f.write(bootdescTemplate % (numberOfImages, numberOfImages, imagesString)) + +def relocateBootdesc(target, source, env): + name, start, end = generateLocationData(source[1]) + print "arm-none-linux-gnueabi-objcopy" + " --adjust-section-vma .data=" + end + " " + source[0].path +# process = subprocess.Popen(executable='arm-none-linux-gnueabi-objcopy', args=( +# '--adjust-section-vma .data=' + end, +# source[0].path)) +# assert process.wait() == 0 + os.system("arm-none-linux-gnueabi-objcopy --adjust-section-vma .data=" + end + " " + source[0].path) + shutil.copyfile(source[0].path, target[0].path) + +objects = e.Object(e.Command('bootdesc.c', images, generateBootdesc)) +Depends(objects, e['configFiles']) +bootdesc = e.Command('bootdesc.axf', e.Program('bootdesc_intermediate', objects) + [images[1]] , relocateBootdesc) +Depends(bootdesc, e['configFiles']) + +Return('bootdesc') diff --git a/conts/posix/bootdesc/SConstruct b/conts/posix/bootdesc/SConstruct new file mode 100644 index 0000000..7eb14cf --- /dev/null +++ b/conts/posix/bootdesc/SConstruct @@ -0,0 +1,123 @@ +# +# Build script to autogenerate a bootdesc image +# +# Copyright (C) 2007 Bahadir Balban +# +import os +import sys +import shutil +from os.path import join + +# The root directory of the repository where this file resides: +project_root = "../.." +tools_root = "../../tools" + +kernel = join(project_root, "build/start.axf") +mm0 = join(project_root, "tasks/mm0/mm0.axf") +fs0 = join(project_root, "tasks/fs0/fs0.axf") +test0 = join(project_root, "tasks/test0/test0.axf") +#test1 = join(project_root, "tasks/test1/test1.axf") +#blkdev0 = join(project_root, "tasks/fsbin/blkdev0.axf") + +images = [kernel, mm0, fs0, test0] +autogen_templ = "bootdesc.c.append" + +def get_image_name_start_end(image, target): + ''' + Using readelf.py utility, extracts name, start, end triplet from an arm-elf image. + ''' + rest, name = os.path.split(image) + if name[-4] == ".": + name = name[:-4] + os.system(join(tools_root, "pyelf/readelf.py --lma-start-end " + \ + image + " > " + target)) + +bootdesc_template = \ +''' +struct bootdesc bootdesc = { + .desc_size = sizeof(struct bootdesc) + sizeof(struct svc_image) * %s, + .total_images = %s, + .images = { +%s + }, +}; +''' + +images_template = \ +''' [%s] = { + .name = "%s", + .phys_start = %s, + .phys_end = %s, + }, +''' + +images_template_end = \ +''' + }, +''' + +def generate_bootdesc(source, target, env): + ''' + Extracts name, start, end information from the kernel and each svc task. + Uses this information to produce bootdesc.c + ''' + source.sort() + images = [] + images_string = "" + for node in source: + if str(node)[-4:] == ".axf": + rest, imgname = os.path.split(str(node)) + images.append((str(node), imgname[:-4])) + elif str(node) [-6:] == ".templ": + # Static template that has type definitions. + #rest, original_template = os.path.split(str(node)) + original_template = str(node) + index = 0 + for imgpath, imgname in images: + get_image_name_start_end(imgpath, imgname + ".txt") + if imgname != "start": + f = open(imgname + ".txt", "r") + svc_name = f.readline()[:-1] + [start, startval] = str.split(f.readline()[:-1]) + [end, endval] = str.split(f.readline()[:-1]) + f.close() + images_string += images_template % (str(index), svc_name, \ + hex(int(startval, 16)), hex(int(endval, 16))) + index += 1 + + # Autogenerated template with actual data. + autogen_template = open(autogen_templ, "w+") + autogen_template.write(bootdesc_template % (str(index), str(index), images_string)) + autogen_template.close() + + os.system("cat " + original_template + " > " + str(target[0])) + os.system("cat " + autogen_templ + " >> " + str(target[0])) + +def relocate_bootdesc(source, target, env): + f = open("start.txt", "r") + kernel_name = f.readline()[:-1] + [start, startval] = str.split(f.readline()[:-1]) + [end, endval] = str.split(f.readline()[:-1]) + os.system("arm-none-linux-gnueabi-objcopy --adjust-section-vma .data=" + \ + hex(int(endval,16)) + " " + str(source[0])) + os.system("mv " + str(source[0]) + " " + str(target[0])) +# The kernel build environment: +env = Environment(CC = 'arm-none-linux-gnueabi-gcc', + # We don't use -nostdinc because sometimes we need standard headers, + # such as stdarg.h e.g. for variable args, as in printk(). + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', '-Werror'], + LINKFLAGS = ['-nostdlib','-Tlinker.lds'], + ASFLAGS = ['-D__ASSEMBLY__'], + PROGSUFFIX = '.axf', # The suffix to use for final executable + ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path + LIBS = 'gcc', # libgcc.a - This is required for division routines. + CPPPATH = '#include') # `hash' ('#') is a shorthand meaning `relative to + # the root directory'. But this only works for + # well-defined variables, not all paths, and only + # if we use a relative build directory for sources. + +bootdesc_src = env.Command("bootdesc.c", ["bootdesc.c.templ"] + images, generate_bootdesc) +objs = env.Object('bootdesc.c') +bootdesc = env.Program('bootdesc_data', objs) +bootdesc_relocated = env.Command("bootdesc.axf", "bootdesc_data.axf", relocate_bootdesc) +env.Depends(bootdesc_relocated, bootdesc) diff --git a/conts/posix/bootdesc/bootdesc.c.templ b/conts/posix/bootdesc/bootdesc.c.templ new file mode 100644 index 0000000..0b6aa49 --- /dev/null +++ b/conts/posix/bootdesc/bootdesc.c.templ @@ -0,0 +1,16 @@ + + +/* Supervisor task at load time. */ +struct svc_image { + char name[16]; + unsigned int phys_start; + unsigned int phys_end; +} __attribute__((__packed__)); + +/* Supervisor task descriptor at load time */ +struct bootdesc { + int desc_size; + int total_images; + struct svc_image images[]; +} __attribute__((__packed__)); + diff --git a/conts/posix/bootdesc/linker.lds b/conts/posix/bootdesc/linker.lds new file mode 100644 index 0000000..06b95ec --- /dev/null +++ b/conts/posix/bootdesc/linker.lds @@ -0,0 +1,8 @@ +ENTRY(_start) + +SECTIONS +{ + _start = .; + .data : { *(.data) } + _end = .; +} diff --git a/conts/posix/fs0/SConscript b/conts/posix/fs0/SConscript new file mode 100644 index 0000000..0356014 --- /dev/null +++ b/conts/posix/fs0/SConscript @@ -0,0 +1,17 @@ + +Import('config', 'env', 'contid') + +import os, sys + +arch = config.arch + +src = [Glob('*.c') + Glob('src/*.c') + Glob('src/arch/arm/*.c') + Glob('src/memfs/*.c') + Glob('src/lib/*.c')] + +e = env.Clone() +e.Append(LIBS = 'posix') +e.Append(LINKFLAGS = ['-T' + "fs0/include/linker.lds", '-u_start']) + +objs = e.Object(src) +fs0 = e.Program('fs0.elf', objs) + +Return('fs0') diff --git a/conts/posix/fs0/SConstruct b/conts/posix/fs0/SConstruct new file mode 100644 index 0000000..6c6b1e3 --- /dev/null +++ b/conts/posix/fs0/SConstruct @@ -0,0 +1,75 @@ +# +# User space application build script +# +# Copyright (C) 2007 Bahadir Balban +# +import os +import sys +import shutil +from os.path import join +from glob import glob + +task_name = "fs0" + +# The root directory of the repository where this file resides: +project_root = "../.." +tools_root = join(project_root, "tools") +prev_image = join(project_root, "tasks/mm0/mm0.axf") +libs_path = join(project_root, "libs") +ld_script = "include/linker.lds" +physical_base_ld_script = "include/physical_base.lds" + +# libc paths: +libc_variant = "userspace" +libc_libpath = join(libs_path, "c/build/%s" % libc_variant) +libc_incpath = join(libc_libpath, "include") +libc_crt0 = join(libs_path, "c/build/crt/sys-userspace/arch-arm/crt0.o") +libc_name = "c-%s" % libc_variant + +#libmem paths: +libmem_path = "../libmem" +libmem_incpath = "../libmem" + +# libl4 paths: +libl4_path = "../libl4" +libl4_incpath1 = join(libl4_path, "include") + +# libposix paths: +libposix_path = "../libposix" +libposix_incpath = join(libposix_path, "include") + +# kernel paths: +kernel_incpath = join(project_root, "include") + +# If crt0 is in its library path, it becomes hard to link with it. +# For instance the linker script must use an absolute path for it. +def copy_crt0(source, target, env): + os.system("cp " + str(source[0]) + " " + str(target[0])) + +def get_physical_base(source, target, env): + os.system(join(tools_root, "pyelf/readelf.py --first-free-page " + \ + prev_image + " >> " + physical_base_ld_script)) + +# The kernel build environment: +env = Environment(CC = 'arm-none-linux-gnueabi-gcc', + # We don't use -nostdinc because sometimes we need standard headers, + # such as stdarg.h e.g. for variable args, as in printk(). + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', '-Werror'], + LINKFLAGS = ['-nostdlib', '-T' + ld_script, "-L" + libc_libpath, "-L" + libl4_path,\ + "-L" + libmem_path, "-L" + libposix_path], + ASFLAGS = ['-D__ASSEMBLY__'], + PROGSUFFIX = '.axf', # The suffix to use for final executable + ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path + LIBS = [libc_name, 'gcc', 'libmc', 'libl4', 'gcc', libc_name, "posix"], + CPPFLAGS = "-D__USERSPACE__", + CPPPATH = ['#include', libl4_incpath1, kernel_incpath, libc_incpath, \ + libposix_incpath, libmem_incpath]) + +src = [glob("src/*.c"), glob("*.c"), glob("src/arch/arm/*.c"), glob("src/memfs/*.c"), glob("src/lib/*.c")] +objs = env.Object(src) +physical_base = env.Command(physical_base_ld_script, prev_image, get_physical_base) +crt0_copied = env.Command("crt0.o", libc_crt0, copy_crt0) + +task = env.Program(task_name, objs + [crt0_copied]) +env.Alias(task_name, task) +env.Depends(task, physical_base) diff --git a/conts/posix/fs0/container.c b/conts/posix/fs0/container.c new file mode 100644 index 0000000..8b3311f --- /dev/null +++ b/conts/posix/fs0/container.c @@ -0,0 +1,23 @@ +/* + * Container entry point for this task + * + * Copyright (C) 2007-2009 Bahadir Bilgehan Balban + */ +#include +#include +#include + +void main(void); + +void __container_init(void) +{ + /* Generic L4 thread initialisation */ + __l4_init(); + + /* FS0 posix-service initialisation */ + posix_service_init(); + + /* Entry to main */ + main(); +} + diff --git a/conts/posix/fs0/include/bdev.h b/conts/posix/fs0/include/bdev.h new file mode 100644 index 0000000..c85a0cd --- /dev/null +++ b/conts/posix/fs0/include/bdev.h @@ -0,0 +1,8 @@ +#ifndef __BDEV_H__ +#define __BDEV_H__ +/* + * This is a mock-up compiled in blockdev buffer, to be used temporarily. + */ + +void *vfs_rootdev_open(void); +#endif/* __BDEV_H__ */ diff --git a/conts/posix/fs0/include/file.h b/conts/posix/fs0/include/file.h new file mode 100644 index 0000000..a553e4b --- /dev/null +++ b/conts/posix/fs0/include/file.h @@ -0,0 +1,6 @@ +#ifndef __FS0_MM_H__ +#define __FS0_MM_H__ + + + +#endif /* __FS0_MM_H__ */ diff --git a/conts/posix/fs0/include/fs.h b/conts/posix/fs0/include/fs.h new file mode 100644 index 0000000..20f7d49 --- /dev/null +++ b/conts/posix/fs0/include/fs.h @@ -0,0 +1,171 @@ +/* + * VFS definitions. + * + * Copyright (C) 2007, 2008 Bahadir Balban. + */ +#ifndef __FS_H__ +#define __FS_H__ + +#include +#include +#include +#include +#include + +typedef void (*vnode_op_t)(void); +typedef void (*file_op_t)(void); + +struct dentry; +struct file; +struct file_system_type; +struct superblock; +struct vnode; + +struct dentry_ops { + int (*compare)(struct dentry *d, const char *n); +}; + +/* Operations that work on file content */ +struct file_ops { + + /* Read a vnode's contents by page range */ + int (*read)(struct vnode *v, unsigned long pfn, + unsigned long npages, void *buf); + + /* Write a vnode's contents by page range */ + int (*write)(struct vnode *v, unsigned long pfn, + unsigned long npages, void *buf); + file_op_t open; + file_op_t close; + file_op_t mmap; + file_op_t lseek; + file_op_t flush; + file_op_t fsync; +}; + +/* Operations that work on vnode fields and associations between vnodes */ +struct vnode_ops { + vnode_op_t create; + struct vnode *(*lookup)(struct vnode *root, struct pathdata *pdata, + const char *component); + int (*readdir)(struct vnode *v); + int (*filldir)(void *buf, struct vnode *v, int count); + vnode_op_t link; + vnode_op_t unlink; + int (*mkdir)(struct vnode *parent, const char *name); + struct vnode *(*mknod)(struct vnode *parent, const char *name, + unsigned int mode); + vnode_op_t rmdir; + vnode_op_t rename; + vnode_op_t getattr; + vnode_op_t setattr; +}; + +struct superblock_ops { + int (*write_sb)(struct superblock *sb); + + /* + * Given a vnum, reads the disk-inode and copies its data + * into the vnode's generic fields + */ + int (*read_vnode)(struct superblock *sb, struct vnode *v); + + /* Writes vnode's generic fields into the disk-inode structure */ + int (*write_vnode)(struct superblock *sb, struct vnode *v); + + /* Allocates a disk-inode along with a vnode, and associates the two */ + struct vnode *(*alloc_vnode)(struct superblock *sb); + + /* Frees the vnode and the corresponding on-disk inode */ + int (*free_vnode)(struct superblock *sb, struct vnode *v); +}; + +#define VFS_DNAME_MAX 256 +struct dentry { + int refcnt; + char name[VFS_DNAME_MAX]; + struct dentry *parent; /* Parent dentry */ + struct link child; /* List of dentries with same parent */ + struct link children; /* List of children dentries */ + struct link vref; /* For vnode's dirent reference list */ + struct link cache_list; /* Dentry cache reference */ + struct vnode *vnode; /* The vnode associated with dentry */ + struct dentry_ops ops; +}; + +/* + * Buffer that maintains directory content for a directory vnode. This is the + * only vnode content that fs0 maintains. All other file data is in mm0 page + * cache. + */ +struct dirbuf { + unsigned long npages; + int dirty; + u8 *buffer; +}; + +/* Posix-style dirent format used by userspace. Returned by sys_readdir() */ +#define DIRENT_NAME_MAX 32 +struct dirent { + u32 inum; /* Inode number */ + u32 offset; /* Dentry offset in its buffer */ + u16 rlength; /* Record length */ + u8 name[DIRENT_NAME_MAX]; /* Name string */ +}; + +struct vnode { + unsigned long vnum; /* Filesystem-wide unique vnode id */ + int refcnt; /* Reference counter */ + int links; /* Number of hard links */ + struct superblock *sb; /* Reference to superblock */ + struct vnode_ops ops; /* Operations on this vnode */ + struct file_ops fops; /* File-related operations on this vnode */ + struct link dentries; /* Dirents that refer to this vnode */ + struct link cache_list; /* For adding the vnode to vnode cache */ + struct dirbuf dirbuf; /* Only directory buffers are kept */ + u32 mode; /* Permissions and vnode type */ + u32 owner; /* Owner */ + u64 atime; /* Last access time */ + u64 mtime; /* Last content modification */ + u64 ctime; /* Last vnode modification */ + u64 size; /* Size of contents */ + void *inode; /* Ptr to fs-specific inode */ +}; + +/* FS0 vfs specific macros */ + +/* Check if directory */ +#define vfs_isdir(v) S_ISDIR((v)->mode) + +/* Set vnode type */ +#define vfs_set_type(v, type) {v->mode &= ~S_IFMT; v->mode |= S_IFMT & type; } + +struct fstype_ops { + struct superblock *(*get_superblock)(void *buf); +}; + +#define VFS_FSNAME_MAX 256 +struct file_system_type { + char name[VFS_FSNAME_MAX]; + unsigned long magic; + struct fstype_ops ops; + struct link list; /* Member of list of all fs types */ + struct link sblist; /* List of superblocks with this type */ +}; +struct superblock *get_superblock(void *buf); + +struct superblock { + u64 fssize; + unsigned int blocksize; + struct link list; + struct file_system_type *fs; + struct superblock_ops *ops; + struct vnode *root; + void *fs_super; +}; + +void vfs_mount_fs(struct superblock *sb); + +extern struct dentry_ops generic_dentry_operations; + +#endif /* __FS_H__ */ diff --git a/conts/posix/fs0/include/globals.h b/conts/posix/fs0/include/globals.h new file mode 100644 index 0000000..50f588d --- /dev/null +++ b/conts/posix/fs0/include/globals.h @@ -0,0 +1,13 @@ +#ifndef __GLOBALS_H__ +#define __GLOBALS_H__ + +struct global_list { + int total; + struct link list; +}; + +extern struct global_list global_vm_files; +extern struct global_list global_vm_objects; +extern struct global_list global_tasks; + +#endif /* __GLOBALS_H__ */ diff --git a/conts/posix/fs0/include/init.h b/conts/posix/fs0/include/init.h new file mode 100644 index 0000000..30b4104 --- /dev/null +++ b/conts/posix/fs0/include/init.h @@ -0,0 +1,7 @@ +#ifndef __INIT_H__ +#define __INIT_H__ + +/* FS0 initialisation */ +int initialise(void); + +#endif /* __INIT_H__ */ diff --git a/conts/posix/fs0/include/lib/bit.h b/conts/posix/fs0/include/lib/bit.h new file mode 100644 index 0000000..7d6f8a7 --- /dev/null +++ b/conts/posix/fs0/include/lib/bit.h @@ -0,0 +1,44 @@ +#ifndef __LIB_BIT_H__ +#define __LIB_BIT_H__ + +#include + +unsigned int __clz(unsigned int bitvector); +int find_and_set_first_free_bit(u32 *word, unsigned int lastbit); +int find_and_set_first_free_contig_bits(u32 *word, unsigned int limit, + int nbits); +int check_and_clear_bit(u32 *word, int bit); +int check_and_clear_contig_bits(u32 *word, int first, int nbits); + +int check_and_set_bit(u32 *word, int bit); + +/* Set */ +static inline void setbit(unsigned int *w, unsigned int flags) +{ + *w |= flags; +} + + +/* Clear */ +static inline void clrbit(unsigned int *w, unsigned int flags) +{ + *w &= ~flags; +} + +/* Test */ +static inline int tstbit(unsigned int *w, unsigned int flags) +{ + return *w & flags; +} + +/* Test and clear */ +static inline int tstclr(unsigned int *w, unsigned int flags) +{ + int res = tstbit(w, flags); + + clrbit(w, flags); + + return res; +} + +#endif /* __LIB_BIT_H__ */ diff --git a/conts/posix/fs0/include/lib/idpool.h b/conts/posix/fs0/include/lib/idpool.h new file mode 100644 index 0000000..2650e75 --- /dev/null +++ b/conts/posix/fs0/include/lib/idpool.h @@ -0,0 +1,29 @@ +#ifndef __MM0_IDPOOL_H__ +#define __MM0_IDPOOL_H__ + +#include +#include +#include INC_GLUE(memory.h) +#include + +struct id_pool { + int nwords; + u32 bitmap[]; +}; + +/* Copy one id pool to another by calculating its size */ +static inline void id_pool_copy(struct id_pool *to, struct id_pool *from, int totalbits) +{ + int nwords = BITWISE_GETWORD(totalbits); + + memcpy(to, from, nwords * SZ_WORD + sizeof(struct id_pool)); +} + +struct id_pool *id_pool_new_init(int mapsize); +int id_new(struct id_pool *pool); +int id_del(struct id_pool *pool, int id); +int id_get(struct id_pool *pool, int id); +int ids_new_contiguous(struct id_pool *pool, int numids); +int ids_del_contiguous(struct id_pool *pool, int first, int numids); + +#endif /* __MM0_IDPOOL_H__ */ diff --git a/conts/posix/fs0/include/lib/malloc.h b/conts/posix/fs0/include/lib/malloc.h new file mode 100644 index 0000000..37479ff --- /dev/null +++ b/conts/posix/fs0/include/lib/malloc.h @@ -0,0 +1,19 @@ +#ifndef __PRIVATE_MALLOC_H__ +#define __PRIVATE_MALLOC_H__ + +#include +#include + +void *kmalloc(size_t size); +void kfree(void *blk); + +static inline void *kzalloc(size_t size) +{ + void *buf = kmalloc(size); + + memset(buf, 0, size); + return buf; +} + + +#endif /*__PRIVATE_MALLOC_H__ */ diff --git a/conts/posix/fs0/include/lib/pathstr.h b/conts/posix/fs0/include/lib/pathstr.h new file mode 100644 index 0000000..724f870 --- /dev/null +++ b/conts/posix/fs0/include/lib/pathstr.h @@ -0,0 +1,9 @@ +#ifndef __LIB_PATHSTR_H__ +#define __LIB_PATHSTR_H__ + +char *strreverse(char *str); +char *splitpath_end(char **path, char sep); +char *splitpath(char **str, char sep); + + +#endif /* __LIB_PATHSTR_H__ */ diff --git a/conts/posix/fs0/include/lib/spinlock.h b/conts/posix/fs0/include/lib/spinlock.h new file mode 100644 index 0000000..b3cc39c --- /dev/null +++ b/conts/posix/fs0/include/lib/spinlock.h @@ -0,0 +1,15 @@ +/* + * Fake spinlock for future multi-threaded mm0 + */ +#ifndef __MM0_SPINLOCK_H__ +#define __MM0_SPINLOCK_H__ + +struct spinlock { + int lock; +}; + +static inline void spin_lock_init(struct spinlock *s) { } +static inline void spin_lock(struct spinlock *s) { } +static inline void spin_unlock(struct spinlock *s) { } + +#endif /* __MM0_SPINLOCK_H__ */ diff --git a/conts/posix/fs0/include/lib/vaddr.h b/conts/posix/fs0/include/lib/vaddr.h new file mode 100644 index 0000000..d26d8af --- /dev/null +++ b/conts/posix/fs0/include/lib/vaddr.h @@ -0,0 +1,17 @@ +/* + * Virtual address allocation pool (for shm) + * + * Copyright (C) 2007 Bahadir Balban + */ +#ifndef __VADDR_H__ +#define __VADDR_H__ + +#include + +void vaddr_pool_init(struct id_pool *pool, unsigned long start, + unsigned long end); +void *vaddr_new(struct id_pool *pool, int npages); +int vaddr_del(struct id_pool *, void *vaddr, int npages); + +#endif /* __VADDR_H__ */ + diff --git a/conts/posix/fs0/include/linker.lds b/conts/posix/fs0/include/linker.lds new file mode 100644 index 0000000..90173fc --- /dev/null +++ b/conts/posix/fs0/include/linker.lds @@ -0,0 +1,49 @@ +/* + * Simple linker script for userspace or svc tasks. + * + * Copyright (C) 2007 Bahadir Balban + */ + +/* + * The only catch with this linker script is that everything + * is linked starting at virtual_base, and loaded starting + * at physical_base. virtual_base is the predefined region + * of virtual memory for userland applications. physical_base + * is determined at build-time, it is one of the subsequent pages + * that come after the kernel image's load area. + */ +/* USER_AREA_START, see memlayout.h */ +virtual_base = 0x10000000; +physical_base = 0x8000; +__stack = (0x20000000 - 0x1000 - 8); /* First page before env/args page */ +/* INCLUDE "include/physical_base.lds" */ + +/* physical_base = 0x228000; */ +offset = virtual_base - physical_base; + +ENTRY(_start) + +SECTIONS +{ + . = virtual_base; + _start_text = .; + .text : AT (ADDR(.text) - offset) { *(.text.head) *(.text) } + /* rodata is needed else your strings will link at physical! */ + .rodata : AT (ADDR(.rodata) - offset) { *(.rodata) } + .rodata1 : AT (ADDR(.rodata1) - offset) { *(.rodata1) } + .data : AT (ADDR(.data) - offset) + { + . = ALIGN(4K); /* Align UTCB to page boundary */ + _start_utcb = .; + *(.utcb) + _end_utcb = .; + . = ALIGN(4K); + _start_bdev = .; + *(.data.memfs) + _end_bdev = .; + *(.data) + } + .bss : AT (ADDR(.bss) - offset) { *(.bss) } + + _end = .; +} diff --git a/conts/posix/fs0/include/memfs/file.h b/conts/posix/fs0/include/memfs/file.h new file mode 100644 index 0000000..9679bee --- /dev/null +++ b/conts/posix/fs0/include/memfs/file.h @@ -0,0 +1,7 @@ +#ifndef __MEMFS_FILE_H__ +#define __MEMFS_FILE_H__ + +extern struct file_ops memfs_file_operations; +extern struct dentry_ops memfs_dentry_operations; + +#endif /* __MEMFS_FILE_H__ */ diff --git a/conts/posix/fs0/include/memfs/memfs.h b/conts/posix/fs0/include/memfs/memfs.h new file mode 100644 index 0000000..6b17d16 --- /dev/null +++ b/conts/posix/fs0/include/memfs/memfs.h @@ -0,0 +1,97 @@ +/* + * The disk layout of our simple unix-like filesystem. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ + +#ifndef __MEMFS_LAYOUT_H__ +#define __MEMFS_LAYOUT_H__ + +#include +#include +#include +#include +#include INC_GLUE(memory.h) +#include +#include + +/* + * + * Filesystem layout: + * + * |---------------| + * | Superblock | + * |---------------| + * + * Superblock layout: + * + * |---------------| + * | inode cache | + * |---------------| + * | dentry cache | + * |---------------| + * | block cache | + * |---------------| + * + */ + +/* + * These fixed filesystem limits make it much easier to implement + * filesystem space allocation. + */ +#define MEMFS_TOTAL_SIZE SZ_4MB +#define MEMFS_TOTAL_INODES 128 +#define MEMFS_TOTAL_BLOCKS 2000 +#define MEMFS_FMAX_BLOCKS 40 +#define MEMFS_BLOCK_SIZE PAGE_SIZE +#define MEMFS_MAGIC 0xB +#define MEMFS_NAME "memfs" +#define MEMFS_NAME_SIZE 8 + +struct memfs_inode { + u32 inum; /* Inode number */ + u32 mode; /* File permissions */ + u32 owner; /* File owner */ + u64 atime; /* Last access time */ + u64 mtime; /* Last content modification */ + u64 ctime; /* Last inode modification */ + u64 size; /* Size of contents */ + void *block[MEMFS_FMAX_BLOCKS]; /* Number of blocks */ +}; + +struct memfs_superblock { + u32 magic; /* Filesystem magic number */ + char name[8]; + u32 blocksize; /* Filesystem block size */ + u64 fmaxblocks; /* Maximum number of blocks per file */ + u64 fssize; /* Total size of filesystem */ + unsigned long root_vnum; /* The root vnum of this superblock */ + struct link inode_cache_list; /* Chain of alloc caches */ + struct link block_cache_list; /* Chain of alloc caches */ + struct id_pool *ipool; /* Index pool for inodes */ + struct id_pool *bpool; /* Index pool for blocks */ + struct memfs_inode *inode[MEMFS_TOTAL_INODES]; /* Table of inodes */ + void *block[MEMFS_TOTAL_BLOCKS]; /* Table of fs blocks */ +} __attribute__ ((__packed__)); + +#define MEMFS_DNAME_MAX 32 +struct memfs_dentry { + u32 inum; /* Inode number */ + u32 offset; /* Dentry offset in its buffer */ + u16 rlength; /* Record length */ + u8 name[MEMFS_DNAME_MAX]; /* Name string */ +}; + +extern struct vnode_ops memfs_vnode_operations; +extern struct superblock_ops memfs_superblock_operations; +extern struct file_ops memfs_file_operations; + +int memfs_format_filesystem(void *buffer); +struct memfs_inode *memfs_create_inode(struct memfs_superblock *sb); +void memfs_register_fstype(struct link *); +struct superblock *memfs_get_superblock(void *block); +int memfs_generate_superblock(void *block); + +void *memfs_alloc_block(struct memfs_superblock *sb); +int memfs_free_block(struct memfs_superblock *sb, void *block); +#endif /* __MEMFS_LAYOUT_H__ */ diff --git a/conts/posix/fs0/include/memfs/vnode.h b/conts/posix/fs0/include/memfs/vnode.h new file mode 100644 index 0000000..38e3080 --- /dev/null +++ b/conts/posix/fs0/include/memfs/vnode.h @@ -0,0 +1,7 @@ +#ifndef __MEMFS_VNODE_H__ +#define __MEMFS_VNODE_H__ + +#include + + +#endif /* __MEMFS_VNODE_H__ */ diff --git a/conts/posix/fs0/include/path.h b/conts/posix/fs0/include/path.h new file mode 100644 index 0000000..cfde50e --- /dev/null +++ b/conts/posix/fs0/include/path.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2008 Bahadir Balban + * + * Path lookup related information + */ +#ifndef __PATH_H__ +#define __PATH_H__ + +#include +#include + +/* + * FIXME: + * These ought to be strings and split/comparison functions should + * always use strings because formats like UTF-8 wouldn't work. + */ +#define VFS_CHAR_SEP '/' +#define VFS_STR_ROOTDIR "/" +#define VFS_STR_PARDIR ".." +#define VFS_STR_CURDIR "." +#define VFS_STR_XATDIR "...." + +struct pathdata { + struct link list; + struct vnode *vstart; +}; + +struct pathcomp { + struct link list; + const char *str; +}; + +struct pathdata *pathdata_parse(const char *pathname, char *pathbuf, + struct tcb *task); +void pathdata_destroy(struct pathdata *p); + +/* Destructive, i.e. unlinks those components from list */ +const char *pathdata_next_component(struct pathdata *pdata); +const char *pathdata_last_component(struct pathdata *pdata); + +#endif /* __PATH_H__ */ diff --git a/conts/posix/fs0/include/stat.h b/conts/posix/fs0/include/stat.h new file mode 100644 index 0000000..ee7225e --- /dev/null +++ b/conts/posix/fs0/include/stat.h @@ -0,0 +1,82 @@ +#ifndef __FS0_STAT_H__ +#define __FS0_STAT_H__ + +/* Posix definitions for file mode flags (covers type and access permissions) */ +#define S_IFMT 00170000 +#define S_IFSOCK 0140000 +#define S_IFLNK 0120000 +#define S_IFREG 0100000 +#define S_IFBLK 0060000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + +#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO) +#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO) +#define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH) +#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH) +#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) + +#define O_ACCMODE 00000003 +#define O_RDONLY 00000000 +#define O_WRONLY 00000001 +#define O_RDWR 00000002 +#define O_CREAT 00000100 +#define O_EXCL 00000200 +#define O_NOCTTY 00000400 +#define O_TRUNC 00001000 +#define O_APPEND 00002000 +#define O_NONBLOCK 00004000 +#define O_SYNC 00010000 +#define FASYNC 00020000 +#define O_DIRECT 00040000 +#define O_LARGEFILE 00100000 +#define O_DIRECTORY 00200000 +#define O_NOFOLLOW 00400000 +#define O_NOATIME 01000000 +#define O_NDELAY O_NONBLOCK + +/* + * Internal codezero-specific stat structure. + * This is converted to posix stat in userspace + */ +struct kstat { + u64 vnum; + u32 mode; + int links; + u16 uid; + u16 gid; + u64 size; + int blksize; + u64 atime; + u64 mtime; + u64 ctime; +}; + +#endif /* __FS0_STAT_H__ */ diff --git a/conts/posix/fs0/include/syscalls.h b/conts/posix/fs0/include/syscalls.h new file mode 100644 index 0000000..b10b892 --- /dev/null +++ b/conts/posix/fs0/include/syscalls.h @@ -0,0 +1,35 @@ +/* + * System call function signatures. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ +#ifndef __FS0_SYSCALLS_H__ +#define __FS0_SYSCALLS_H__ + +#include + +/* Posix calls */ +int sys_open(struct tcb *sender, const char *pathname, int flags, u32 mode); +int sys_readdir(struct tcb *sender, int fd, void *buf, int count); +int sys_mkdir(struct tcb *sender, const char *pathname, unsigned int mode); +int sys_chdir(struct tcb *sender, const char *pathname); + +/* Calls from pager that completes a posix call */ +int pager_open_bypath(struct tcb *pager, char *pathname); +int pager_sys_open(struct tcb *sender, l4id_t opener, int fd); +int pager_sys_read(struct tcb *sender, unsigned long vnum, unsigned long f_offset, + unsigned long npages, void *pagebuf); + +int pager_sys_write(struct tcb *sender, unsigned long vnum, unsigned long f_offset, + unsigned long npages, void *pagebuf); + +int pager_sys_close(struct tcb *sender, l4id_t closer, int fd); +int pager_update_stats(struct tcb *sender, unsigned long vnum, + unsigned long newsize); + +int pager_notify_fork(struct tcb *sender, l4id_t parentid, + l4id_t childid, unsigned long utcb_address, + unsigned int flags); + +int pager_notify_exit(struct tcb *sender, l4id_t tid); +#endif /* __FS0_SYSCALLS_H__ */ diff --git a/conts/posix/fs0/include/task.h b/conts/posix/fs0/include/task.h new file mode 100644 index 0000000..7908755 --- /dev/null +++ b/conts/posix/fs0/include/task.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2008 Bahadir Balban + */ +#ifndef __FS0_TASK_H__ +#define __FS0_TASK_H__ + +#include +#include +#include + +#define __TASKNAME__ __VFSNAME__ + +#define TCB_NO_SHARING 0 +#define TCB_SHARED_VM (1 << 0) +#define TCB_SHARED_FILES (1 << 1) +#define TCB_SHARED_FS (1 << 2) + +#define TASK_FILES_MAX 32 + +struct task_fd_head { + int fd[TASK_FILES_MAX]; + struct id_pool *fdpool; + int tcb_refs; +}; + +struct task_fs_data { + struct vnode *curdir; + struct vnode *rootdir; + int tcb_refs; +}; + +/* Thread control block, fs0 portion */ +struct tcb { + l4id_t tid; + struct link list; + unsigned long shpage_address; + struct task_fd_head *files; + struct task_fs_data *fs_data; +}; + +/* Structures used when receiving new task info from pager */ +struct task_data { + unsigned long tid; + unsigned long shpage_address; +}; + +struct task_data_head { + unsigned long total; + struct task_data tdata[]; +}; + +struct tcb *find_task(int tid); +int init_task_data(void); + +#endif /* __FS0_TASK_H__ */ diff --git a/conts/posix/fs0/include/vfs.h b/conts/posix/fs0/include/vfs.h new file mode 100644 index 0000000..5d9b5a8 --- /dev/null +++ b/conts/posix/fs0/include/vfs.h @@ -0,0 +1,90 @@ +#ifndef __VFS_H__ +#define __VFS_H__ + +#include +#include +#include +#include +#include +#include +#include +#include + +extern struct link vnode_cache; +extern struct link dentry_cache; + +/* + * This is a temporary origacement for page cache support provided by mm0. + * Normally mm0 tracks all vnode pages, but this is used to track pages in + * directory vnodes, which are normally never mapped by tasks. + */ +static inline void *vfs_alloc_dirpage(struct vnode *v) +{ + /* + * Urgh, we allocate from the block cache of memfs to store generic vfs directory + * pages. This is currently the quickest we can allocate page-aligned memory. + */ + return memfs_alloc_block(v->sb->fs_super); +} + +static inline void vfs_free_dirpage(struct vnode *v, void *block) +{ + memfs_free_block(v->sb->fs_super, block); +} + +static inline struct dentry *vfs_alloc_dentry(void) +{ + struct dentry *d = kzalloc(sizeof(struct dentry)); + + link_init(&d->child); + link_init(&d->children); + link_init(&d->vref); + link_init(&d->cache_list); + + return d; +} + +static inline void vfs_free_dentry(struct dentry *d) +{ + return kfree(d); +} + +static inline struct vnode *vfs_alloc_vnode(void) +{ + struct vnode *v = kzalloc(sizeof(struct vnode)); + + link_init(&v->dentries); + link_init(&v->cache_list); + + return v; +} + +static inline void vfs_free_vnode(struct vnode *v) +{ + BUG(); /* Are the dentries freed ??? */ + list_remove(&v->cache_list); + kfree(v); +} + +static inline struct superblock *vfs_alloc_superblock(void) +{ + struct superblock *sb = kmalloc(sizeof(struct superblock)); + link_init(&sb->list); + + return sb; +} + +struct vfs_mountpoint { + struct superblock *sb; /* The superblock of mounted filesystem */ + struct vnode *pivot; /* The dentry upon which we mount */ +}; + +extern struct vfs_mountpoint vfs_root; + +int vfs_mount_root(struct superblock *sb); +struct vnode *generic_vnode_lookup(struct vnode *thisnode, struct pathdata *p, + const char *component); +struct vnode *vfs_lookup_bypath(struct pathdata *p); +struct vnode *vfs_lookup_byvnum(struct superblock *sb, unsigned long vnum); + +#endif /* __VFS_H__ */ diff --git a/conts/posix/fs0/main.c b/conts/posix/fs0/main.c new file mode 100644 index 0000000..b5b672b --- /dev/null +++ b/conts/posix/fs0/main.c @@ -0,0 +1,148 @@ +/* + * FS0. Filesystem implementation + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * TODO: + * - Have a dentry cache searchable by name + * - Have a vnode cache searchable by vnum (and name?) + * - fs-specific readdir would read contents by page range, and add vnodes/dentries + * to their caches, while populating the directory vnode being read. + * - Have 2 vfs_lookup() flavors, one that searches a path, one that searches a vnum. + * - dirbuf is either allocated by low-level readdir, or else by a higher level, i.e. + * either high-level vfs code, or the mm0 page cache. + * - readdir provides a posix-compliant dirent structure list in dirbuf. + * - memfs dentries should be identical to posix struct dirents. + * + * ALL DONE!!! But untested. + * + * - Add mkdir + * - Add create + * - Add read/write -> This will need page cache and mm0 involvement. + * + * Done those, too. but untested. + */ + +/* Synchronise with pager via a `wait' tagged ipc with destination as pager */ +void wait_pager(l4id_t partner) +{ + l4_send(partner, L4_IPC_TAG_SYNC); + // printf("%s: Pager synced with us.\n", __TASKNAME__); +} + +void handle_fs_requests(void) +{ + u32 mr[MR_UNUSED_TOTAL]; + l4id_t senderid; + struct tcb *sender; + int ret; + u32 tag; + + if ((ret = l4_receive(L4_ANYTHREAD)) < 0) { + printf("%s: %s: IPC Error: %d. Quitting...\n", __TASKNAME__, + __FUNCTION__, ret); + BUG(); + } + + /* Read conventional ipc data */ + tag = l4_get_tag(); + senderid = l4_get_sender(); + + if (!(sender = find_task(senderid))) { + l4_ipc_return(-ESRCH); + return; + } + + /* Read mrs not used by syslib */ + for (int i = 0; i < MR_UNUSED_TOTAL; i++) + mr[i] = read_mr(MR_UNUSED_START + i); + + /* FIXME: Fix all these syscalls to read any buffer data from the caller task's utcb. + * Make sure to return -EINVAL if data is not valid. */ + switch(tag) { + case L4_IPC_TAG_SYNC: + printf("%s: Synced with waiting thread.\n", __TASKNAME__); + return; /* No origy for this tag */ + case L4_IPC_TAG_OPEN: + ret = sys_open(sender, (void *)mr[0], (int)mr[1], (unsigned int)mr[2]); + break; + case L4_IPC_TAG_MKDIR: + ret = sys_mkdir(sender, (const char *)mr[0], (unsigned int)mr[1]); + break; + case L4_IPC_TAG_CHDIR: + ret = sys_chdir(sender, (const char *)mr[0]); + break; + case L4_IPC_TAG_READDIR: + ret = sys_readdir(sender, (int)mr[0], (void *)mr[1], (int)mr[2]); + break; + case L4_IPC_TAG_PAGER_READ: + ret = pager_sys_read(sender, (unsigned long)mr[0], (unsigned long)mr[1], + (unsigned long)mr[2], (void *)mr[3]); + break; + case L4_IPC_TAG_PAGER_OPEN: + ret = pager_sys_open(sender, (l4id_t)mr[0], (int)mr[1]); + break; + case L4_IPC_TAG_PAGER_OPEN_BYPATH: + ret = pager_open_bypath(sender, (char *)mr[0]); + break; + case L4_IPC_TAG_PAGER_WRITE: + ret = pager_sys_write(sender, (unsigned long)mr[0], (unsigned long)mr[1], + (unsigned long)mr[2], (void *)mr[3]); + break; + case L4_IPC_TAG_PAGER_CLOSE: + ret = pager_sys_close(sender, (l4id_t)mr[0], (int)mr[1]); + break; + case L4_IPC_TAG_PAGER_UPDATE_STATS: + ret = pager_update_stats(sender, (unsigned long)mr[0], + (unsigned long)mr[1]); + break; + case L4_IPC_TAG_NOTIFY_FORK: + ret = pager_notify_fork(sender, (l4id_t)mr[0], (l4id_t)mr[1], + (unsigned long)mr[2], (unsigned int)mr[3]); + break; + case L4_IPC_TAG_NOTIFY_EXIT: + ret = pager_notify_exit(sender, (l4id_t)mr[0]); + break; + + default: + printf("%s: Unrecognised ipc tag (%d) " + "received from tid: %d. Ignoring.\n", __TASKNAME__, + mr[MR_TAG], senderid); + } + + /* Reply */ + if ((ret = l4_ipc_return(ret)) < 0) { + printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, ret); + BUG(); + } +} + +void main(void) +{ + printf("\n%s: Started with thread id %d\n", __TASKNAME__, self_tid()); + + initialise(); + + wait_pager(PAGER_TID); + + printf("%s: VFS service initialized. Listening requests.\n", __TASKNAME__); + while (1) { + handle_fs_requests(); + } +} + diff --git a/conts/posix/fs0/src/bdev.c b/conts/posix/fs0/src/bdev.c new file mode 100644 index 0000000..1f69162 --- /dev/null +++ b/conts/posix/fs0/src/bdev.c @@ -0,0 +1,15 @@ +/* + * This is just to allocate some memory as a block device. + */ +#include +#include + +extern char _start_bdev[]; +extern char _end_bdev[]; + +__attribute__((section(".data.memfs"))) char blockdevice[MEMFS_TOTAL_SIZE]; + +void *vfs_rootdev_open(void) +{ + return (void *)_start_bdev; +} diff --git a/conts/posix/fs0/src/bootfs/bootfs.c b/conts/posix/fs0/src/bootfs/bootfs.c new file mode 100644 index 0000000..1b3fdcb --- /dev/null +++ b/conts/posix/fs0/src/bootfs/bootfs.c @@ -0,0 +1,147 @@ +/* + * A pseudo-filesystem for reading the in-memory + * server tasks loaded from the initial elf executable. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ +#include +#include +#include + +struct dentry *bootfs_dentry_lookup(struct dentry *d, char *dname) +{ + struct dentry *this; + + list_foreach_struct(this, child, &d->children) { + if (this->compare(this, dname)) + return this; + } + return 0; +} + +struct dentry *path_lookup(struct superblock *sb, char *pathstr) +{ + char *dname; + char *splitpath; + struct dentry *this, *next; + + /* First dentry is root */ + this = sb->root; + + /* Get next path component from path string */ + dname = path_next_dentry_name(pathstr); + + if (!this->compare(dname)) + return; + + while(!(dname = path_next_dentry_name(pathstr))) { + if ((d = this->lookup(this, dname))) + return 0; + } +} + +/* + * This creates a pseudo-filesystem tree from the loaded + * server elf images whose information is available from + * initdata. + */ +void bootfs_populate(struct initdata *initdata, struct superblock *sb) +{ + struct bootdesc *bd = initdata->bootdesc; + struct svc_image *img; + struct dentry *d; + struct vnode *v; + struct file *f; + + for (int i = 0; i < bd->total_images; i++) { + img = &bd->images[i]; + + d = malloc(sizeof(struct dentry)); + v = malloc(sizeof(struct vnode)); + f = malloc(sizeof(struct file)); + + /* Initialise dentry for image */ + d->refcnt = 0; + d->vnode = v; + d->parent = sb->root; + strncpy(d->name, img->name, VFS_DENTRY_NAME_MAX); + link_init(&d->child); + link_init(&d->children); + list_insert(&d->child, &sb->root->children); + + /* Initialise vnode for image */ + v->refcnt = 0; + v->id = img->phys_start; + v->size = img->phys_end - img->phys_start; + link_init(&v->dirents); + list_insert(&d->v_ref, &v->dirents); + + /* Initialise file struct for image */ + f->refcnt = 0; + f->dentry = d; + + img_d++; + img_vn++; + img_f++; + } +} + +void bootfs_init_root(struct dentry *r) +{ + struct vnode *v = r->vnode; + + /* Initialise dentry for rootdir */ + r->refcnt = 0; + strcpy(r->name, ""); + link_init(&r->child); + link_init(&r->children); + link_init(&r->vref); + r->parent = r; + + /* Initialise vnode for rootdir */ + v->id = 0; + v->refcnt = 0; + link_init(&v->dirents); + link_init(&v->state_list); + list_insert(&r->vref, &v->dirents); + v->size = 0; +} + +struct superblock *bootfs_init_sb(struct superblock *sb) +{ + sb->root = malloc(sizeof(struct dentry)); + sb->root->vnode = malloc(sizeof(struct vnode)); + + bootfs_init_root(&sb->root); + + return sb; +} + +struct superblock bootfs_sb = { + .fs = bootfs_type, + .ops = { + .read_sb = bootfs_read_sb, + .write_sb = bootfs_write_sb, + .read_vnode = bootfs_read_vnode, + .write_vnode = bootfs_write_vnode, + }, +}; + +struct superblock *bootfs_get_sb(void) +{ + bootfs_init_sb(&bootfs_sb); + return &bootfs_sb; +} + +struct file_system_type bootfs_type = { + .name = "bootfs", + .magic = 0, + .get_sb = bootfs_get_sb, +}; + +void init_bootfs() +{ + bootfs_init_sb(&bootfs_sb); + + bootfs_populate(&bootfs_sb); +} diff --git a/conts/posix/fs0/src/c0fs/c0fs.c b/conts/posix/fs0/src/c0fs/c0fs.c new file mode 100644 index 0000000..d1146b2 --- /dev/null +++ b/conts/posix/fs0/src/c0fs/c0fs.c @@ -0,0 +1,29 @@ +/* + * A basic unix-like read/writeable filesystem for Codezero. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ +#include +#include + +void sfs_read_sb(struct superblock *sb) +{ + +} + +static void simplefs_alloc_vnode(struct vnode *) +{ + +} + +struct file_system_type sfs_type = { + .name = "c0fs", + .magic = 1, + .flags = 0, +}; + +/* Registers sfs as an available filesystem type */ +void sfs_register_fstype(struct link *fslist) +{ + list_insert(&sfs_type.list, fslist); +} diff --git a/conts/posix/fs0/src/c0fs/c0fs.h b/conts/posix/fs0/src/c0fs/c0fs.h new file mode 100644 index 0000000..da91f15 --- /dev/null +++ b/conts/posix/fs0/src/c0fs/c0fs.h @@ -0,0 +1,113 @@ +/* + * The disk layout of our simple unix-like filesystem. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ + +#ifndef __C0FS_LAYOUT_H__ +#define __C0FS_LAYOUT_H__ + +#include +#include +#include +#include +#include INC_GLUE(memory.h) + +/* + * + * Filesystem layout: + * + * |---------------| + * | Group 0 | + * |---------------| + * | Group 1 | + * |---------------| + * | ... | + * |---------------| + * | Group n | + * |---------------| + * + * + * Group layout: + * + * |---------------| + * | Superblock | + * |---------------| + * | Inode table | + * |---------------| + * | Data blocks | + * |---------------| + * + * or + * + * |---------------| + * | Data blocks | + * |---------------| + * + */ + +#define BLOCK_SIZE PAGE_SIZE +#define BLOCK_BITS PAGE_BITS +#define GROUP_SIZE SZ_8MB +#define INODE_TABLE_SIZE ((GROUP_SIZE / BLOCK_SIZE) / 2) +#define INODE_BITMAP_SIZE (INODE_TABLE_SIZE >> 5) + + +struct sfs_superblock { + u32 magic; /* Filesystem magic number */ + u64 fssize; /* Total size of filesystem */ + u32 total; /* To */ + u32 groupmap[]; /* Bitmap of all fs groups */ +}; + +struct sfs_group_table { + u32 total; + u32 free; + u32 groupmap[]; +}; + +struct sfs_inode_table { + u32 total; + u32 free; + u32 inodemap[INODE_BITMAP_SIZE]; + struct sfs_inode inode[INODE_TABLE_SIZE]; +}; + +/* + * The purpose of an inode: + * + * 1) Uniquely identify a file or a directory. + * 2) Keep file/directory metadata. + * 3) Provide access means to file blocks/directory contents. + */ +#define INODE_DIRECT_BLOCKS 5 +struct sfs_inode_blocks { + int szidx; /* Direct array index size */ + unsigned long indirect; + unsigned long indirect2; + unsigned long indirect3; + unsigned long direct[]; +}; + +struct sfs_inode { + u32 unum; /* Unit number this inode is in */ + u32 inum; /* Inode number */ + u32 mode; /* File permissions */ + u32 owner; /* File owner */ + u64 atime; /* Last access time */ + u64 mtime; /* Last content modification */ + u64 ctime; /* Last inode modification */ + u64 size; /* Size of contents */ + struct sfs_inode_blocks blocks; +} __attribute__ ((__packed__)); + +struct sfs_dentry { + u32 inum; /* Inode number */ + u32 nlength; /* Name length */ + u8 name[]; /* Name string */ +} __attribute__ ((__packed__)); + + +void sfs_register_type(struct link *); + +#endif /* __C0FS_LAYOUT_H__ */ diff --git a/conts/posix/fs0/src/crt0.S b/conts/posix/fs0/src/crt0.S new file mode 100644 index 0000000..9bcb3a8 --- /dev/null +++ b/conts/posix/fs0/src/crt0.S @@ -0,0 +1,94 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#ifdef __thumb__ +#define bl blx +#endif + + .section .text.head + .code 32 + .global _start; + .align; +_start: + ldr sp, =__stack + bl platform_init + bl __container_init +1: + b 1b + diff --git a/conts/posix/fs0/src/file.c b/conts/posix/fs0/src/file.c new file mode 100644 index 0000000..2bfd6fe --- /dev/null +++ b/conts/posix/fs0/src/file.c @@ -0,0 +1,25 @@ +/* + * File content tracking. + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include INC_GLUE(memory.h) +#include + +/* + * This reads contents of a file in pages, calling the fs-specific file read function to read-in + * those pages' contents. + * + * Normally this is ought to be called by mm0 when a file's pages cannot be found in the page + * cache. + */ +int generic_file_read(struct vnode *v, unsigned long pfn, unsigned long npages, void *page_buf) +{ + BUG_ON(!is_page_aligned(page_buf)); + + return v->fops.read(v, pfn, npages, page_buf); +} diff --git a/conts/posix/fs0/src/init.c b/conts/posix/fs0/src/init.c new file mode 100644 index 0000000..84ff20c --- /dev/null +++ b/conts/posix/fs0/src/init.c @@ -0,0 +1,91 @@ +/* + * FS0 Initialisation. + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct link fs_type_list; + +struct superblock *vfs_probe_filesystems(void *block) +{ + struct file_system_type *fstype; + struct superblock *sb; + + list_foreach_struct(fstype, &fs_type_list, list) { + /* Does the superblock match for this fs type? */ + if ((sb = fstype->ops.get_superblock(block))) { + /* + * Add this to the list of superblocks this + * fs already has. + */ + list_insert(&sb->list, &fstype->sblist); + return sb; + } + } + + return PTR_ERR(-ENODEV); +} + +/* + * Registers each available filesystem so that these can be + * used when probing superblocks on block devices. + */ +void vfs_register_filesystems(void) +{ + /* Initialise fstype list */ + link_init(&fs_type_list); + + /* Call per-fs registration functions */ + memfs_register_fstype(&fs_type_list); +} + +/* + * Filesystem initialisation. + */ +int initialise(void) +{ + void *rootdev_blocks; + struct superblock *root_sb; + + /* Get standard init data from microkernel */ + // request_initdata(&initdata); + + /* Register compiled-in filesystems with vfs core. */ + vfs_register_filesystems(); + + /* Get a pointer to first block of root block device */ + rootdev_blocks = vfs_rootdev_open(); + + /* + * Since the *only* filesystem we have is a temporary memory + * filesystem, we create it on the root device first. + */ + memfs_format_filesystem(rootdev_blocks); + + /* Search for a filesystem on the root device */ + BUG_ON(IS_ERR(root_sb = vfs_probe_filesystems(rootdev_blocks))); + + /* Mount the filesystem on the root device */ + vfs_mount_root(root_sb); + + printf("%s: Mounted memfs root filesystem.\n", __TASKNAME__); + + /* Learn about what tasks are running */ + init_task_data(); + + /* + * Initialisation is done. From here on, we can start + * serving filesystem requests. + */ + return 0; +} + diff --git a/conts/posix/fs0/src/lib/bit.c b/conts/posix/fs0/src/lib/bit.c new file mode 100644 index 0000000..7b1dee4 --- /dev/null +++ b/conts/posix/fs0/src/lib/bit.c @@ -0,0 +1,111 @@ +/* + * Bit manipulation functions. + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include INC_GLUE(memory.h) + +/* Emulation of ARM's CLZ (count leading zeroes) instruction */ +unsigned int __clz(unsigned int bitvector) +{ + unsigned int x = 0; + while((!(bitvector & ((unsigned)1 << 31))) && (x < 32)) { + bitvector <<= 1; + x++; + } + return x; +} + +int find_and_set_first_free_bit(u32 *word, unsigned int limit) +{ + int success = 0; + int i; + + for(i = 0; i < limit; i++) { + /* Find first unset bit */ + if (!(word[BITWISE_GETWORD(i)] & BITWISE_GETBIT(i))) { + /* Set it */ + word[BITWISE_GETWORD(i)] |= BITWISE_GETBIT(i); + success = 1; + break; + } + } + /* Return bit just set */ + if (success) + return i; + else + return -1; +} + +int find_and_set_first_free_contig_bits(u32 *word, unsigned int limit, + int nbits) +{ + int i = 0, first = 0, last = 0, found = 0; + + /* Can't allocate more than the limit */ + if (nbits > limit) + return -1; + + /* This is a state machine that checks n contiguous free bits. */ + while (i + nbits < limit) { + first = i; + last = i; + while (!(word[BITWISE_GETWORD(last)] & BITWISE_GETBIT(last))) { + last++; + i++; + if (last == first + nbits) { + found = 1; + break; + } + } + if (found) + break; + i++; + } + + /* If found, set the bits */ + if (found) { + for (int x = first; x < first + nbits; x++) + word[BITWISE_GETWORD(x)] |= BITWISE_GETBIT(x); + return first; + } else + return -1; +} + +int check_and_clear_bit(u32 *word, int bit) +{ + /* Check that bit was set */ + if (word[BITWISE_GETWORD(bit)] & BITWISE_GETBIT(bit)) { + word[BITWISE_GETWORD(bit)] &= ~BITWISE_GETBIT(bit); + return 0; + } else { + printf("Trying to clear already clear bit\n"); + return -1; + } +} + +int check_and_clear_contig_bits(u32 *word, int first, int nbits) +{ + for (int i = first; i < first + nbits; i++) + if (check_and_clear_bit(word, i) < 0) + return -1; + return 0; +} + +int check_and_set_bit(u32 *word, int bit) +{ + /* Check that bit was clear */ + if (!(word[BITWISE_GETWORD(bit)] & BITWISE_GETBIT(bit))) { + word[BITWISE_GETWORD(bit)] |= BITWISE_GETBIT(bit); + return 0; + } else { + //printf("Trying to set already set bit\n"); + return -1; + } +} + + diff --git a/conts/posix/fs0/src/lib/idpool.c b/conts/posix/fs0/src/lib/idpool.c new file mode 100644 index 0000000..0cb826e --- /dev/null +++ b/conts/posix/fs0/src/lib/idpool.c @@ -0,0 +1,81 @@ +/* + * Used for thread and space ids. + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +// #include --> This requires page allocation to grow/shrink. +#include // --> This is a local library that statically allocates its heap. +#include +#include INC_GLUE(memory.h) +#include +#include + +struct id_pool *id_pool_new_init(int totalbits) +{ + int nwords = BITWISE_GETWORD(totalbits); + struct id_pool *new = kzalloc((nwords * SZ_WORD) + + sizeof(struct id_pool)); + if (!new) + return PTR_ERR(-ENOMEM); + new->nwords = nwords; + return new; +} + +int id_new(struct id_pool *pool) +{ + int id = find_and_set_first_free_bit(pool->bitmap, + pool->nwords * WORD_BITS); + if (id < 0) + printf("%s: Warning! New id alloc failed\n", __FUNCTION__); + return id; +} + +/* This finds n contiguous free ids, allocates and returns the first one */ +int ids_new_contiguous(struct id_pool *pool, int numids) +{ + int id = find_and_set_first_free_contig_bits(pool->bitmap, + pool->nwords *WORD_BITS, + numids); + if (id < 0) + printf("%s: Warning! New id alloc failed\n", __FUNCTION__); + return id; +} + +/* This deletes a list of contiguous ids given the first one and number of ids */ +int ids_del_contiguous(struct id_pool *pool, int first, int numids) +{ + int ret; + + if (pool->nwords * WORD_BITS < first + numids) + return -1; + if ((ret = check_and_clear_contig_bits(pool->bitmap, first, numids))) + printf("%s: Error: Invalid argument range.\n", __FUNCTION__); + return ret; +} + +int id_del(struct id_pool *pool, int id) +{ + int ret; + + if (pool->nwords * WORD_BITS < id) + return -1; + + if ((ret = check_and_clear_bit(pool->bitmap, id) < 0)) + printf("%s: Error: Could not delete id.\n", __FUNCTION__); + return ret; +} + +/* Return a specific id, if available */ +int id_get(struct id_pool *pool, int id) +{ + int ret; + + ret = check_and_set_bit(pool->bitmap, id); + + if (ret < 0) + return ret; + else + return id; +} + diff --git a/conts/posix/fs0/src/lib/malloc.c b/conts/posix/fs0/src/lib/malloc.c new file mode 100644 index 0000000..27c3829 --- /dev/null +++ b/conts/posix/fs0/src/lib/malloc.c @@ -0,0 +1,417 @@ +/***************************************************************************** +Simple malloc +Chris Giese http://www.execpc.com/~geezer +Release date: Oct 30, 2002 +This code is public domain (no copyright). +You can do whatever you want with it. + +Features: +- First-fit +- free() coalesces adjacent free blocks +- Uses variable-sized heap, enlarged with kbrk()/sbrk() function +- Does not use mmap() +- Can be easily modified to use fixed-size heap +- Works with 16- or 32-bit compilers + +Build this program with either of the two main() functions, then run it. +Messages that indicate a software error will contain three asterisks (***). +*****************************************************************************/ +#include /* memcpy(), memset() */ +#include /* printf() */ + +#define _32BIT 1 + +/* use small (32K) heap for 16-bit compilers, +large (500K) heap for 32-bit compilers */ +#if defined(_32BIT) +#define HEAP_SIZE 500000uL +#else +#define HEAP_SIZE 32768u +#endif + +#define MALLOC_MAGIC 0x6D92 /* must be < 0x8000 */ + +typedef struct _malloc /* Turbo C DJGPP */ +{ + size_t size; /* 2 bytes 4 bytes */ + struct _malloc *next; /* 2 bytes 4 bytes */ + unsigned magic : 15; /* 2 bytes total 4 bytes total */ + unsigned used : 1; +} malloc_t; /* total 6 bytes 12 bytes */ + +static char *g_heap_bot, *g_kbrk, *g_heap_top; +/***************************************************************************** +*****************************************************************************/ +void dump_heap(void) +{ + unsigned blks_used = 0, blks_free = 0; + size_t bytes_used = 0, bytes_free = 0; + malloc_t *m; + int total; + + printf("===============================================\n"); + for(m = (malloc_t *)g_heap_bot; m != NULL; m = m->next) + { + printf("blk %5p: %6u bytes %s\n", m, + m->size, m->used ? "used" : "free"); + if(m->used) + { + blks_used++; + bytes_used += m->size; + } + else + { + blks_free++; + bytes_free += m->size; + } + } + printf("blks: %6u used, %6u free, %6u total\n", blks_used, + blks_free, blks_used + blks_free); + printf("bytes: %6u used, %6u free, %6u total\n", bytes_used, + bytes_free, bytes_used + bytes_free); + printf("g_heap_bot=0x%p, g_kbrk=0x%p, g_heap_top=0x%p\n", + g_heap_bot, g_kbrk, g_heap_top); + total = (bytes_used + bytes_free) + + (blks_used + blks_free) * sizeof(malloc_t); + if(total != g_kbrk - g_heap_bot) + printf("*** some heap memory is not accounted for\n"); + printf("===============================================\n"); +} +/***************************************************************************** +POSIX sbrk() looks like this + void *sbrk(int incr); +Mine is a bit different so I can signal the calling function +if more memory than desired was allocated (e.g. in a system with paging) +If your kbrk()/sbrk() always allocates the amount of memory you ask for, +this code can be easily changed. + + int brk( void *sbrk( void *kbrk( +function void *adr); int delta); int *delta); +---------------------- ------------ ------------ ------------- +POSIX? yes yes NO +return value if error -1 -1 NULL +get break value . sbrk(0) int x=0; kbrk(&x); +set break value to X brk(X) sbrk(X - sbrk(0)) int x=X, y=0; kbrk(&x) - kbrk(&y); +enlarge heap by N bytes . sbrk(+N) int x=N; kbrk(&x); +shrink heap by N bytes . sbrk(-N) int x=-N; kbrk(&x); +can you tell if you're + given more memory + than you wanted? no no yes +*****************************************************************************/ +static void *kbrk(int *delta) +{ + static char heap[HEAP_SIZE]; +/**/ + char *new_brk, *old_brk; + +/* heap doesn't exist yet */ + if(g_heap_bot == NULL) + { + g_heap_bot = g_kbrk = heap; + g_heap_top = g_heap_bot + HEAP_SIZE; + } + new_brk = g_kbrk + (*delta); +/* too low: return NULL */ + if(new_brk < g_heap_bot) + return NULL; +/* too high: return NULL */ + if(new_brk >= g_heap_top) + return NULL; +/* success: adjust brk value... */ + old_brk = g_kbrk; + g_kbrk = new_brk; +/* ...return actual delta... (for this sbrk(), they are the same) + (*delta) = (*delta); */ +/* ...return old brk value */ + return old_brk; +} +/***************************************************************************** +kmalloc() and kfree() use g_heap_bot, but not g_kbrk nor g_heap_top +*****************************************************************************/ +void *kmalloc(size_t size) +{ + unsigned total_size; + malloc_t *m, *n; + int delta; + + if(size == 0) + return NULL; + total_size = size + sizeof(malloc_t); +/* search heap for free block (FIRST FIT) */ + m = (malloc_t *)g_heap_bot; +/* g_heap_bot == 0 == NULL if heap does not yet exist */ + if(m != NULL) + { + if(m->magic != MALLOC_MAGIC) +// panic("kernel heap is corrupt in kmalloc()"); + { + printf("*** kernel heap is corrupt in kmalloc()\n"); + return NULL; + } + for(; m->next != NULL; m = m->next) + { + if(m->used) + continue; +/* size == m->size is a perfect fit */ + if(size == m->size) + m->used = 1; + else + { +/* otherwise, we need an extra sizeof(malloc_t) bytes for the header +of a second, free block */ + if(total_size > m->size) + continue; +/* create a new, smaller free block after this one */ + n = (malloc_t *)((char *)m + total_size); + n->size = m->size - total_size; + n->next = m->next; + n->magic = MALLOC_MAGIC; + n->used = 0; +/* reduce the size of this block and mark it used */ + m->size = size; + m->next = n; + m->used = 1; + } + return (char *)m + sizeof(malloc_t); + } + } +/* use kbrk() to enlarge (or create!) heap */ + delta = total_size; + n = kbrk(&delta); +/* uh-oh */ + if(n == NULL) + return NULL; + if(m != NULL) + m->next = n; + n->size = size; + n->magic = MALLOC_MAGIC; + n->used = 1; +/* did kbrk() return the exact amount of memory we wanted? +cast to make "gcc -Wall -W ..." shut the hell up */ + if((int)total_size == delta) + n->next = NULL; + else + { +/* it returned more than we wanted (it will never return less): +create a new, free block */ + m = (malloc_t *)((char *)n + total_size); + m->size = delta - total_size - sizeof(malloc_t); + m->next = NULL; + m->magic = MALLOC_MAGIC; + m->used = 0; + + n->next = m; + } + return (char *)n + sizeof(malloc_t); +} + +static inline void *kzalloc(size_t size) +{ + void *buf = kmalloc(size); + + memset(buf, 0, size); + return buf; +} + +/***************************************************************************** +*****************************************************************************/ +void kfree(void *blk) +{ + malloc_t *m, *n; + +/* get address of header */ + m = (malloc_t *)((char *)blk - sizeof(malloc_t)); + if(m->magic != MALLOC_MAGIC) +// panic("attempt to kfree() block at 0x%p " +// "with bad magic value", blk); + { + printf("*** attempt to kfree() block at 0x%p " + "with bad magic value\n", blk); + return; + } +/* find this block in the heap */ + n = (malloc_t *)g_heap_bot; + if(n->magic != MALLOC_MAGIC) +// panic("kernel heap is corrupt in kfree()"); + { + printf("*** kernel heap is corrupt in kfree()\n"); + return; + } + for(; n != NULL; n = n->next) + { + if(n == m) + break; + } +/* not found? bad pointer or no heap or something else? */ + if(n == NULL) +// panic("attempt to kfree() block at 0x%p " +// "that is not in the heap", blk); + { + printf("*** attempt to kfree() block at 0x%p " + "that is not in the heap\n", blk); + return; + } +/* free the block */ + m->used = 0; +/* coalesce adjacent free blocks +Hard to spell, hard to do */ + for(m = (malloc_t *)g_heap_bot; m != NULL; m = m->next) + { + while(!m->used && m->next != NULL && !m->next->used) + { +/* resize this block */ + m->size += sizeof(malloc_t) + m->next->size; +/* merge with next block */ + m->next = m->next->next; + } + } +} +/***************************************************************************** +*****************************************************************************/ +void *krealloc(void *blk, size_t size) +{ + void *new_blk; + malloc_t *m; + +/* size == 0: free block */ + if(size == 0) + { + if(blk != NULL) + kfree(blk); + new_blk = NULL; + } + else + { +/* allocate new block */ + new_blk = kmalloc(size); +/* if allocation OK, and if old block exists, copy old block to new */ + if(new_blk != NULL && blk != NULL) + { + m = (malloc_t *)((char *)blk - sizeof(malloc_t)); + if(m->magic != MALLOC_MAGIC) +// panic("attempt to krealloc() block at " +// "0x%p with bad magic value", blk); + { + printf("*** attempt to krealloc() block at " + "0x%p with bad magic value\n", blk); + return NULL; + } +/* copy minimum of old and new block sizes */ + if(size > m->size) + size = m->size; + memcpy(new_blk, blk, size); +/* free the old block */ + kfree(blk); + } + } + return new_blk; +} +/***************************************************************************** +*****************************************************************************/ + +#if 0 + +#include /* rand() */ + + +#define SLOTS 17 + +int main(void) +{ + unsigned lifetime[SLOTS]; + void *blk[SLOTS]; + int i, j, k; + + dump_heap(); + memset(lifetime, 0, sizeof(lifetime)); + memset(blk, 0, sizeof(blk)); + for(i = 0; i < 1000; i++) + { + printf("Pass %6u\n", i); + for(j = 0; j < SLOTS; j++) + { +/* age the block */ + if(lifetime[j] != 0) + { + (lifetime[j])--; + continue; + } +/* too old; free it */ + if(blk[j] != NULL) + { + kfree(blk[j]); + blk[j] = NULL; + } +/* alloc new block of random size +Note that size_t==unsigned, but kmalloc() uses integer math, +so block size must be positive integer */ +#if defined(_32BIT) + k = rand() % 40960 + 1; +#else + k = rand() % 4096 + 1; +#endif + blk[j] = kmalloc(k); + if(blk[j] == NULL) + printf("failed to alloc %u bytes\n", k); + else +/* give it a random lifetime 0-20 */ + lifetime[j] = rand() % 21; + } + } +/* let's see what we've wrought */ + printf("\n\n"); + dump_heap(); +/* free everything */ + for(j = 0; j < SLOTS; j++) + { + if(blk[j] != NULL) + { + kfree(blk[j]); + blk[j] = NULL; + } + (lifetime[j]) = 0; + } +/* after all that, we should have a single, unused block */ + dump_heap(); + return 0; +} +/***************************************************************************** +*****************************************************************************/ + +int main(void) +{ + void *b1, *b2, *b3; + + dump_heap(); + + b1 = kmalloc(42); + dump_heap(); + + b2 = kmalloc(23); + dump_heap(); + + b3 = kmalloc(7); + dump_heap(); + + b2 = krealloc(b2, 24); + dump_heap(); + + kfree(b1); + dump_heap(); + + b1 = kmalloc(5); + dump_heap(); + + kfree(b2); + dump_heap(); + + kfree(b3); + dump_heap(); + + kfree(b1); + dump_heap(); + + return 0; +} +#endif + diff --git a/conts/posix/fs0/src/lib/pathstr.c b/conts/posix/fs0/src/lib/pathstr.c new file mode 100644 index 0000000..8492da7 --- /dev/null +++ b/conts/posix/fs0/src/lib/pathstr.c @@ -0,0 +1,92 @@ +/* + * Functions to manipulate path strings. + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include + +/* Reverses a string by allocating on stack. Not super-efficient but easy. */ +char *strreverse(char *str) +{ + int length = strlen(str); + char *tmp = alloca(length); + + strcpy(tmp, str); + + for (int i = 0; i < length; i++) + str[i] = tmp[length - 1 - i]; + + return str; +} + +/* + * Splits the string str according to the given seperator, returns the + * first component, and modifies the str so that it points at the next + * available component (or a leading separator which can be filtered + * out on a subsequent call to this function). + */ +char *splitpath(char **str, char sep) +{ + char *cursor = *str; + char *end; + + /* Move forward until no seperator */ + while (*cursor == sep) { + *cursor = '\0'; + cursor++; /* Move to first char of component */ + } + + end = cursor; + while (*end != sep && *end != '\0') + end++; /* Move until end of component */ + + if (*end == sep) { /* if ended with separator */ + *end = '\0'; /* finish component by null */ + if (*(end + 1) != '\0') /* if more components after, */ + *str = end + 1; /* assign beginning to str */ + else + *str = end; /* else str is also depleted, give null */ + } else /* if end was null, that means the end for str, too. */ + *str = end; + + return cursor; +} + +/* Same as split path, but splits components from the end. Slow. */ +char *splitpath_end(char **path, char sep) +{ + char *component; + + /* Reverse the string */ + strreverse(*path); + + /* Pick one from the start */ + component = splitpath(path, sep); + + /* Reverse the rest back to original. */ + strreverse(*path); + + /* Reverse component back to original */ + strreverse(component); + + return component; +} + +/* Splitpath test program. Tests all 3 functions. +int main() +{ + char str1[256] = "/a/b/c/d/////e/f"; + char *str2 = malloc(strlen(str1) + 1); + char *comp; + + strcpy(str2, str1); + + comp = splitpath_end(&str2, '/'); + while (*comp) { + printf("%s and %s\n", comp, str2); + comp = splitpath_end(&str2, '/'); + } +} +*/ + diff --git a/conts/posix/fs0/src/lib/vaddr.c b/conts/posix/fs0/src/lib/vaddr.c new file mode 100644 index 0000000..8a847a7 --- /dev/null +++ b/conts/posix/fs0/src/lib/vaddr.c @@ -0,0 +1,39 @@ +/* + * This module allocates an unused virtual address range for shm segments. + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include INC_GLUE(memory.h) +#include +#include + +void vaddr_pool_init(struct id_pool *pool, unsigned long start, unsigned long end) +{ + pool = id_pool_new_init(__pfn(end - start)); +} + +void *vaddr_new(struct id_pool *pool, int npages) +{ + unsigned int shm_vpfn; + + if ((int)(shm_vpfn = ids_new_contiguous(pool, npages)) < 0) + return 0; + + return (void *)__pfn_to_addr(shm_vpfn + SHM_AREA_START); +} + +int vaddr_del(struct id_pool *pool, void *vaddr, int npages) +{ + unsigned long idpfn = __pfn(page_align(vaddr) - SHM_AREA_START); + + if (ids_del_contiguous(pool, idpfn, npages) < 0) { + printf("%s: Invalid address range returned to " + "virtual address pool.\n", __FUNCTION__); + return -1; + } + return 0; +} + diff --git a/conts/posix/fs0/src/lookup.c b/conts/posix/fs0/src/lookup.c new file mode 100644 index 0000000..2453f6f --- /dev/null +++ b/conts/posix/fs0/src/lookup.c @@ -0,0 +1,90 @@ +/* + * Inode lookup. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include + +/* + * Given a dentry that has been populated by readdir with children dentries + * and their vnodes, this itself checks all those children on that level for + * a match, but it also calls lookup, which recursively checks lower levels. + */ +struct vnode *lookup_dentry_children(struct dentry *parentdir, + struct pathdata *pdata) +{ + struct dentry *childdir; + struct vnode *v; + const char *component = pathdata_next_component(pdata); + + list_foreach_struct(childdir, &parentdir->children, child) + if (IS_ERR(v = childdir->vnode->ops.lookup(childdir->vnode, + pdata, component))) + /* Means not found, continue search */ + if ((int)v == -ENOENT) + continue; + else /* A real error */ + return v; + else /* No error, so found it */ + return v; + + /* Out of all children dentries, neither was a match */ + return PTR_ERR(-ENOENT); +} + +/* Lookup, recursive, assuming single-mountpoint */ +struct vnode *generic_vnode_lookup(struct vnode *thisnode, + struct pathdata *pdata, + const char *component) +{ + struct dentry *d; + struct vnode *found; + int err; + + /* Does this path component match with any of this vnode's dentries? */ + list_foreach_struct(d, &thisnode->dentries, vref) { + if (d->ops.compare(d, component)) { + /* Is this a directory? */ + if (vfs_isdir(thisnode)) { + /* Are there more path components? */ + if (!list_empty(&pdata->list)) { + /* Read directory contents */ + if ((err = d->vnode->ops.readdir(d->vnode)) < 0) + return PTR_ERR(err); + + /* Search all children one level below. */ + if ((found = lookup_dentry_children(d, pdata))) + /* Either found, or non-zero error */ + return found; + } else + return thisnode; + } else { /* Its a file */ + if (!list_empty(&pdata->list)) /* There's still path, but not directory */ + return PTR_ERR(-ENOTDIR); + else /* No path left, found it, so return file */ + return thisnode; + } + } + } + + /* Not found, return nothing */ + return PTR_ERR(-ENOENT); +} + +int generic_dentry_compare(struct dentry *d, const char *name) +{ + if (!strcmp(d->name, name) || !strcmp(name, VFS_STR_CURDIR)) + return 1; + else + return 0; +} + +struct dentry_ops generic_dentry_operations = { + .compare = generic_dentry_compare, +}; + diff --git a/conts/posix/fs0/src/memfs/file.c b/conts/posix/fs0/src/memfs/file.c new file mode 100644 index 0000000..dd78b56 --- /dev/null +++ b/conts/posix/fs0/src/memfs/file.c @@ -0,0 +1,142 @@ +/* + * Memfs file operations + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) + + +#if 0 + +/* + * FIXME: read_write() could be more layered using these functions. + */ +void *memfs_read_block(struct vnode *v, int blknum) +{ + void *buf = vfs_alloc_block(); + + if (!buf) + return PTR_ERR(-ENOMEM); + + if(!v->block[blknum]) + return PTR_ERR(-EEXIST); + + memcpy(buf, &v->block[blknum], v->sb->blocksize); + return buf; +} + +int memfs_write_block(struct vnode *v, int blknum, void *buf) +{ + if(!v->block[blknum]) + return -EEXIST; + + memcpy(&v->block[blknum], buf, v->sb->blocksize); + return 0; +} +#endif + +/* + * Handles both read and writes since most details are common. + * + * TODO: Think about whether to use inode or the vnode's fields (e.g. size) + * and when updated, which one is to be updated first. Normally if you use and + * update inode, then you sync vnode via read_vnode. but this is not really meant for + * this use, its meant for retrieving an unknown inode under the vnode with valid vnum. + * here we already have the inode. + */ +int memfs_file_read_write(struct vnode *v, unsigned int pfn, + unsigned int npages, void *buf, int wr) +{ + struct memfs_inode *i; + struct memfs_superblock *memfs_sb; + unsigned int start, end, count; + u32 blocksize; + + /* Don't support different block and page sizes for now */ + BUG_ON(v->sb->blocksize != PAGE_SIZE); + + /* Buffer must be page aligned */ + BUG_ON(!is_page_aligned(buf)); + + /* Low-level fs refs must be valid */ + BUG_ON(!(i = v->inode)); + BUG_ON(!(memfs_sb = v->sb->fs_super)); + blocksize = v->sb->blocksize; + + /* Check filesystem per-file size limit */ + if ((pfn + npages) > memfs_sb->fmaxblocks) { + printf("%s: fslimit: Trying to %s outside maximum file range: %x-%x\n", + __FUNCTION__, (wr) ? "write" : "read", pfn, pfn + npages); + return -EINVAL; /* Same error that posix llseek returns */ + } + + /* Read-specific operations */ + if (!wr) { + /* Find read boundaries from expected range and file's current range */ + start = pfn < __pfn(v->size) ? pfn : __pfn(v->size); + end = pfn + npages < __pfn(page_align_up(v->size)) + ? pfn + npages : __pfn(page_align_up(v->size)); + count = end - start; + + /* Copy the data from inode blocks into page buffer */ + for (int x = start, bufpage = 0; x < end; x++, bufpage++) + memcpy(((void *)buf) + (bufpage * blocksize), + i->block[x], blocksize); + return (int)(count * blocksize); + } else { /* Write-specific operations */ + /* Is the write beyond current file size? */ + if (v->size < ((pfn + npages) * (blocksize))) { + unsigned long pagediff = pfn + npages - __pfn(v->size); + unsigned long holes; + + /* + * If write is not consecutively after the currently + * last file block, the gap must be filled in by holes. + */ + if (pfn > __pfn(v->size)) + holes = pfn - __pfn(v->size); + else + holes = 0; + + /* Allocate new blocks */ + for (int x = 0; x < pagediff; x++) + if (!(i->block[__pfn(v->size) + x] = + memfs_alloc_block(v->sb->fs_super))) + return -ENOSPC; + + /* Zero out the holes. FIXME: How do we zero out non-page-aligned bytes?` */ + for (int x = 0; x < holes; x++) + memset(i->block[__pfn(v->size) + x], 0, blocksize); + } + + /* Copy the data from page buffer into inode blocks */ + for (int x = pfn, bufpage = 0; x < pfn + npages; x++, bufpage++) + memcpy(i->block[x], ((void *)buf) + (bufpage * blocksize), blocksize); + } + + return (int)(npages * blocksize); +} + +int memfs_file_write(struct vnode *v, unsigned long pfn, unsigned long npages, void *buf) +{ + return memfs_file_read_write(v, pfn, npages, buf, 1); +} + +int memfs_file_read(struct vnode *v, unsigned long pfn, unsigned long npages, void *buf) +{ + return memfs_file_read_write(v, pfn, npages, buf, 0); +} + +struct file_ops memfs_file_operations = { + .read = memfs_file_read, + .write = memfs_file_write, +}; + diff --git a/conts/posix/fs0/src/memfs/memfs.c b/conts/posix/fs0/src/memfs/memfs.c new file mode 100644 index 0000000..72bb764 --- /dev/null +++ b/conts/posix/fs0/src/memfs/memfs.c @@ -0,0 +1,215 @@ +/* + * A simple read/writeable memory-only filesystem. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) + +struct memfs_superblock *memfs_superblock; + +/* Initialise allocation caches as part of superblock initialisation */ +int memfs_init_caches(struct memfs_superblock *sb) +{ + void *free_block; + struct mem_cache *block_cache; + struct mem_cache *inode_cache; + + /* Use the whole filesystem space to initialise block cache */ + free_block = (void *)sb + sizeof(*sb); + block_cache = mem_cache_init(free_block, sb->fssize - sizeof(*sb), + sb->blocksize, 1); + list_insert(&block_cache->list, &sb->block_cache_list); + + /* Allocate a block and initialise it as first inode cache */ + free_block = mem_cache_alloc(block_cache); + inode_cache = mem_cache_init(free_block, sb->blocksize, + sizeof(struct memfs_inode), 0); + list_insert(&inode_cache->list, &sb->inode_cache_list); + + return 0; +} + +/* + * Given an empty block buffer, initialises a filesystem there. + */ +int memfs_format_filesystem(void *buffer) +{ + struct memfs_superblock *sb = buffer; /* Buffer is the first block */ + + /* Zero initialise the superblock area */ + memset(sb, 0, sizeof(*sb)); + + /* Initialise filesystem parameters */ + sb->magic = MEMFS_MAGIC; + memcpy(sb->name, MEMFS_NAME, MEMFS_NAME_SIZE); + sb->blocksize = MEMFS_BLOCK_SIZE; + sb->fmaxblocks = MEMFS_FMAX_BLOCKS; + sb->fssize = MEMFS_TOTAL_SIZE; + + /* Initialise block and inode index pools */ + sb->ipool = id_pool_new_init(MEMFS_TOTAL_INODES); + sb->bpool = id_pool_new_init(MEMFS_TOTAL_BLOCKS); + + /* Initialise bitmap allocation lists for blocks and inodes */ + link_init(&sb->block_cache_list); + link_init(&sb->inode_cache_list); + memfs_init_caches(sb); + + return 0; +} + +/* Allocates a block of unused buffer */ +void *memfs_alloc_block(struct memfs_superblock *sb) +{ + struct mem_cache *cache; + + list_foreach_struct(cache, &sb->block_cache_list, list) { + if (cache->free) + return mem_cache_zalloc(cache); + else + continue; + } + return PTR_ERR(-ENOSPC); +} + +/* + * Even though on a list, block allocation is currently from a single cache. + * This frees a block back to the free buffer cache. + */ +int memfs_free_block(struct memfs_superblock *sb, void *block) +{ + struct mem_cache *c, *tmp; + + list_foreach_removable_struct(c, tmp, &sb->block_cache_list, list) + if (!mem_cache_free(c, block)) + return 0; + else + return -EINVAL; + return -EINVAL; +} + +struct superblock *memfs_get_superblock(void *block); + +struct file_system_type memfs_fstype = { + .name = "memfs", + .magic = MEMFS_MAGIC, + .ops = { + .get_superblock = memfs_get_superblock, + }, +}; + +/* + * Initialise root inode as a directory, as in the mknod() call + * but differently since root is parentless and is the parent of itself. + */ +int memfs_init_rootdir(struct superblock *sb) +{ + struct memfs_superblock *msb = sb->fs_super; + struct dentry *d; + struct vnode *v; + + /* + * Create the root vnode. Since this is memfs, root vnode is + * not read-in but dynamically created here. We expect this + * first vnode to have vnum = 0. + */ + v = sb->root = sb->ops->alloc_vnode(sb); + msb->root_vnum = sb->root->vnum; + BUG_ON(msb->root_vnum != 0); + + /* Initialise fields */ + vfs_set_type(v, S_IFDIR); + + /* Allocate a new vfs dentry */ + if (!(d = vfs_alloc_dentry())) + return -ENOMEM; + + /* + * Initialise root dentry. + * + * NOTE: Root's parent is itself. + * Here's how it looks like in structures: + * root's parent is root. But root's child is not root. + * + * NOTE: Root has no name. This helps since splitpath + * cuts out the '/' and "" is left for root name search. + */ + strncpy(d->name, VFS_STR_ROOTDIR, VFS_DNAME_MAX); + d->ops = generic_dentry_operations; + d->parent = d; + d->vnode = v; + + /* Associate dentry with its vnode */ + list_insert(&d->vref, &d->vnode->dentries); + + /* Add both vnode and dentry to their flat caches */ + list_insert(&d->cache_list, &dentry_cache); + list_insert(&v->cache_list, &vnode_cache); + + return 0; +} + +/* Copies fs-specific superblock into generic vfs superblock */ +struct superblock *memfs_fill_superblock(struct memfs_superblock *sb, + struct superblock *vfs_sb) +{ + vfs_sb->fs = &memfs_fstype; + vfs_sb->ops = &memfs_superblock_operations; + vfs_sb->fs_super = sb; + vfs_sb->fssize = sb->fssize; + vfs_sb->blocksize = sb->blocksize; + + /* We initialise the root vnode as the root directory */ + memfs_init_rootdir(vfs_sb); + + return vfs_sb; +} + +/* + * Probes block buffer for a valid memfs superblock, if found, + * allocates and copies data to a vfs superblock, and returns it. + */ +struct superblock *memfs_get_superblock(void *block) +{ + struct memfs_superblock *sb = block; + struct superblock *vfs_sb; + + // printf("%s: %s: Reading superblock.\n", __TASKNAME__, __FUNCTION__); + /* We don't do sanity checks here, just confirm id. */ + if (strcmp(sb->name, "memfs")) { + printf("%s: Name does not match: %s\n", __FUNCTION__, sb->name); + return 0; + } + if (sb->magic != MEMFS_MAGIC) { + printf("%s: Magic number not match: %u\n", __FUNCTION__, sb->magic); + return 0; + } + + /* Allocate a vfs superblock. */ + vfs_sb = vfs_alloc_superblock(); + + /* Fill generic sb from fs-specific sb */ + return memfs_fill_superblock(sb, vfs_sb); +} + +/* Registers sfs as an available filesystem type */ +void memfs_register_fstype(struct link *fslist) +{ + /* Initialise superblock list for this fstype */ + link_init(&memfs_fstype.sblist); + + /* Add this fstype to list of available fstypes. */ + list_insert(&memfs_fstype.list, fslist); +} + diff --git a/conts/posix/fs0/src/memfs/vnode.c b/conts/posix/fs0/src/memfs/vnode.c new file mode 100644 index 0000000..ff1b6b0 --- /dev/null +++ b/conts/posix/fs0/src/memfs/vnode.c @@ -0,0 +1,427 @@ +/* + * Inode and vnode implementation. + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +struct memfs_inode *memfs_alloc_inode(struct memfs_superblock *sb) +{ + struct mem_cache *cache; + struct memfs_inode *i; + void *free_block; + + /* Ask existing inode caches for a new inode */ + list_foreach_struct(cache, &sb->inode_cache_list, list) { + if (cache->free) + if (!(i = mem_cache_zalloc(cache))) + return PTR_ERR(-ENOSPC); + else + return i; + else + continue; + } + + /* Ask existing block caches for a new block */ + if (IS_ERR(free_block = memfs_alloc_block(sb))) + return PTR_ERR(free_block); + + /* Initialise it as an inode cache */ + cache = mem_cache_init(free_block, sb->blocksize, + sizeof(struct memfs_inode), 0); + list_insert(&cache->list, &sb->inode_cache_list); + + if (!(i = mem_cache_zalloc(cache))) + return PTR_ERR(-ENOSPC); + else + return i; +} + +/* + * O(n^2) complexity but its simple, yet it would only reveal on high numbers. + */ +int memfs_free_inode(struct memfs_superblock *sb, struct memfs_inode *i) +{ + struct mem_cache *c, *tmp; + + list_foreach_removable_struct(c, tmp, &sb->inode_cache_list, list) { + /* Free it, if success */ + if (!mem_cache_free(c, i)) { + /* If cache completely emtpy */ + if (mem_cache_is_empty(c)) { + /* Free the block, too. */ + list_remove(&c->list); + memfs_free_block(sb, c); + } + return 0; + } + } + return -EINVAL; +} + +/* Allocates *and* initialises the inode */ +struct memfs_inode *memfs_create_inode(struct memfs_superblock *sb) +{ + struct memfs_inode *i; + + /* Allocate the inode */ + if (PTR_ERR(i = memfs_alloc_inode(sb)) < 0) + return i; + + /* Allocate a new inode number */ + if ((i->inum = id_new(sb->ipool)) < 0) + return i; + + /* Put a reference to this inode in the inode table at this index */ + sb->inode[i->inum] = i; + + return i; +} + +/* Deallocate the inode and any other closely relevant structure */ +int memfs_destroy_inode(struct memfs_superblock *sb, struct memfs_inode *i) +{ + int inum = i->inum; + + /* Deallocate the inode */ + if (memfs_free_inode(sb, i) < 0) + return -EINVAL; + + /* Deallocate the inode number */ + if (id_del(sb->ipool, inum) < 0) + return -EINVAL; + + /* Clear the ref in inode table */ + sb->inode[inum] = 0; + + return 0; +} + +/* Allocates both an inode and a vnode and associates the two together */ +struct vnode *memfs_alloc_vnode(struct superblock *sb) +{ + struct memfs_inode *i; + struct vnode *v; + + /* Get a (pseudo-disk) memfs inode */ + if (IS_ERR(i = memfs_create_inode(sb->fs_super))) + return PTR_ERR(i); + + /* Get a vnode */ + if (!(v = vfs_alloc_vnode())) + return PTR_ERR(-ENOMEM); + + /* Associate the two together */ + v->inode = i; + v->vnum = i->inum; + + /* Associate memfs-specific fields with vnode */ + v->ops = memfs_vnode_operations; + v->fops = memfs_file_operations; + v->sb = sb; + + /* Return the vnode */ + return v; +} + +/* Frees the inode and the corresponding vnode */ +int memfs_free_vnode(struct superblock *sb, struct vnode *v) +{ + struct memfs_inode *i = v->inode; + + BUG_ON(!i); /* Vnodes that come here must have valid inodes */ + + /* Destroy on-disk inode */ + memfs_destroy_inode(sb->fs_super, i); + + /* Free vnode */ + vfs_free_vnode(v); + + return 0; +} + +/* + * Given a vnode with a valid vnum, this retrieves the corresponding + * inode from the filesystem. + */ +struct memfs_inode *memfs_read_inode(struct superblock *sb, struct vnode *v) +{ + struct memfs_superblock *fssb = sb->fs_super; + + BUG_ON(!fssb->inode[v->vnum]); + + return fssb->inode[v->vnum]; +} + +/* + * Given a preallocated vnode with a valid vnum, this reads the corresponding + * inode from the filesystem and fills in the vnode's fields. + */ +int memfs_read_vnode(struct superblock *sb, struct vnode *v) +{ + struct memfs_inode *i = memfs_read_inode(sb, v); + + if (!i) + return -EEXIST; + + /* Simply copy common fields */ + v->vnum = i->inum; + v->size = i->size; + v->mode = i->mode; + v->owner = i->owner; + v->atime = i->atime; + v->mtime = i->mtime; + v->ctime = i->ctime; + + return 0; +} + +/* Writes a valid vnode's fields back to its fs-specific inode */ +int memfs_write_vnode(struct superblock *sb, struct vnode *v) +{ + struct memfs_inode *i = v->inode; + + /* Vnodes that come here must have valid inodes */ + BUG_ON(!i); + + /* Simply copy common fields */ + i->inum = v->vnum; + i->size = v->size; + i->mode = v->mode; + i->owner = v->owner; + i->atime = v->atime; + i->mtime = v->mtime; + i->ctime = v->ctime; + + return 0; +} + + +/* + * Creates ordinary files and directories at the moment. In the future, + * other file types will be added. Returns the created node. + */ +struct vnode *memfs_vnode_mknod(struct vnode *v, const char *dirname, + unsigned int mode) +{ + struct dentry *d, *parent = link_to_struct(v->dentries.next, + struct dentry, vref); + struct memfs_dentry *memfsd; + struct dentry *newd; + struct vnode *newv; + int err; + + /* + * Precautions to prove that parent is the *only* dentry, + * since directories can't have multiple dentries associated + * with them. + */ + BUG_ON(list_empty(&v->dentries)); + BUG_ON(parent->vref.next != &v->dentries); + BUG_ON(!vfs_isdir(v)); + + /* Populate the children */ + if ((err = v->ops.readdir(v)) < 0) + return PTR_ERR(err); + + /* Check there's no existing child with same name */ + list_foreach_struct(d, &parent->children, child) { + /* Does the name exist as a child? */ + if(d->ops.compare(d, dirname)) + return PTR_ERR(-EEXIST); + } + + /* Allocate a new vnode for the new directory */ + if (IS_ERR(newv = v->sb->ops->alloc_vnode(v->sb))) + return newv; + + /* Initialise the vnode */ + vfs_set_type(newv, mode); + + /* Get the next directory entry available on the parent vnode */ + if (v->dirbuf.npages * PAGE_SIZE <= v->size) + return PTR_ERR(-ENOSPC); + + /* Fill in the new entry to parent directory entry */ + memfsd = (struct memfs_dentry *)&v->dirbuf.buffer[v->size]; + memfsd->offset = v->size; + memfsd->rlength = sizeof(*memfsd); + memfsd->inum = ((struct memfs_inode *)newv->inode)->inum; + strncpy((char *)memfsd->name, dirname, MEMFS_DNAME_MAX); + memfsd->name[MEMFS_DNAME_MAX - 1] = '\0'; + + /* Write the updated directory buffer back to disk block */ + if ((err = v->fops.write(v, 0, 1, v->dirbuf.buffer)) < 0) + return PTR_ERR(err); /* FIXME: free all you allocated so far */ + + /* Update parent vnode size */ + v->size += sizeof(*memfsd); + v->sb->ops->write_vnode(v->sb, v); + + /* Allocate a new vfs dentry */ + if (!(newd = vfs_alloc_dentry())) + return PTR_ERR(-ENOMEM); + + /* Initialise it */ + newd->ops = generic_dentry_operations; + newd->parent = parent; + newd->vnode = newv; + strncpy(newd->name, dirname, VFS_DNAME_MAX); + + /* Associate dentry with its vnode */ + list_insert(&newd->vref, &newd->vnode->dentries); + + /* Associate dentry with its parent */ + list_insert(&newd->child, &parent->children); + + /* Add both vnode and dentry to their flat caches */ + list_insert(&newd->cache_list, &dentry_cache); + list_insert(&newv->cache_list, &vnode_cache); + + return newv; +} + +/* + * Reads the vnode directory contents into vnode's buffer in a posix-compliant + * struct dirent format. + * + * Reading the buffer, allocates and populates all dentries and their + * corresponding vnodes that are the direct children of vnode v. This means + * that by each call to readdir, the vfs layer increases its cache of filesystem + * tree by one level beneath that directory. + */ +int memfs_vnode_readdir(struct vnode *v) +{ + int err; + struct memfs_dentry *memfsd; + struct dentry *parent = link_to_struct(v->dentries.next, + struct dentry, vref); + + /* + * Precautions to prove that parent is the *only* dentry, + * since directories can't have multiple dentries associated + * with them. + */ + BUG_ON(parent->vref.next != &v->dentries); + BUG_ON(!vfs_isdir(v)); + + /* If a buffer is there, it means the directory is already read */ + if (v->dirbuf.buffer) + return 0; + + /* This is as big as a page */ + if (IS_ERR(v->dirbuf.buffer = vfs_alloc_dirpage(v))) { + printf("%s: Could not allocate dirbuf.\n", __FUNCTION__); + return (int)v->dirbuf.buffer; + } + v->dirbuf.npages = 1; + + /* + * Fail if vnode size is bigger than a page. Since this allocation + * method is to be origaced, we can live with this limitation for now. + */ + BUG_ON(v->size > PAGE_SIZE); + + /* Read memfsd contents into the buffer */ + if ((err = v->fops.read(v, 0, 1, v->dirbuf.buffer))) + return err; + + memfsd = (struct memfs_dentry *)v->dirbuf.buffer; + + /* Read fs-specific directory entry into vnode and dentry caches. */ + for (int i = 0; i < (v->size / sizeof(struct memfs_dentry)); i++) { + struct dentry *newd; + struct vnode *newv; + + /* Allocate a vfs dentry */ + if (!(newd = vfs_alloc_dentry())) + return -ENOMEM; + + /* Initialise it */ + newd->ops = generic_dentry_operations; + newd->parent = parent; + list_insert(&newd->child, &parent->children); + + /* + * Lookup the vnode for dentry by its vnode number. We call + * vnode_lookup_byvnum instead of directly reading it because + * this dentry might just be a link to a vnode that's already + * in the vnode cache. If it's not there, the lookup function + * allocates and reads it for us as well. + */ + newv = newd->vnode = vfs_lookup_byvnum(v->sb, memfsd[i].inum); + if (!newv) { + printf("Filesystem seems to be broken. Directory has" + "inode number: %d, but no such inode found.\n", + memfsd[i].inum); + BUG(); + } + + /* Assing this dentry as a name of its vnode */ + list_insert(&newd->vref, &newd->vnode->dentries); + + /* Increase link count */ + newv->links++; + + /* Copy fields into generic dentry */ + memcpy(newd->name, memfsd[i].name, MEMFS_DNAME_MAX); + + /* Add both vnode and dentry to their caches */ + list_insert(&newd->cache_list, &dentry_cache); + list_insert(&newv->cache_list, &vnode_cache); + } + + return 0; +} + +/* + * Copies fs-specific dirent data into user buffer in + * generic struct dirent format. + */ +int memfs_vnode_filldir(void *userbuf, struct vnode *v, int count) +{ + int nbytes; + int err; + + /* Bytes to read, minimum of vnode size and count requested */ + nbytes = (v->size <= count) ? v->size : count; + + /* Read the dir content from fs, if haven't done so yet */ + if ((err = v->ops.readdir(v)) < 0) + return err; + + /* Do we have those bytes at hand? */ + if (v->dirbuf.buffer && (v->dirbuf.npages * PAGE_SIZE) >= nbytes) { + /* + * Memfs does a direct copy since memfs dirent format + * is the same as generic dirent format. + */ + memcpy(userbuf, v->dirbuf.buffer, nbytes); + return nbytes; + } + return 0; +} + +struct vnode_ops memfs_vnode_operations = { + .readdir = memfs_vnode_readdir, + .filldir = memfs_vnode_filldir, + .mknod = memfs_vnode_mknod, + .lookup = generic_vnode_lookup, +}; + +struct superblock_ops memfs_superblock_operations = { + .read_vnode = memfs_read_vnode, + .write_vnode = memfs_write_vnode, + .alloc_vnode = memfs_alloc_vnode, + .free_vnode = memfs_free_vnode, +}; + diff --git a/conts/posix/fs0/src/path.c b/conts/posix/fs0/src/path.c new file mode 100644 index 0000000..e5719b6 --- /dev/null +++ b/conts/posix/fs0/src/path.c @@ -0,0 +1,145 @@ +/* + * Path manipulation functions. + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +const char *pathdata_next_component(struct pathdata *pdata) +{ + struct pathcomp *p, *n; + const char *pathstr; + + list_foreach_removable_struct(p, n, &pdata->list, list) { + list_remove(&p->list); + pathstr = p->str; + kfree(p); + return pathstr; + } + return ""; +} + +/* Check there's at least one element, unlink and return the last element */ +const char *pathdata_last_component(struct pathdata *pdata) +{ + struct pathcomp *p; + const char *pathstr; + + if (!list_empty(&pdata->list)) { + p = link_to_struct(pdata->list.prev, struct pathcomp, list); + list_remove(&p->list); + pathstr = p->str; + kfree(p); + return pathstr; + } + + return ""; +} + +/* Unlink and free all path components in pathdata, and then free pathdata */ +void pathdata_destroy(struct pathdata *p) +{ + struct pathcomp *c, *n; + + list_foreach_removable_struct(c, n, &p->list, list) { + list_remove(&c->list); + kfree(c); + } + kfree(p); +} + +void pathdata_print(struct pathdata *p) +{ + struct pathcomp *comp; + + printf("Extracted path is:\n"); + list_foreach_struct(comp, &p->list, list) + printf("%s\n", comp->str); +} + +/* Extracts all path components from pathname into more presentable form */ +struct pathdata *pathdata_parse(const char *pathname, + char *pathbuf, struct tcb *task) +{ + struct pathdata *pdata = kzalloc(sizeof(*pdata)); + struct pathcomp *comp; + char *str; + + if (!pdata) + return PTR_ERR(-ENOMEM); + + /* Initialise pathdata */ + link_init(&pdata->list); + strcpy(pathbuf, pathname); + + /* First component is root if there's a root */ + if (pathname[0] == VFS_CHAR_SEP) { + if (!(comp = kzalloc(sizeof(*comp)))) { + kfree(pdata); + return PTR_ERR(-ENOMEM); + } + link_init(&comp->list); + comp->str = VFS_STR_ROOTDIR; + list_insert_tail(&comp->list, &pdata->list); + + if (task) + /* Lookup start vnode is root vnode */ + pdata->vstart = task->fs_data->rootdir; + else /* If no task, we use the root mountpoint pivot vnode */ + pdata->vstart = vfs_root.pivot; + + /* Otherwise start from current directory */ + } else { + struct dentry *curdir; + + if (!(comp = kzalloc(sizeof(*comp)))) { + kfree(pdata); + return PTR_ERR(-ENOMEM); + } + link_init(&comp->list); + + /* Get current dentry for this task */ + curdir = link_to_struct(task->fs_data->curdir->dentries.next, + struct dentry, vref); + + /* Use its name in path component */ + comp->str = curdir->name; + list_insert_tail(&comp->list, &pdata->list); + + /* Lookup start vnode is current dir vnode */ + pdata->vstart = task->fs_data->curdir; + } + + /* Add every other path component */ + str = splitpath(&pathbuf, VFS_CHAR_SEP); + while(*str) { + /* Any curdir components in path are ignored. */ + if (!strcmp(str, VFS_STR_CURDIR)) { + ; + } else { + if (!(comp = kzalloc(sizeof(*comp)))) { + pathdata_destroy(pdata); + return PTR_ERR(-ENOMEM); + } + link_init(&comp->list); + comp->str = str; + list_insert_tail(&comp->list, &pdata->list); + } + + /* Next component */ + str = splitpath(&pathbuf, VFS_CHAR_SEP); + } + // pathdata_print(pdata); + + return pdata; +} + diff --git a/conts/posix/fs0/src/romfs/romfs.c b/conts/posix/fs0/src/romfs/romfs.c new file mode 100644 index 0000000..d225ec5 --- /dev/null +++ b/conts/posix/fs0/src/romfs/romfs.c @@ -0,0 +1,86 @@ +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) + +/* + * Romfs superblock descriptor: + * + * All words are Big-Endian. + * + * Word 0: | - | r | o | m | + * Word 1: | 1 | f | s | - | + * Word 2: | Size | The number of bytes in this fs. + * Word 3: | Checksum | The checksum of first 512 bytes. + * Word 4: | Volume Name | The name of volume, padded to 16-byte boundary. + * Rest: | File Headers | The rest of the data. + */ +struct romfs_superblock { + u32 word0; + u32 word1; + u32 size; + u32 checksum; + char name[0]; +}; + +struct romfs_inode { + unsigned long mdata_size; /* Size of metadata */ + unsigned long data_offset; /* Offset of data from start of fs */ +}; + +static u32 +romfs_checksum(void *data) +{ + u32 sum = 0; + u32 *ptr = data; + + size >>= 2; + while (size > 0) { + sum += be32_to_cpu(*ptr++); + size--; + } + return sum; +} + +int romfs_fill_super(struct superblock *sb) +{ + char buf[PAGE_SIZE]; + struct romfs_superblock *romfs_sb = (struct romfs_superblock *)buf; + unsigned long vroot_offset; + struct vnode *vroot; + + /* Read first page from block device */ + bdev_readpage(0, buf); + + /* Check superblock sanity */ + if (strcmp(be32_to_cpu(romfs_sb->word0), ROMFS_SB_WORD0)) { + printf("Bad magic word 0\n"); + } + if (strcmp(be32_to_cpu(romfs_sb->word1), ROMFS_SB_WORD1)) { + printf("Bad magic word 1\n"); + } + if (romfs_checksum(romfs_sb, min(romfs_sb->size, PAGE_SIZE))) { + printf("Bad checksum.\n"); + } + + /* Copy some params to generic superblock */ + sb->size = be32_to_cpu(romfs_sb->size); + sb->magic = ROMFS_MAGIC; + sb->ops = romfs_ops; + + /* Offset of first vnode, which is the root vnode */ + vroot_offset = align_up(strnlen(romfs_sb->name, ROMFS_MAXNAME) + 1, 16); + if (!(vroot = romfs_read_vnode(s, vroot_offset))) { + printf("Error, could not get root inode.\n"); + } + + /* Get the dirent for this vnode */ + if (!(sb->root = new_dentry(vroot))) { + printf("Error: Could not get new dentry for root vnode.\n"); + } + +} + + diff --git a/conts/posix/fs0/src/romfs/romfs.h b/conts/posix/fs0/src/romfs/romfs.h new file mode 100644 index 0000000..fed9ab7 --- /dev/null +++ b/conts/posix/fs0/src/romfs/romfs.h @@ -0,0 +1,43 @@ +#ifndef __ROMFS_H__ +#define __ROMFS_H__ + +#define ROMFS_MAGIC 0x7275 + +#define ROMFS_FTYPE_MSK 0xF /* File mask */ +#define ROMFS_FTYPE_HRD 0 /* Hard link */ +#define ROMFS_FTYPE_DIR 1 /* Directory */ +#define ROMFS_FTYPE_REG 2 /* Regular file */ +#define ROMFS_FTYPE_SYM 3 /* Symbolic link */ +#define ROMFS_FTYPE_BLK 4 /* Block device */ +#define ROMFS_FTYPE_CHR 5 /* Char device */ +#define ROMFS_FTYPE_SCK 6 /* Socket */ +#define ROMFS_FTYPE_FIF 7 /* FIFO */ +#define ROMFS_FTYPE_EXE 8 /* Executable */ + +#define ROMFS_NAME_ALIGN 16 /* Alignment size of names */ + +#define ROMFS_SB_WORD0 "-rom" +#define ROMFS_SB_WORD1 "1fs-" + +/* + * Romfs superblock descriptor: + * + * All words are Big-Endian. + * + * Word 0: | - | r | o | m | + * Word 1: | 1 | f | s | - | + * Word 2: | Size | The number of bytes in this fs. + * Word 3: | Checksum | The checksum of first 512 bytes. + * Word 4: | Volume Name | The name of volume, padded to 16-byte boundary. + * Rest: | File Headers | The rest of the data. + */ +struct romfs_superblock { + u32 word0; + u32 word1; + u32 size; + u32 checksum; + char name[0]; +}; + + +#endif /* __ROMFS_H__ */ diff --git a/conts/posix/fs0/src/romfs/romfs_fs.h b/conts/posix/fs0/src/romfs/romfs_fs.h new file mode 100644 index 0000000..e20bbf9 --- /dev/null +++ b/conts/posix/fs0/src/romfs/romfs_fs.h @@ -0,0 +1,61 @@ +#ifndef __LINUX_ROMFS_FS_H +#define __LINUX_ROMFS_FS_H + +/* The basic structures of the romfs filesystem */ + +#define ROMBSIZE BLOCK_SIZE +#define ROMBSBITS BLOCK_SIZE_BITS +#define ROMBMASK (ROMBSIZE-1) +#define ROMFS_MAGIC 0x7275 + +#define ROMFS_MAXFN 128 + +#define __mkw(h,l) (((h)&0x00ff)<< 8|((l)&0x00ff)) +#define __mkl(h,l) (((h)&0xffff)<<16|((l)&0xffff)) +#define __mk4(a,b,c,d) cpu_to_be32(__mkl(__mkw(a,b),__mkw(c,d))) +#define ROMSB_WORD0 __mk4('-','r','o','m') +#define ROMSB_WORD1 __mk4('1','f','s','-') + +/* On-disk "super block" */ + +struct romfs_super_block { + __be32 word0; + __be32 word1; + __be32 size; + __be32 checksum; + char name[0]; /* volume name */ +}; + +/* On disk inode */ + +struct romfs_inode { + __be32 next; /* low 4 bits see ROMFH_ */ + __be32 spec; + __be32 size; + __be32 checksum; + char name[0]; +}; + +#define ROMFH_TYPE 7 +#define ROMFH_HRD 0 +#define ROMFH_DIR 1 +#define ROMFH_REG 2 +#define ROMFH_SYM 3 +#define ROMFH_BLK 4 +#define ROMFH_CHR 5 +#define ROMFH_SCK 6 +#define ROMFH_FIF 7 +#define ROMFH_EXEC 8 + +/* Alignment */ + +#define ROMFH_SIZE 16 +#define ROMFH_PAD (ROMFH_SIZE-1) +#define ROMFH_MASK (~ROMFH_PAD) + +#ifdef __KERNEL__ + +/* Not much now */ + +#endif /* __KERNEL__ */ +#endif diff --git a/conts/posix/fs0/src/syscalls.c b/conts/posix/fs0/src/syscalls.c new file mode 100644 index 0000000..9943c44 --- /dev/null +++ b/conts/posix/fs0/src/syscalls.c @@ -0,0 +1,528 @@ +/* + * Some syscall stubs + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NILFD -1 + +/* + * This informs mm0 about an opened file descriptors. + * + * MM0 *also* keeps track of fd's because mm0 is a better candidate + * for handling syscalls that access file content (i.e. read/write) since + * it maintains the page cache. MM0 is not notified about opened files + * but is rather informed when it asks to be. This avoids deadlocks by + * keeping the request flow in one way. + */ + +int pager_sys_open(struct tcb *pager, l4id_t opener, int fd) +{ + struct tcb *task; + struct vnode *v; + + //printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + if (pager->tid != PAGER_TID) + return -EINVAL; + + /* Check if such task exists */ + if (!(task = find_task(opener))) + return -ESRCH; + + /* Check if that fd has been opened */ + if (task->files->fd[fd] == NILFD) + return -EBADF; + + /* Search the vnode by that vnum */ + if (IS_ERR(v = vfs_lookup_byvnum(vfs_root.pivot->sb, + task->files->fd[fd]))) + return (int)v; + + /* + * Write file information, they will + * be sent via the return origy. + */ + write_mr(L4SYS_ARG0, v->vnum); + write_mr(L4SYS_ARG1, v->size); + + return 0; +} + +/* This is called when the pager needs to open a vfs file via its path */ +int pager_open_bypath(struct tcb *pager, char *pathname) +{ + struct pathdata *pdata; + struct tcb *task; + struct vnode *v; + int retval; + + //printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + if (pager->tid != PAGER_TID) + return -EINVAL; + + /* Parse path data */ + if (IS_ERR(pdata = pathdata_parse(pathname, + alloca(strlen(pathname) + 1), + task))) + return (int)pdata; + + /* Search the vnode by that path */ + if (IS_ERR(v = vfs_lookup_bypath(pdata))) { + retval = (int)v; + goto out; + } + + /* + * Write file information, they will + * be sent via the return origy. + */ + write_mr(L4SYS_ARG0, v->vnum); + write_mr(L4SYS_ARG1, v->size); + + return 0; + +out: + pathdata_destroy(pdata); + return retval; + +} + + +/* Directories only for now */ +void print_vnode(struct vnode *v) +{ + struct dentry *d, *c; + + printf("Vnode names:\n"); + list_foreach_struct(d, &v->dentries, vref) { + printf("%s\n", d->name); + printf("Children dentries:\n"); + list_foreach_struct(c, &d->children, child) + printf("%s\n", c->name); + } +} + +/* Creates a node under a directory, e.g. a file, directory. */ +struct vnode *vfs_create(struct tcb *task, struct pathdata *pdata, + unsigned int mode) +{ + struct vnode *vparent, *newnode; + const char *nodename; + + /* The last component is to be created */ + nodename = pathdata_last_component(pdata); + + /* Check that the parent directory exists. */ + if (IS_ERR(vparent = vfs_lookup_bypath(pdata))) + return vparent; + + /* The parent vnode must be a directory. */ + if (!vfs_isdir(vparent)) + return PTR_ERR(-ENOENT); + + /* Create new directory under the parent */ + if (IS_ERR(newnode = vparent->ops.mknod(vparent, nodename, mode))) + return newnode; + + // print_vnode(vparent); + return newnode; +} + +/* + * Pager notifies vfs about a closed file descriptor. + * + * FIXME: fsync + close could be done under a single "close" ipc + * from pager. Currently there are 2 ipcs: 1 fsync + 1 fd close. + */ +int pager_sys_close(struct tcb *sender, l4id_t closer, int fd) +{ + struct tcb *task; + int err; + + // printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + + BUG_ON(!(task = find_task(closer))); + + if ((err = id_del(task->files->fdpool, fd)) < 0) { + printf("%s: Error releasing fd identifier.\n", + __FUNCTION__); + return err; + } + task->files->fd[fd] = NILFD; + + return 0; +} + +/* FIXME: + * - Is it already open? + * - Allocate a copy of path string since lookup destroys it + * - Check flags and mode. + */ +int sys_open(struct tcb *task, const char *pathname, int flags, unsigned int mode) +{ + struct pathdata *pdata; + struct vnode *v; + int fd; + int retval; + + // printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + + /* Parse path data */ + if (IS_ERR(pdata = pathdata_parse(pathname, + alloca(strlen(pathname) + 1), + task))) + return (int)pdata; + + /* Creating new file */ + if (flags & O_CREAT) { + /* Make sure mode identifies a file */ + mode |= S_IFREG; + if (IS_ERR(v = vfs_create(task, pdata, mode))) { + retval = (int)v; + goto out; + } + } else { + /* Not creating, just opening, get the vnode */ + if (IS_ERR(v = vfs_lookup_bypath(pdata))) { + retval = (int)v; + goto out; + } + } + + /* Get a new fd */ + BUG_ON((fd = id_new(task->files->fdpool)) < 0); + retval = fd; + + /* Assign the new fd with the vnode's number */ + task->files->fd[fd] = v->vnum; + +out: + pathdata_destroy(pdata); + return retval; +} + +int sys_mkdir(struct tcb *task, const char *pathname, unsigned int mode) +{ + struct pathdata *pdata; + struct vnode *v; + int ret = 0; + + /* Parse path data */ + if (IS_ERR(pdata = pathdata_parse(pathname, + alloca(strlen(pathname) + 1), + task))) + return (int)pdata; + + /* Make sure we create a directory */ + mode |= S_IFDIR; + + /* Create the directory or fail */ + if (IS_ERR(v = vfs_create(task, pdata, mode))) + ret = (int)v; + + /* Destroy extracted path data */ + pathdata_destroy(pdata); + return ret; +} + +int sys_chdir(struct tcb *task, const char *pathname) +{ + struct vnode *v; + struct pathdata *pdata; + int ret = 0; + + /* Parse path data */ + if (IS_ERR(pdata = pathdata_parse(pathname, + alloca(strlen(pathname) + 1), + task))) + return (int)pdata; + + /* Get the vnode */ + if (IS_ERR(v = vfs_lookup_bypath(pdata))) { + ret = (int)v; + goto out; + } + + /* Ensure it's a directory */ + if (!vfs_isdir(v)) { + ret = -ENOTDIR; + goto out; + } + + /* Assign the current directory pointer */ + task->fs_data->curdir = v; + +out: + /* Destroy extracted path data */ + pathdata_destroy(pdata); + return ret; +} + +void fill_kstat(struct vnode *v, struct kstat *ks) +{ + ks->vnum = (u64)v->vnum; + ks->mode = v->mode; + ks->links = v->links; + ks->uid = v->owner & 0xFFFF; + ks->gid = (v->owner >> 16) & 0xFFFF; + ks->size = v->size; + ks->blksize = v->sb->blocksize; + ks->atime = v->atime; + ks->mtime = v->mtime; + ks->ctime = v->ctime; +} + +int sys_fstat(struct tcb *task, int fd, void *statbuf) +{ + struct vnode *v; + unsigned long vnum; + + /* Get the vnum */ + if (fd < 0 || fd > TASK_FILES_MAX || task->files->fd[fd] == NILFD) + return -EBADF; + + vnum = task->files->fd[fd]; + + /* Lookup vnode */ + if (!(v = vfs_lookup_byvnum(vfs_root.pivot->sb, vnum))) + return -EINVAL; + + /* Fill in the c0-style stat structure */ + fill_kstat(v, statbuf); + + return 0; +} + +/* + * Returns codezero-style stat structure which in turn is + * converted to posix style stat structure via the libposix + * library in userspace. + */ +int sys_stat(struct tcb *task, const char *pathname, void *statbuf) +{ + struct vnode *v; + struct pathdata *pdata; + int ret = 0; + + /* Parse path data */ + if (IS_ERR(pdata = pathdata_parse(pathname, + alloca(strlen(pathname) + 1), + task))) + return (int)pdata; + + /* Get the vnode */ + if (IS_ERR(v = vfs_lookup_bypath(pdata))) { + ret = (int)v; + goto out; + } + + /* Fill in the c0-style stat structure */ + fill_kstat(v, statbuf); + +out: + /* Destroy extracted path data */ + pathdata_destroy(pdata); + return ret; +} + +/* + * Note this can be solely called by the pager and is not the posix read call. + * That call is in the pager. This merely supplies the pages the pager needs + * if they're not in the page cache. + */ +int pager_sys_read(struct tcb *pager, unsigned long vnum, unsigned long f_offset, + unsigned long npages, void *pagebuf) +{ + struct vnode *v; + + // printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + + if (pager->tid != PAGER_TID) + return -EINVAL; + + /* Lookup vnode */ + if (!(v = vfs_lookup_byvnum(vfs_root.pivot->sb, vnum))) + return -EINVAL; + + /* Ensure vnode is not a directory */ + if (vfs_isdir(v)) + return -EISDIR; + + return v->fops.read(v, f_offset, npages, pagebuf); +} + +int pager_update_stats(struct tcb *pager, unsigned long vnum, + unsigned long newsize) +{ + struct vnode *v; + + // printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + + if (pager->tid != PAGER_TID) + return -EINVAL; + + /* Lookup vnode */ + if (!(v = vfs_lookup_byvnum(vfs_root.pivot->sb, vnum))) + return -EINVAL; + + v->size = newsize; + v->sb->ops->write_vnode(v->sb, v); + + return 0; +} + +/* + * This can be solely called by the pager and is not the posix write call. + * That call is in the pager. This writes the dirty pages of a file + * back to disk via vfs. + * + * The buffer must be contiguous by page, if npages > 1. + */ +int pager_sys_write(struct tcb *pager, unsigned long vnum, unsigned long f_offset, + unsigned long npages, void *pagebuf) +{ + struct vnode *v; + int ret; + int fwrite_end; + + // printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + + if (pager->tid != PAGER_TID) + return -EINVAL; + + /* Lookup vnode */ + if (!(v = vfs_lookup_byvnum(vfs_root.pivot->sb, vnum))) + return -EINVAL; + + /* Ensure vnode is not a directory */ + if (vfs_isdir(v)) + return -EISDIR; + + //printf("%s/%s: Writing to vnode %lu, at pgoff 0x%x, %d pages, buf at 0x%x\n", + // __TASKNAME__, __FUNCTION__, vnum, f_offset, npages, pagebuf); + + if ((ret = v->fops.write(v, f_offset, npages, pagebuf)) < 0) + return ret; + + /* + * If the file is extended, write silently extends it. + * We update the extended size here. Otherwise subsequent write's + * may fail by relying on wrong file size. + */ + fwrite_end = __pfn_to_addr(f_offset) + ret; + if (v->size < fwrite_end) { + v->size = fwrite_end; + v->sb->ops->write_vnode(v->sb, v); + } + + return ret; +} + +/* + * FIXME: Here's how this should have been: + * v->ops.readdir() -> Reads fs-specific directory contents. i.e. reads + * the directory buffer, doesn't care however contained vnode details are + * stored. + * + * After reading, it converts the fs-spceific contents into generic vfs + * dentries and populates the dentries of those vnodes. + * + * If vfs_readdir() is issued, those generic dentries are converted into + * the posix-defined directory record structure. During this on-the-fly + * generation, pseudo-entries such as . and .. are also added. + * + * If this layering is not done, i.e. the low-level dentry buffer already + * keeps this record structure and we try to return that, then we wont + * have a chance to add the pseudo-entries . and .. These record entries + * are essentially created from parent vnode and current vnode but using + * the names . and .. + */ + +int fill_dirent(void *buf, unsigned long vnum, int offset, char *name) +{ + struct dirent *d = buf; + + d->inum = (unsigned int)vnum; + d->offset = offset; + d->rlength = sizeof(struct dirent); + strncpy((char *)d->name, name, DIRENT_NAME_MAX); + + return d->rlength; +} + +/* + * Reads @count bytes of posix struct dirents into @buf. This implements + * the raw dirent read syscall upon which readdir() etc. posix calls + * can be built in userspace. + * + * FIXME: Ensure buf is in shared utcb, and count does not exceed it. + */ +int sys_readdir(struct tcb *t, int fd, void *buf, int count) +{ + int dirent_size = sizeof(struct dirent); + int total = 0, nbytes = 0; + unsigned long vnum; + struct vnode *v; + struct dentry *d; + + // printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + + /* Check address is in task's utcb */ + if ((unsigned long)buf < t->shpage_address || + (unsigned long)buf > t->shpage_address + PAGE_SIZE) + return -EINVAL; + + if (fd < 0 || fd > TASK_FILES_MAX || t->files->fd[fd] == NILFD) + return -EBADF; + + vnum = t->files->fd[fd]; + + /* Lookup vnode */ + if (!(v = vfs_lookup_byvnum(vfs_root.pivot->sb, vnum))) + return -EINVAL; + + d = link_to_struct(v->dentries.next, struct dentry, vref); + + /* Ensure vnode is a directory */ + if (!vfs_isdir(v)) + return -ENOTDIR; + + /* Write pseudo-entries . and .. to user buffer */ + if (count < dirent_size) + return 0; + + fill_dirent(buf, v->vnum, nbytes, VFS_STR_CURDIR); + nbytes += dirent_size; + buf += dirent_size; + count -= dirent_size; + + if (count < dirent_size) + return 0; + + fill_dirent(buf, d->parent->vnode->vnum, nbytes, VFS_STR_PARDIR); + nbytes += dirent_size; + buf += dirent_size; + count -= dirent_size; + + /* Copy fs-specific dir to buf in struct dirent format */ + if ((total = v->ops.filldir(buf, v, count)) < 0) + return total; + + return nbytes + total; +} + diff --git a/conts/posix/fs0/src/task.c b/conts/posix/fs0/src/task.c new file mode 100644 index 0000000..c0b7bb2 --- /dev/null +++ b/conts/posix/fs0/src/task.c @@ -0,0 +1,315 @@ +/* + * FS0 task data initialisation. + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +extern void *shared_page; + +struct global_list global_tasks = { + .list = { &global_tasks.list, &global_tasks.list }, + .total = 0, +}; + +void global_add_task(struct tcb *task) +{ + BUG_ON(!list_empty(&task->list)); + list_insert_tail(&task->list, &global_tasks.list); + global_tasks.total++; +} + +void global_remove_task(struct tcb *task) +{ + BUG_ON(list_empty(&task->list)); + list_remove_init(&task->list); + BUG_ON(--global_tasks.total < 0); +} + +struct tcb *find_task(int tid) +{ + struct tcb *t; + + list_foreach_struct(t, &global_tasks.list, list) + if (t->tid == tid) + return t; + return 0; +} + +/* Allocate a vfs task structure according to given flags */ +struct tcb *tcb_alloc_init(unsigned int flags) +{ + struct tcb *task; + + if (!(task = kzalloc(sizeof(struct tcb)))) + return PTR_ERR(-ENOMEM); + + /* Allocate new fs data struct if its not shared */ + if (!(flags & TCB_SHARED_FS)) { + if (!(task->fs_data = + kzalloc(sizeof(*task->fs_data)))) { + kfree(task); + return PTR_ERR(-ENOMEM); + } + task->fs_data->tcb_refs = 1; + } + + /* Allocate file structures if not shared */ + if (!(flags & TCB_SHARED_FILES)) { + if (!(task->files = + kzalloc(sizeof(*task->files)))) { + kfree(task->fs_data); + kfree(task); + return PTR_ERR(-ENOMEM); + } + if (IS_ERR(task->files->fdpool = + id_pool_new_init(TASK_FILES_MAX))) { + void *err = task->files->fdpool; + + kfree(task->files); + kfree(task->fs_data); + kfree(task); + return err; + } + task->files->tcb_refs = 1; + } + + /* Ids will be set up later */ + task->tid = TASK_ID_INVALID; + + /* Initialise list structure */ + link_init(&task->list); + + return task; +} + +void copy_tcb(struct tcb *to, struct tcb *from, unsigned int share_flags) +{ + if (share_flags & TCB_SHARED_FILES) { + to->files = from->files; + to->files->tcb_refs++; + } else { + /* Copy all file descriptors */ + memcpy(to->files->fd, from->files->fd, + TASK_FILES_MAX * sizeof(to->files->fd[0])); + + /* Copy the idpool */ + id_pool_copy(to->files->fdpool, from->files->fdpool, TASK_FILES_MAX); + } + + if (share_flags & TCB_SHARED_FS) { + to->fs_data = from->fs_data; + to->fs_data->tcb_refs++; + } else + memcpy(to->fs_data, from->fs_data, sizeof(*to->fs_data)); +} + +/* Allocate a task struct and initialise it */ +struct tcb *tcb_create(struct tcb *orig, l4id_t tid, unsigned long shpage, + unsigned int share_flags) +{ + struct tcb *task; + + /* Can't have some share flags with no original task */ + BUG_ON(!orig && share_flags); + + /* Create a task and use given space and thread ids. */ + if (IS_ERR(task = tcb_alloc_init(share_flags))) + return task; + + task->tid = tid; + task->shpage_address = shpage; + + /* + * If there's an original task that means this will be a full + * or partial copy of it. We copy depending on share_flags. + */ + if (orig) + copy_tcb(task, orig, share_flags); + + return task; +} + +/* Free shared structures if no references left */ +void tcb_free_resources(struct tcb *task) +{ + + if (--task->fs_data->tcb_refs == 0) + kfree(task->fs_data); + + if (--task->files->tcb_refs == 0) { + kfree(task->files->fdpool); + kfree(task->files); + } + +} + +void tcb_destroy(struct tcb *task) +{ + global_remove_task(task); + + tcb_free_resources(task); + + kfree(task); +} + +/* + * Attaches to task's utcb. TODO: Add SHM_RDONLY and test it. + * FIXME: This calls the pager and is a potential for deadlock + * it only doesn't lock because it is called during initialisation. + */ +int task_utcb_attach(struct tcb *t) +{ + int shmid; + void *shmaddr; + + /* Use it as a key to create a shared memory region */ + if ((shmid = shmget((key_t)t->shpage_address, PAGE_SIZE, 0)) == -1) + goto out_err; + + /* Attach to the region */ + if ((int)(shmaddr = shmat(shmid, (void *)t->shpage_address, 0)) == -1) + goto out_err; + + /* Ensure address is right */ + if ((unsigned long)shmaddr != t->shpage_address) + return -EINVAL; + + // printf("%s: Mapped shared page of task %d @ 0x%x\n", + // __TASKNAME__, t->tid, shmaddr); + + return 0; + +out_err: + printf("%s: Mapping utcb of task %d failed with err: %d.\n", + __TASKNAME__, t->tid, errno); + return -EINVAL; +} + +/* + * Receives ipc from pager about a new fork event and + * the information on the resulting child task. + */ +int pager_notify_fork(struct tcb *sender, l4id_t parentid, + l4id_t childid, unsigned long shpage_address, + unsigned int flags) +{ + struct tcb *child, *parent; + + // printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + BUG_ON(!(parent = find_task(parentid))); + + /* Create a child vfs tcb using given parent and copy flags */ + if (IS_ERR(child = tcb_create(parent, childid, shpage_address, flags))) + return (int)child; + + global_add_task(child); + + // printf("%s/%s: Exiting...\n", __TASKNAME__, __FUNCTION__); + return 0; +} + + +/* + * Pager tells us that a task is exiting by this call. + */ +int pager_notify_exit(struct tcb *sender, l4id_t tid) +{ + struct tcb *task; + + // printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + BUG_ON(!(task = find_task(tid))); + + tcb_destroy(task); + + // printf("%s/%s: Exiting...\n", __TASKNAME__, __FUNCTION__); + + return 0; +} + + +/* Read task information into the utcb page, since it won't fit into mrs. */ +struct task_data_head *receive_pager_taskdata(void) +{ + int err; + + /* Make the actual ipc call */ + if ((err = l4_sendrecv(PAGER_TID, PAGER_TID, + L4_IPC_TAG_TASKDATA)) < 0) { + printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + return PTR_ERR(err); + } + + /* Check if call itself was successful */ + if ((err = l4_get_retval()) < 0) { + printf("%s: Error: %d.\n", __FUNCTION__, err); + return PTR_ERR(err); + } + + /* Data is expected in the utcb page */ + // printf("%s: %d Total tasks.\n", __FUNCTION__, + // ((struct task_data_head *)shared_page)->total); + + return (struct task_data_head *)shared_page; +} + + +int init_task_structs(struct task_data_head *tdata_head) +{ + struct tcb *t; + + for (int i = 0; i < tdata_head->total; i++) { + /* New tcb with fields sent by pager */ + if (IS_ERR(t = tcb_create(0, tdata_head->tdata[i].tid, + tdata_head->tdata[i].shpage_address, + 0))) + return (int)t; + + /* Initialise vfs specific fields. */ + t->fs_data->rootdir = vfs_root.pivot; + t->fs_data->curdir = vfs_root.pivot; + + /* Print task information */ + //printf("%s: Task info received from mm0:\n", __TASKNAME__); + //printf("%s: task id: %d, utcb address: 0x%x\n", + // __TASKNAME__, t->tid, t->utcb_address); + + /* shm attach to the utcbs for all these tasks except own */ + if (t->tid != self_tid()) + task_utcb_attach(t); + global_add_task(t); + } + + return 0; +} + +int init_task_data(void) +{ + struct task_data_head *tdata_head; + + /* Read how many tasks and tids of each */ + BUG_ON((tdata_head = receive_pager_taskdata()) < 0); + + /* Initialise local task structs using this info */ + BUG_ON(init_task_structs(tdata_head) < 0); + + return 0; +} + diff --git a/conts/posix/fs0/src/vfs.c b/conts/posix/fs0/src/vfs.c new file mode 100644 index 0000000..3752fa3 --- /dev/null +++ b/conts/posix/fs0/src/vfs.c @@ -0,0 +1,84 @@ +/* + * High-level vfs implementation. + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include + +LINK_DECLARE(vnode_cache); +LINK_DECLARE(dentry_cache); + +/* + * / + * /boot + * /boot/images/mm0.axf + * /boot/images/fs0.axf + * /boot/images/test0.axf + * /file.txt + */ +struct vfs_mountpoint vfs_root; + +/* + * Vnodes in the vnode cache have 2 keys. One is their dentry names, the other + * is their vnum. This one checks the vnode cache by the given vnum first. + * If nothing is found, it reads the vnode from disk into cache. This is called + * by system calls since tasks keep an fd-to-vnum table. + */ +struct vnode *vfs_lookup_byvnum(struct superblock *sb, unsigned long vnum) +{ + struct vnode *v; + int err; + + /* Check the vnode flat list by vnum */ + list_foreach_struct(v, &vnode_cache, cache_list) + if (v->vnum == vnum) + return v; + + /* Check the actual filesystem for the vnode */ + v = vfs_alloc_vnode(); + v->vnum = vnum; + + /* Note this only checks given superblock */ + if ((err = sb->ops->read_vnode(sb, v)) < 0) { + vfs_free_vnode(v); + return PTR_ERR(err); + } + + /* Add the vnode back to vnode flat list */ + list_insert(&v->cache_list, &vnode_cache); + + return v; +} + +/* + * Vnodes in the vnode cache have 2 keys. One is the set of dentry names they + * have, the other is their vnum. This one checks the vnode cache by the path + * first. If nothing is found, it reads the vnode from disk into the cache. + */ +struct vnode *vfs_lookup_bypath(struct pathdata *pdata) +{ + const char *firstcomp; + + /* + * This does vfs cache + fs lookup. + */ + BUG_ON(list_empty(&pdata->list)); + firstcomp = pathdata_next_component(pdata); + return pdata->vstart->ops.lookup(pdata->vstart, pdata, firstcomp); +} + +int vfs_mount_root(struct superblock *sb) +{ + /* + * Lookup the root vnode of this superblock. + * The root superblock has vnode number 0. + */ + vfs_root.pivot = vfs_lookup_byvnum(sb, 0); + vfs_root.sb = sb; + + return 0; +} + diff --git a/conts/posix/fs0/tools/generate_bootdesc.py b/conts/posix/fs0/tools/generate_bootdesc.py new file mode 100755 index 0000000..9761a6d --- /dev/null +++ b/conts/posix/fs0/tools/generate_bootdesc.py @@ -0,0 +1,27 @@ +#!/usr/bin/python +import os +import sys + +compiler_prefix = "arm-linux-" +objdump = "objdump" +command = "-t" +image_name = "roottask.axf" +linkoutput_file_suffix = "-linkinfo.txt" +linkoutput_file = image_name + linkoutput_file_suffix +def generate_bootdesc(): + command = compiler_prefix + objdump + " -t " + image_name + " > " + linkoutput_file + print command + os.system(command) + f = open(linkoutput_file, "r") + + while True: + line = f.readline() + if len(line) is 0: + break + if "_start" in line or "_end" in line: + print line + f.close() + +if __name__ == "__main__": + generate_bootdesc() + diff --git a/conts/posix/libposix/README b/conts/posix/libposix/README new file mode 100644 index 0000000..bce1bcc --- /dev/null +++ b/conts/posix/libposix/README @@ -0,0 +1,84 @@ + +libposix + +Copyright (C) 2007 Bahadir Balban + +Despite the name, this is a library that supports only a small portion of posix +functions. + +Note however, that unlike many other shallow POSIX implementations function +listed below are backed by a real virtual memory subsystem and a virtual +filesystem. + +Highest priority POSIX functions are: + +shmat +shmget +shmdt +mmap +munmap +sbrk +read +readdir +write +lseek +open +close +creat +mkdir +mknod +link +unlink +fork +clone +execve +getpid +wait +kill +getenv +setenv + + +Currently supported functions are: + +shmat +shmget +shmdt +mmap +munmap +read +readdir +write +lseek +open +close +creat +mkdir +mknod +fork +clone +execve +exit +getpid + + +Functions to be supported in the near future are: + +link +unlink +wait +kill +sbrk +getenv +setenv + + +Other calls: +pipe +mount +unmount +swapon + + +New ones will be added as needed. + diff --git a/conts/posix/libposix/SConscript b/conts/posix/libposix/SConscript new file mode 100644 index 0000000..0ad256e --- /dev/null +++ b/conts/posix/libposix/SConscript @@ -0,0 +1,16 @@ +# -*- mode: python; coding: utf-8; -*- + +# Codezero -- A Virtualization microkernel for embedded systems. +# +# Copyright © 2009 B Labs Ltd + +Import('env') + +e = env.Clone() +e.Append(CPPPATH = ['include', 'include/posix']) +e.Replace(CCFLAGS = ['-g', '-nostdlib', '-Wall', '-ffreestanding', '-std=gnu99']) + +objects = e.StaticObject(Glob('*.c')) +libposix = e.StaticLibrary('posix', objects) + +Return('libposix') diff --git a/conts/posix/libposix/SConstruct b/conts/posix/libposix/SConstruct new file mode 100644 index 0000000..352c734 --- /dev/null +++ b/conts/posix/libposix/SConstruct @@ -0,0 +1,74 @@ +# +# Copyright (C) 2007 Bahadir Balban +# + +import os +import glob +import sys +from os.path import join +from string import split + +project_root = "../.." +kernel_headers = join(project_root, "include") +l4lib_headers = join(project_root, "tasks/libl4/include") +config_h = join(project_root, "include/l4/config.h") + +env = Environment(CC = 'arm-none-linux-gnueabi-gcc', + CCFLAGS = ['-g', '-std=gnu99', '-nostdlib', '-ffreestanding'], + LINKFLAGS = ['-nostdlib'], + CPPPATH = ['#include'], + ENV = {'PATH' : os.environ['PATH']}, + LIBS = 'gcc') + + +def extract_arch_subarch_plat(config_header): + ''' + From the autogenerated kernel config.h, extracts platform, archictecture, + subarchitecture information. This is used to include the relevant headers + from the kernel directories. + ''' + arch = None + subarch = None + plat = None + + if not os.path.exists(config_header): + print "\n\nconfig.h does not exist. "\ + "Please run: `scons configure' first\n\n" + sys.exit() + f = open(config_h, "r") + while True: + line = f.readline() + if line == "": + break + parts = split(line) + if len(parts) > 0: + if parts[0] == "#define": + if parts[1] == "__ARCH__": + arch = parts[2] + elif parts[1] == "__PLATFORM__": + plat = parts[2] + elif parts[1] == "__SUBARCH__": + subarch = parts[2] + f.close() + if arch == None: + print "Error: No config symbol found for architecture" + sys.exit() + if subarch == None: + print "Error: No config symbol found for subarchitecture" + sys.exit() + if plat == None: + print "Error: No config symbol found for platform" + sys.exit() + return arch, subarch, plat + +arch, subarch, plat = extract_arch_subarch_plat(config_h) + +headers = ["#include/posix", l4lib_headers, kernel_headers] + +env.Append(CPPPATH = headers) + +src = glob.glob("src/*.c") + glob.glob("*.c") + +libposix = env.StaticLibrary('posix', src) + + diff --git a/conts/posix/libposix/chdir.c b/conts/posix/libposix/chdir.c new file mode 100644 index 0000000..5169745 --- /dev/null +++ b/conts/posix/libposix/chdir.c @@ -0,0 +1,54 @@ +/* + * l4/posix glue for mkdir() + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) + +static inline int l4_chdir(const char *pathname) +{ + int fd; + + // write_mr(L4SYS_ARG0, (unsigned long)pathname); + copy_to_shpage((void *)pathname, 0, strlen(pathname) + 1); + write_mr(L4SYS_ARG0, (unsigned long)shared_page); + + /* Call pager with shmget() request. Check ipc error. */ + if ((fd = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_CHDIR)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, fd); + return fd; + } + /* Check if syscall itself was successful */ + if ((fd = l4_get_retval()) < 0) { + print_err("%s: MKDIR Error: %d.\n", __FUNCTION__, fd); + return fd; + } + return fd; +} + +int chdir(const char *pathname) +{ + int ret; + + /* If error, return positive error code */ + if ((ret = l4_chdir(pathname)) < 0) { + errno = -ret; + return -1; + } + /* else return value */ + return ret; +} + diff --git a/conts/posix/libposix/close.c b/conts/posix/libposix/close.c new file mode 100644 index 0000000..2e4fc46 --- /dev/null +++ b/conts/posix/libposix/close.c @@ -0,0 +1,78 @@ +/* + * l4/posix glue for close() and fsync() + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) +#include + +static inline int l4_close(int fd) +{ + write_mr(L4SYS_ARG0, fd); + + /* Call pager with close() request. Check ipc error. */ + if ((fd = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_CLOSE)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, fd); + return fd; + } + /* Check if syscall itself was successful */ + if ((fd = l4_get_retval()) < 0) { + print_err("%s: CLOSE Error: %d.\n", __FUNCTION__, fd); + return fd; + } + return fd; +} + +int close(int fd) +{ + int ret = l4_close(fd); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + + /* else return value */ + return ret; +} + +static inline int l4_fsync(int fd) +{ + write_mr(L4SYS_ARG0, fd); + + /* Call pager with close() request. Check ipc error. */ + if ((fd = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_FSYNC)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, fd); + return fd; + } + /* Check if syscall itself was successful */ + if ((fd = l4_get_retval()) < 0) { + print_err("%s: CLOSE Error: %d.\n", __FUNCTION__, fd); + return fd; + } + return fd; +} + +int fsync(int fd) +{ + int ret = l4_fsync(fd); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + + /* else return value */ + return ret; +} + diff --git a/conts/posix/libposix/env.c b/conts/posix/libposix/env.c new file mode 100644 index 0000000..69aabee --- /dev/null +++ b/conts/posix/libposix/env.c @@ -0,0 +1,35 @@ +/* + * Environment accessor functions + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include + +char **__environ; + +/* + * Search for given name in name=value string pairs located + * in the environment segment, and return the pointer to value + * string. + */ +char *getenv(const char *name) +{ + char **envp = __environ; + int length; + + if (!envp) + return 0; + length = strlen(name); + + while(*envp) { + if (memcmp(name, *envp, length) == 0 && + (*envp)[length] == '=') + return *envp + length + 1; + envp++; + } + + return 0; +} + diff --git a/conts/posix/libposix/errno.c b/conts/posix/libposix/errno.c new file mode 100644 index 0000000..03800ec --- /dev/null +++ b/conts/posix/libposix/errno.c @@ -0,0 +1,15 @@ +#include +#include +#include + +int errno_variable; + +void perror(const char *str) +{ + print_err("%s: %d\n", str, errno); +} + +int *__errno_location(void) +{ + return &errno_variable; +} diff --git a/conts/posix/libposix/execve.c b/conts/posix/libposix/execve.c new file mode 100644 index 0000000..a698c7d --- /dev/null +++ b/conts/posix/libposix/execve.c @@ -0,0 +1,67 @@ +/* + * l4/posix glue for execve() + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) +#include + + +struct sys_execve_args { + char *path; + char **argv; + char **envp; +}; + +static inline int l4_execve(const char *pathname, char *const argv[], char *const envp[]) +{ + int err = 0; + + write_mr(L4SYS_ARG0, (unsigned long)pathname); + write_mr(L4SYS_ARG1, (unsigned long)argv); + write_mr(L4SYS_ARG2, (unsigned long)envp); + + + /* Call pager with open() request. Check ipc error. */ + if ((err = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_EXECVE)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + return err; + } + /* Check if syscall itself was successful */ + if ((err = l4_get_retval()) < 0) { + print_err("%s: OPEN Error: %d.\n", __FUNCTION__, err); + return err; + } + + return err; +} + +int execve(const char *pathname, char *const argv[], char *const envp[]) +{ + int ret; + + ret = l4_execve(pathname, argv, envp); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + /* else return value */ + return ret; + +} + diff --git a/conts/posix/libposix/exit.c b/conts/posix/libposix/exit.c new file mode 100644 index 0000000..5708360 --- /dev/null +++ b/conts/posix/libposix/exit.c @@ -0,0 +1,27 @@ + +#include +#include +#include +#include +#include +#include + +static inline void __attribute__ ((noreturn)) l4_exit(int status) +{ + int ret; + + write_mr(L4SYS_ARG0, status); + + /* Call pager with exit() request and block on its receive phase */ + ret = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_EXIT); + + /* This call should not fail or return */ + print_err("%s: L4 IPC returned: %d.\n", __FUNCTION__, ret); + BUG(); +} + +void __attribute__ ((noreturn)) _exit(int status) +{ + l4_exit(status); +} + diff --git a/conts/posix/libposix/fork.c b/conts/posix/libposix/fork.c new file mode 100644 index 0000000..4072bf8 --- /dev/null +++ b/conts/posix/libposix/fork.c @@ -0,0 +1,90 @@ +/* + * l4/posix glue for fork() + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) +#include +#include + +static inline int l4_fork(void) +{ + int err; + + /* Call pager with open() request. Check ipc error. */ + if ((err = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_FORK)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + return err; + } + /* Check if syscall itself was successful */ + if ((err = l4_get_retval()) < 0) { + print_err("%s: OPEN Error: %d.\n", __FUNCTION__, err); + return err; + } + return err; +} + +int fork(void) +{ + int ret = l4_fork(); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + + /* + * If we're a child, we need to initialise the default + * shared page via libposix_init() + */ + if (ret == 0) + shared_page_init(); + + return ret; +} + +extern int arch_clone(l4id_t to, l4id_t from, unsigned int flags); + +int clone(int (*fn)(void *), void *child_stack, int flags, void *arg, ...) +{ + /* Set up the child stack */ + unsigned int *stack = child_stack; + int ret; + + /* First word of new stack is arg */ + stack[-1] = (unsigned long)arg; + + /* Second word of new stack is function address */ + stack[-2] = (unsigned long)fn; + + /* Write the tag */ + l4_set_tag(L4_IPC_TAG_CLONE); + + /* Write the args as in usual ipc */ + write_mr(L4SYS_ARG0, (unsigned long)child_stack); + write_mr(L4SYS_ARG1, flags); + + /* Perform an ipc but with different return logic. See implementation. */ + if ((ret = arch_clone(PAGER_TID, PAGER_TID, 0)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, ret); + return ret; + } + + if ((ret = l4_get_retval()) < 0) { + print_err("%s: CLONE Error: %d.\n", __FUNCTION__, ret); + return ret; + } + return ret; +} + + + diff --git a/conts/posix/libposix/getpid.c b/conts/posix/libposix/getpid.c new file mode 100644 index 0000000..d4f9287 --- /dev/null +++ b/conts/posix/libposix/getpid.c @@ -0,0 +1,11 @@ + +#include +#include +#include +#include +#include + +pid_t getpid(void) +{ + return self_tid(); +} diff --git a/conts/posix/libposix/include/libposix.h b/conts/posix/libposix/include/libposix.h new file mode 100644 index 0000000..d0f05db --- /dev/null +++ b/conts/posix/libposix/include/libposix.h @@ -0,0 +1,13 @@ +#ifndef __LIBPOSIX_H__ +#define __LIBPOSIX_H__ + +/* Abort debugging conditions */ +// #define LIBPOSIX_ERROR_MESSAGES +#if defined (LIBPOSIX_ERROR_MESSAGES) +#define print_err(...) printf(__VA_ARGS__) +#else +#define print_err(...) +#endif + + +#endif /* __LIBPOSIX_H__ */ diff --git a/conts/posix/libposix/include/posix/_lfs_64.h b/conts/posix/libposix/include/posix/_lfs_64.h new file mode 100644 index 0000000..3e56bbf --- /dev/null +++ b/conts/posix/libposix/include/posix/_lfs_64.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2000-2006 Erik Andersen + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ +#include + +#ifdef __UCLIBC_HAS_LFS__ + +#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS != 64 +#undef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS 64 +#endif + +#ifndef __USE_LARGEFILE64 +# define __USE_LARGEFILE64 1 +#endif + +/* We absolutely do _NOT_ want interfaces silently + * renamed under us or very bad things will happen... */ +#ifdef __USE_FILE_OFFSET64 +# undef __USE_FILE_OFFSET64 +#endif + +#else + +# error Do not include this header in files not built when LFS is disabled + +#endif diff --git a/conts/posix/libposix/include/posix/a.out.h b/conts/posix/libposix/include/posix/a.out.h new file mode 100644 index 0000000..d963de7 --- /dev/null +++ b/conts/posix/libposix/include/posix/a.out.h @@ -0,0 +1,5 @@ +#ifdef _LIBC +# include_next +#else +# include +#endif diff --git a/conts/posix/libposix/include/posix/alloca.h b/conts/posix/libposix/include/posix/alloca.h new file mode 100644 index 0000000..b4fc317 --- /dev/null +++ b/conts/posix/libposix/include/posix/alloca.h @@ -0,0 +1,43 @@ +/* Copyright (C) 1992, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _ALLOCA_H +#define _ALLOCA_H 1 + +#include + +#define __need_size_t +#include + +__BEGIN_DECLS + +/* Remove any previous definitions. */ +#undef alloca + +/* Allocate a block that will be freed when the calling function exits. */ +extern void *alloca (size_t __size) __THROW; + +#ifdef __GNUC__ +# define alloca(size) __builtin_alloca (size) +#endif /* GCC. */ + +#define __MAX_ALLOCA_CUTOFF 65536 + +__END_DECLS + +#endif /* alloca.h */ diff --git a/conts/posix/libposix/include/posix/ar.h b/conts/posix/libposix/include/posix/ar.h new file mode 100644 index 0000000..5d157ec --- /dev/null +++ b/conts/posix/libposix/include/posix/ar.h @@ -0,0 +1,48 @@ +/* Header describing `ar' archive file format. + Copyright (C) 1996 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _AR_H +#define _AR_H 1 + +#include + +/* Archive files start with the ARMAG identifying string. Then follows a + `struct ar_hdr', and as many bytes of member file data as its `ar_size' + member indicates, for each member file. */ + +#define ARMAG "!\n" /* String that begins an archive file. */ +#define SARMAG 8 /* Size of that string. */ + +#define ARFMAG "`\n" /* String in ar_fmag at end of each header. */ + +__BEGIN_DECLS + +struct ar_hdr + { + char ar_name[16]; /* Member file name, sometimes / terminated. */ + char ar_date[12]; /* File date, decimal seconds since Epoch. */ + char ar_uid[6], ar_gid[6]; /* User and group IDs, in ASCII decimal. */ + char ar_mode[8]; /* File mode, in ASCII octal. */ + char ar_size[10]; /* File size, in ASCII decimal. */ + char ar_fmag[2]; /* Always contains ARFMAG. */ + }; + +__END_DECLS + +#endif /* ar.h */ diff --git a/conts/posix/libposix/include/posix/arpa/ftp.h b/conts/posix/libposix/include/posix/arpa/ftp.h new file mode 100644 index 0000000..e5b340d --- /dev/null +++ b/conts/posix/libposix/include/posix/arpa/ftp.h @@ -0,0 +1,105 @@ +/* + * Copyright (c) 1983, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ftp.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _ARPA_FTP_H +#define _ARPA_FTP_H 1 + +/* Definitions for FTP; see RFC-765. */ + +/* + * Reply codes. + */ +#define PRELIM 1 /* positive preliminary */ +#define COMPLETE 2 /* positive completion */ +#define CONTINUE 3 /* positive intermediate */ +#define TRANSIENT 4 /* transient negative completion */ +#define ERROR 5 /* permanent negative completion */ + +/* + * Type codes + */ +#define TYPE_A 1 /* ASCII */ +#define TYPE_E 2 /* EBCDIC */ +#define TYPE_I 3 /* image */ +#define TYPE_L 4 /* local byte size */ + +#ifdef FTP_NAMES +char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" }; +#endif + +/* + * Form codes + */ +#define FORM_N 1 /* non-print */ +#define FORM_T 2 /* telnet format effectors */ +#define FORM_C 3 /* carriage control (ASA) */ +#ifdef FTP_NAMES +char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" }; +#endif + +/* + * Structure codes + */ +#define STRU_F 1 /* file (no record structure) */ +#define STRU_R 2 /* record structure */ +#define STRU_P 3 /* page structure */ +#ifdef FTP_NAMES +char *strunames[] = {"0", "File", "Record", "Page" }; +#endif + +/* + * Mode types + */ +#define MODE_S 1 /* stream */ +#define MODE_B 2 /* block */ +#define MODE_C 3 /* compressed */ +#ifdef FTP_NAMES +char *modenames[] = {"0", "Stream", "Block", "Compressed" }; +#endif + +/* + * Record Tokens + */ +#define REC_ESC '\377' /* Record-mode Escape */ +#define REC_EOR '\001' /* Record-mode End-of-Record */ +#define REC_EOF '\002' /* Record-mode End-of-File */ + +/* + * Block Header + */ +#define BLK_EOR 0x80 /* Block is End-of-Record */ +#define BLK_EOF 0x40 /* Block is End-of-File */ +#define BLK_ERRORS 0x20 /* Block is suspected of containing errors */ +#define BLK_RESTART 0x10 /* Block is Restart Marker */ + +#define BLK_BYTECOUNT 2 /* Bytes in this block */ + +#endif /* arpa/ftp.h */ diff --git a/conts/posix/libposix/include/posix/arpa/inet.h b/conts/posix/libposix/include/posix/arpa/inet.h new file mode 100644 index 0000000..fe3373b --- /dev/null +++ b/conts/posix/libposix/include/posix/arpa/inet.h @@ -0,0 +1,106 @@ +/* Copyright (C) 1997, 1999, 2000, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _ARPA_INET_H +#define _ARPA_INET_H 1 + +#include +#include /* To define `struct in_addr'. */ + +/* Type for length arguments in socket calls. */ +#ifndef __socklen_t_defined +typedef __socklen_t socklen_t; +# define __socklen_t_defined +#endif + +__BEGIN_DECLS + +/* Convert Internet host address from numbers-and-dots notation in CP + into binary data in network byte order. */ +extern in_addr_t inet_addr (__const char *__cp) __THROW; + +/* Return the local host address part of the Internet address in IN. */ +extern in_addr_t inet_lnaof (struct in_addr __in) __THROW; + +/* Make Internet host address in network byte order by combining the + network number NET with the local address HOST. */ +extern struct in_addr inet_makeaddr (in_addr_t __net, in_addr_t __host) + __THROW; + +/* Return network number part of the Internet address IN. */ +extern in_addr_t inet_netof (struct in_addr __in) __THROW; + +/* Extract the network number in network byte order from the address + in numbers-and-dots natation starting at CP. */ +extern in_addr_t inet_network (__const char *__cp) __THROW; + +/* Convert Internet number in IN to ASCII representation. The return value + is a pointer to an internal array containing the string. */ +extern char *inet_ntoa (struct in_addr __in) __THROW; + +/* Convert from presentation format of an Internet number in buffer + starting at CP to the binary network format and store result for + interface type AF in buffer starting at BUF. */ +extern int inet_pton (int __af, __const char *__restrict __cp, + void *__restrict __buf) __THROW; + +/* Convert a Internet address in binary network format for interface + type AF in buffer starting at CP to presentation form and place + result in buffer of length LEN astarting at BUF. */ +extern __const char *inet_ntop (int __af, __const void *__restrict __cp, + char *__restrict __buf, socklen_t __len) + __THROW; + + +/* The following functions are not part of XNS 5.2. */ +#ifdef __USE_MISC +/* Convert Internet host address from numbers-and-dots notation in CP + into binary data and store the result in the structure INP. */ +extern int inet_aton (__const char *__cp, struct in_addr *__inp) __THROW; + +/* Format a network number NET into presentation format and place result + in buffer starting at BUF with length of LEN bytes. */ +extern char *inet_neta (in_addr_t __net, char *__buf, size_t __len) __THROW; + +/* Convert network number for interface type AF in buffer starting at + CP to presentation format. The result will specifiy BITS bits of + the number. */ +extern char *inet_net_ntop (int __af, __const void *__cp, int __bits, + char *__buf, size_t __len) __THROW; + +/* Convert network number for interface type AF from presentation in + buffer starting at CP to network format and store result int + buffer starting at BUF of size LEN. */ +extern int inet_net_pton (int __af, __const char *__cp, + void *__buf, size_t __len) __THROW; + +/* Convert ASCII representation in hexadecimal form of the Internet + address to binary form and place result in buffer of length LEN + starting at BUF. */ +extern unsigned int inet_nsap_addr (__const char *__cp, + unsigned char *__buf, int __len) __THROW; + +/* Convert internet address in binary form in LEN bytes starting at CP + a presentation form and place result in BUF. */ +extern char *inet_nsap_ntoa (int __len, __const unsigned char *__cp, + char *__buf) __THROW; +#endif + +__END_DECLS + +#endif /* arpa/inet.h */ diff --git a/conts/posix/libposix/include/posix/arpa/nameser.h b/conts/posix/libposix/include/posix/arpa/nameser.h new file mode 100644 index 0000000..496c8db --- /dev/null +++ b/conts/posix/libposix/include/posix/arpa/nameser.h @@ -0,0 +1,557 @@ +/* + * Copyright (c) 1983, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Copyright (c) 1996-1999 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + * $BINDId: nameser.h,v 8.37 2000/03/30 21:16:49 vixie Exp $ + */ + +#ifndef _ARPA_NAMESER_H_ +#define _ARPA_NAMESER_H_ + +#define BIND_4_COMPAT + +#include +#if (!defined(BSD)) || (BSD < 199306) +# include +#else +# include +#endif +#include + +/* + * Revision information. This is the release date in YYYYMMDD format. + * It can change every day so the right thing to do with it is use it + * in preprocessor commands such as "#if (__NAMESER > 19931104)". Do not + * compare for equality; rather, use it to determine whether your libbind.a + * contains a new enough lib/nameser/ to support the feature you need. + */ + +#define __NAMESER 19991006 /* New interface version stamp. */ + +/* + * Define constants based on RFC 883, RFC 1034, RFC 1035 + */ +#define NS_PACKETSZ 512 /* maximum packet size */ +#define NS_MAXDNAME 1025 /* maximum domain name */ +#define NS_MAXCDNAME 255 /* maximum compressed domain name */ +#define NS_MAXLABEL 63 /* maximum length of domain label */ +#define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */ +#define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */ +#define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */ +#define NS_INT32SZ 4 /* #/bytes of data in a u_int32_t */ +#define NS_INT16SZ 2 /* #/bytes of data in a u_int16_t */ +#define NS_INT8SZ 1 /* #/bytes of data in a u_int8_t */ +#define NS_INADDRSZ 4 /* IPv4 T_A */ +#define NS_IN6ADDRSZ 16 /* IPv6 T_AAAA */ +#define NS_CMPRSFLGS 0xc0 /* Flag bits indicating name compression. */ +#define NS_DEFAULTPORT 53 /* For both TCP and UDP. */ + +/* + * These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord() + * in synch with it. + */ +typedef enum __ns_sect { + ns_s_qd = 0, /* Query: Question. */ + ns_s_zn = 0, /* Update: Zone. */ + ns_s_an = 1, /* Query: Answer. */ + ns_s_pr = 1, /* Update: Prerequisites. */ + ns_s_ns = 2, /* Query: Name servers. */ + ns_s_ud = 2, /* Update: Update. */ + ns_s_ar = 3, /* Query|Update: Additional records. */ + ns_s_max = 4 +} ns_sect; + +/* + * This is a message handle. It is caller allocated and has no dynamic data. + * This structure is intended to be opaque to all but ns_parse.c, thus the + * leading _'s on the member names. Use the accessor functions, not the _'s. + */ +typedef struct __ns_msg { + const u_char *_msg, *_eom; + u_int16_t _id, _flags, _counts[ns_s_max]; + const u_char *_sections[ns_s_max]; + ns_sect _sect; + int _rrnum; + const u_char *_ptr; +} ns_msg; + +/* Private data structure - do not use from outside library. */ +struct _ns_flagdata { int mask, shift; }; +extern struct _ns_flagdata _ns_flagdata[]; + +/* Accessor macros - this is part of the public interface. */ +#define ns_msg_getflag(handle, flag) ( \ + ((handle)._flags & _ns_flagdata[flag].mask) \ + >> _ns_flagdata[flag].shift \ + ) +#define ns_msg_id(handle) ((handle)._id + 0) +#define ns_msg_base(handle) ((handle)._msg + 0) +#define ns_msg_end(handle) ((handle)._eom + 0) +#define ns_msg_size(handle) ((handle)._eom - (handle)._msg) +#define ns_msg_count(handle, section) ((handle)._counts[section] + 0) + +/* + * This is a parsed record. It is caller allocated and has no dynamic data. + */ +typedef struct __ns_rr { + char name[NS_MAXDNAME]; + u_int16_t type; + u_int16_t rr_class; + u_int32_t ttl; + u_int16_t rdlength; + const u_char * rdata; +} ns_rr; + +/* Accessor macros - this is part of the public interface. */ +#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".") +#define ns_rr_type(rr) ((ns_type)((rr).type + 0)) +#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0)) +#define ns_rr_ttl(rr) ((rr).ttl + 0) +#define ns_rr_rdlen(rr) ((rr).rdlength + 0) +#define ns_rr_rdata(rr) ((rr).rdata + 0) + +/* + * These don't have to be in the same order as in the packet flags word, + * and they can even overlap in some cases, but they will need to be kept + * in synch with ns_parse.c:ns_flagdata[]. + */ +typedef enum __ns_flag { + ns_f_qr, /* Question/Response. */ + ns_f_opcode, /* Operation code. */ + ns_f_aa, /* Authoritative Answer. */ + ns_f_tc, /* Truncation occurred. */ + ns_f_rd, /* Recursion Desired. */ + ns_f_ra, /* Recursion Available. */ + ns_f_z, /* MBZ. */ + ns_f_ad, /* Authentic Data (DNSSEC). */ + ns_f_cd, /* Checking Disabled (DNSSEC). */ + ns_f_rcode, /* Response code. */ + ns_f_max +} ns_flag; + +/* + * Currently defined opcodes. + */ +typedef enum __ns_opcode { + ns_o_query = 0, /* Standard query. */ + ns_o_iquery = 1, /* Inverse query (deprecated/unsupported). */ + ns_o_status = 2, /* Name server status query (unsupported). */ + /* Opcode 3 is undefined/reserved. */ + ns_o_notify = 4, /* Zone change notification. */ + ns_o_update = 5, /* Zone update message. */ + ns_o_max = 6 +} ns_opcode; + +/* + * Currently defined response codes. + */ +typedef enum __ns_rcode { + ns_r_noerror = 0, /* No error occurred. */ + ns_r_formerr = 1, /* Format error. */ + ns_r_servfail = 2, /* Server failure. */ + ns_r_nxdomain = 3, /* Name error. */ + ns_r_notimpl = 4, /* Unimplemented. */ + ns_r_refused = 5, /* Operation refused. */ + /* these are for BIND_UPDATE */ + ns_r_yxdomain = 6, /* Name exists */ + ns_r_yxrrset = 7, /* RRset exists */ + ns_r_nxrrset = 8, /* RRset does not exist */ + ns_r_notauth = 9, /* Not authoritative for zone */ + ns_r_notzone = 10, /* Zone of record different from zone section */ + ns_r_max = 11, + /* The following are TSIG extended errors */ + ns_r_badsig = 16, + ns_r_badkey = 17, + ns_r_badtime = 18 +} ns_rcode; + +/* BIND_UPDATE */ +typedef enum __ns_update_operation { + ns_uop_delete = 0, + ns_uop_add = 1, + ns_uop_max = 2 +} ns_update_operation; + +/* + * This structure is used for TSIG authenticated messages + */ +struct ns_tsig_key { + char name[NS_MAXDNAME], alg[NS_MAXDNAME]; + unsigned char *data; + int len; +}; +typedef struct ns_tsig_key ns_tsig_key; + +/* + * This structure is used for TSIG authenticated TCP messages + */ +struct ns_tcp_tsig_state { + int counter; + struct dst_key *key; + void *ctx; + unsigned char sig[NS_PACKETSZ]; + int siglen; +}; +typedef struct ns_tcp_tsig_state ns_tcp_tsig_state; + +#define NS_TSIG_FUDGE 300 +#define NS_TSIG_TCP_COUNT 100 +#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT" + +#define NS_TSIG_ERROR_NO_TSIG -10 +#define NS_TSIG_ERROR_NO_SPACE -11 +#define NS_TSIG_ERROR_FORMERR -12 + +/* + * Currently defined type values for resources and queries. + */ +typedef enum __ns_type { + ns_t_invalid = 0, /* Cookie. */ + ns_t_a = 1, /* Host address. */ + ns_t_ns = 2, /* Authoritative server. */ + ns_t_md = 3, /* Mail destination. */ + ns_t_mf = 4, /* Mail forwarder. */ + ns_t_cname = 5, /* Canonical name. */ + ns_t_soa = 6, /* Start of authority zone. */ + ns_t_mb = 7, /* Mailbox domain name. */ + ns_t_mg = 8, /* Mail group member. */ + ns_t_mr = 9, /* Mail rename name. */ + ns_t_null = 10, /* Null resource record. */ + ns_t_wks = 11, /* Well known service. */ + ns_t_ptr = 12, /* Domain name pointer. */ + ns_t_hinfo = 13, /* Host information. */ + ns_t_minfo = 14, /* Mailbox information. */ + ns_t_mx = 15, /* Mail routing information. */ + ns_t_txt = 16, /* Text strings. */ + ns_t_rp = 17, /* Responsible person. */ + ns_t_afsdb = 18, /* AFS cell database. */ + ns_t_x25 = 19, /* X_25 calling address. */ + ns_t_isdn = 20, /* ISDN calling address. */ + ns_t_rt = 21, /* Router. */ + ns_t_nsap = 22, /* NSAP address. */ + ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */ + ns_t_sig = 24, /* Security signature. */ + ns_t_key = 25, /* Security key. */ + ns_t_px = 26, /* X.400 mail mapping. */ + ns_t_gpos = 27, /* Geographical position (withdrawn). */ + ns_t_aaaa = 28, /* Ip6 Address. */ + ns_t_loc = 29, /* Location Information. */ + ns_t_nxt = 30, /* Next domain (security). */ + ns_t_eid = 31, /* Endpoint identifier. */ + ns_t_nimloc = 32, /* Nimrod Locator. */ + ns_t_srv = 33, /* Server Selection. */ + ns_t_atma = 34, /* ATM Address */ + ns_t_naptr = 35, /* Naming Authority PoinTeR */ + ns_t_kx = 36, /* Key Exchange */ + ns_t_cert = 37, /* Certification record */ + ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */ + ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */ + ns_t_sink = 40, /* Kitchen sink (experimentatl) */ + ns_t_opt = 41, /* EDNS0 option (meta-RR) */ + ns_t_tsig = 250, /* Transaction signature. */ + ns_t_ixfr = 251, /* Incremental zone transfer. */ + ns_t_axfr = 252, /* Transfer zone of authority. */ + ns_t_mailb = 253, /* Transfer mailbox records. */ + ns_t_maila = 254, /* Transfer mail agent records. */ + ns_t_any = 255, /* Wildcard match. */ + ns_t_zxfr = 256, /* BIND-specific, nonstandard. */ + ns_t_max = 65536 +} ns_type; + +/* Exclusively a QTYPE? (not also an RTYPE) */ +#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \ + (t) == ns_t_mailb || (t) == ns_t_maila) +/* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */ +#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt) +/* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */ +#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t)) +#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr) +#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \ + (t) == ns_t_zxfr) + +/* + * Values for class field + */ +typedef enum __ns_class { + ns_c_invalid = 0, /* Cookie. */ + ns_c_in = 1, /* Internet. */ + ns_c_2 = 2, /* unallocated/unsupported. */ + ns_c_chaos = 3, /* MIT Chaos-net. */ + ns_c_hs = 4, /* MIT Hesiod. */ + /* Query class values which do not appear in resource records */ + ns_c_none = 254, /* for prereq. sections in update requests */ + ns_c_any = 255, /* Wildcard match. */ + ns_c_max = 65536 +} ns_class; + +/* DNSSEC constants. */ + +typedef enum __ns_key_types { + ns_kt_rsa = 1, /* key type RSA/MD5 */ + ns_kt_dh = 2, /* Diffie Hellman */ + ns_kt_dsa = 3, /* Digital Signature Standard (MANDATORY) */ + ns_kt_private = 254 /* Private key type starts with OID */ +} ns_key_types; + +typedef enum __ns_cert_types { + cert_t_pkix = 1, /* PKIX (X.509v3) */ + cert_t_spki = 2, /* SPKI */ + cert_t_pgp = 3, /* PGP */ + cert_t_url = 253, /* URL private type */ + cert_t_oid = 254 /* OID private type */ +} ns_cert_types; + +/* Flags field of the KEY RR rdata. */ +#define NS_KEY_TYPEMASK 0xC000 /* Mask for "type" bits */ +#define NS_KEY_TYPE_AUTH_CONF 0x0000 /* Key usable for both */ +#define NS_KEY_TYPE_CONF_ONLY 0x8000 /* Key usable for confidentiality */ +#define NS_KEY_TYPE_AUTH_ONLY 0x4000 /* Key usable for authentication */ +#define NS_KEY_TYPE_NO_KEY 0xC000 /* No key usable for either; no key */ +/* The type bits can also be interpreted independently, as single bits: */ +#define NS_KEY_NO_AUTH 0x8000 /* Key unusable for authentication */ +#define NS_KEY_NO_CONF 0x4000 /* Key unusable for confidentiality */ +#define NS_KEY_RESERVED2 0x2000 /* Security is *mandatory* if bit=0 */ +#define NS_KEY_EXTENDED_FLAGS 0x1000 /* reserved - must be zero */ +#define NS_KEY_RESERVED4 0x0800 /* reserved - must be zero */ +#define NS_KEY_RESERVED5 0x0400 /* reserved - must be zero */ +#define NS_KEY_NAME_TYPE 0x0300 /* these bits determine the type */ +#define NS_KEY_NAME_USER 0x0000 /* key is assoc. with user */ +#define NS_KEY_NAME_ENTITY 0x0200 /* key is assoc. with entity eg host */ +#define NS_KEY_NAME_ZONE 0x0100 /* key is zone key */ +#define NS_KEY_NAME_RESERVED 0x0300 /* reserved meaning */ +#define NS_KEY_RESERVED8 0x0080 /* reserved - must be zero */ +#define NS_KEY_RESERVED9 0x0040 /* reserved - must be zero */ +#define NS_KEY_RESERVED10 0x0020 /* reserved - must be zero */ +#define NS_KEY_RESERVED11 0x0010 /* reserved - must be zero */ +#define NS_KEY_SIGNATORYMASK 0x000F /* key can sign RR's of same name */ +#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \ + NS_KEY_RESERVED4 | \ + NS_KEY_RESERVED5 | \ + NS_KEY_RESERVED8 | \ + NS_KEY_RESERVED9 | \ + NS_KEY_RESERVED10 | \ + NS_KEY_RESERVED11 ) +#define NS_KEY_RESERVED_BITMASK2 0xFFFF /* no bits defined here */ + +/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */ +#define NS_ALG_MD5RSA 1 /* MD5 with RSA */ +#define NS_ALG_DH 2 /* Diffie Hellman KEY */ +#define NS_ALG_DSA 3 /* DSA KEY */ +#define NS_ALG_DSS NS_ALG_DSA +#define NS_ALG_EXPIRE_ONLY 253 /* No alg, no security */ +#define NS_ALG_PRIVATE_OID 254 /* Key begins with OID giving alg */ + +/* Protocol values */ +/* value 0 is reserved */ +#define NS_KEY_PROT_TLS 1 +#define NS_KEY_PROT_EMAIL 2 +#define NS_KEY_PROT_DNSSEC 3 +#define NS_KEY_PROT_IPSEC 4 +#define NS_KEY_PROT_ANY 255 + +/* Signatures */ +#define NS_MD5RSA_MIN_BITS 512 /* Size of a mod or exp in bits */ +#define NS_MD5RSA_MAX_BITS 2552 + /* Total of binary mod and exp */ +#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3) + /* Max length of text sig block */ +#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4) +#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8) +#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8) + +#define NS_DSA_SIG_SIZE 41 +#define NS_DSA_MIN_SIZE 213 +#define NS_DSA_MAX_BYTES 405 + +/* Offsets into SIG record rdata to find various values */ +#define NS_SIG_TYPE 0 /* Type flags */ +#define NS_SIG_ALG 2 /* Algorithm */ +#define NS_SIG_LABELS 3 /* How many labels in name */ +#define NS_SIG_OTTL 4 /* Original TTL */ +#define NS_SIG_EXPIR 8 /* Expiration time */ +#define NS_SIG_SIGNED 12 /* Signature time */ +#define NS_SIG_FOOT 16 /* Key footprint */ +#define NS_SIG_SIGNER 18 /* Domain name of who signed it */ + +/* How RR types are represented as bit-flags in NXT records */ +#define NS_NXT_BITS 8 +#define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS))) +#define NS_NXT_MAX 127 + +/* + * Inline versions of get/put short/long. Pointer is advanced. + */ +#define NS_GET16(s, cp) do { \ + register u_char *t_cp = (u_char *)(cp); \ + (s) = ((u_int16_t)t_cp[0] << 8) \ + | ((u_int16_t)t_cp[1]) \ + ; \ + (cp) += NS_INT16SZ; \ +} while (0) + +#define NS_GET32(l, cp) do { \ + register u_char *t_cp = (u_char *)(cp); \ + (l) = ((u_int32_t)t_cp[0] << 24) \ + | ((u_int32_t)t_cp[1] << 16) \ + | ((u_int32_t)t_cp[2] << 8) \ + | ((u_int32_t)t_cp[3]) \ + ; \ + (cp) += NS_INT32SZ; \ +} while (0) + +#define NS_PUT16(s, cp) do { \ + register u_int16_t t_s = (u_int16_t)(s); \ + register u_char *t_cp = (u_char *)(cp); \ + *t_cp++ = t_s >> 8; \ + *t_cp = t_s; \ + (cp) += NS_INT16SZ; \ +} while (0) + +#define NS_PUT32(l, cp) do { \ + register u_int32_t t_l = (u_int32_t)(l); \ + register u_char *t_cp = (u_char *)(cp); \ + *t_cp++ = t_l >> 24; \ + *t_cp++ = t_l >> 16; \ + *t_cp++ = t_l >> 8; \ + *t_cp = t_l; \ + (cp) += NS_INT32SZ; \ +} while (0) + +/* + * ANSI C identifier hiding for bind's lib/nameser. + */ +#define ns_get16 __ns_get16 +#define ns_get32 __ns_get32 +#define ns_put16 __ns_put16 +#define ns_put32 __ns_put32 +#define ns_initparse __ns_initparse +#define ns_skiprr __ns_skiprr +#define ns_parserr __ns_parserr +#define ns_sprintrr __ns_sprintrr +#define ns_sprintrrf __ns_sprintrrf +#define ns_format_ttl __ns_format_ttl +#define ns_parse_ttl __ns_parse_ttl +#define ns_datetosecs __ns_datetosecs +#define ns_name_ntol __ns_name_ntol +#define ns_name_ntop __ns_name_ntop +#define ns_name_pton __ns_name_pton +#define ns_name_unpack __ns_name_unpack +#define ns_name_pack __ns_name_pack +#define ns_name_compress __ns_name_compress +#define ns_name_uncompress __ns_name_uncompress +#define ns_name_skip __ns_name_skip +#define ns_name_rollback __ns_name_rollback +#define ns_sign __ns_sign +#define ns_sign_tcp __ns_sign_tcp +#define ns_sign_tcp_init __ns_sign_tcp_init +#define ns_find_tsig __ns_find_tsig +#define ns_verify __ns_verify +#define ns_verify_tcp __ns_verify_tcp +#define ns_verify_tcp_init __ns_verify_tcp_init +#define ns_samedomain __ns_samedomain +#define ns_subdomain __ns_subdomain +#define ns_makecanon __ns_makecanon +#define ns_samename __ns_samename + +__BEGIN_DECLS +u_int ns_get16 (const u_char *) __THROW; +u_long ns_get32 (const u_char *) __THROW; +void ns_put16 (u_int, u_char *) __THROW; +void ns_put32 (u_long, u_char *) __THROW; +int ns_initparse (const u_char *, int, ns_msg *) __THROW; +int ns_skiprr (const u_char *, const u_char *, ns_sect, int) + __THROW; +int ns_parserr (ns_msg *, ns_sect, int, ns_rr *) __THROW; +int ns_sprintrr (const ns_msg *, const ns_rr *, + const char *, const char *, char *, size_t) + __THROW; +int ns_sprintrrf (const u_char *, size_t, const char *, + ns_class, ns_type, u_long, const u_char *, + size_t, const char *, const char *, + char *, size_t) __THROW; +int ns_format_ttl (u_long, char *, size_t) __THROW; +int ns_parse_ttl (const char *, u_long *) __THROW; +u_int32_t ns_datetosecs (const char *cp, int *errp) __THROW; +int ns_name_ntol (const u_char *, u_char *, size_t) __THROW; +int ns_name_ntop (const u_char *, char *, size_t) __THROW; +int ns_name_pton (const char *, u_char *, size_t) __THROW; +int ns_name_unpack (const u_char *, const u_char *, + const u_char *, u_char *, size_t) __THROW; +int ns_name_pack (const u_char *, u_char *, int, + const u_char **, const u_char **) __THROW; +int ns_name_uncompress (const u_char *, const u_char *, + const u_char *, char *, size_t) __THROW; +int ns_name_compress (const char *, u_char *, size_t, + const u_char **, const u_char **) __THROW; +int ns_name_skip (const u_char **, const u_char *) __THROW; +void ns_name_rollback (const u_char *, const u_char **, + const u_char **) __THROW; +int ns_sign (u_char *, int *, int, int, void *, + const u_char *, int, u_char *, int *, time_t) __THROW; +int ns_sign_tcp (u_char *, int *, int, int, + ns_tcp_tsig_state *, int) __THROW; +int ns_sign_tcp_init (void *, const u_char *, int, + ns_tcp_tsig_state *) __THROW; +u_char *ns_find_tsig (u_char *, u_char *) __THROW; +int ns_verify (u_char *, int *, void *, const u_char *, int, + u_char *, int *, time_t *, int) __THROW; +int ns_verify_tcp (u_char *, int *, ns_tcp_tsig_state *, int) + __THROW; +int ns_verify_tcp_init (void *, const u_char *, int, + ns_tcp_tsig_state *) __THROW; +int ns_samedomain (const char *, const char *) __THROW; +int ns_subdomain (const char *, const char *) __THROW; +int ns_makecanon (const char *, char *, size_t) __THROW; +int ns_samename (const char *, const char *) __THROW; +__END_DECLS + +#ifdef BIND_4_COMPAT +#include +#endif + +#endif /* !_ARPA_NAMESER_H_ */ diff --git a/conts/posix/libposix/include/posix/arpa/nameser_compat.h b/conts/posix/libposix/include/posix/arpa/nameser_compat.h new file mode 100644 index 0000000..43bcd3a --- /dev/null +++ b/conts/posix/libposix/include/posix/arpa/nameser_compat.h @@ -0,0 +1,183 @@ +/* Copyright (c) 1983, 1989 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * from nameser.h 8.1 (Berkeley) 6/2/93 + * $BINDId: nameser_compat.h,v 8.11 1999/01/02 08:00:58 vixie Exp $ + */ + +#ifndef _ARPA_NAMESER_COMPAT_ +#define _ARPA_NAMESER_COMPAT_ + +#define __BIND 19950621 /* (DEAD) interface version stamp. */ + +#include + +/* + * Structure for query header. The order of the fields is machine- and + * compiler-dependent, depending on the byte/bit order and the layout + * of bit fields. We use bit fields only in int variables, as this + * is all ANSI requires. This requires a somewhat confusing rearrangement. + */ + +typedef struct { + unsigned id :16; /* query identification number */ +#if BYTE_ORDER == BIG_ENDIAN + /* fields in third byte */ + unsigned qr: 1; /* response flag */ + unsigned opcode: 4; /* purpose of message */ + unsigned aa: 1; /* authoritive answer */ + unsigned tc: 1; /* truncated message */ + unsigned rd: 1; /* recursion desired */ + /* fields in fourth byte */ + unsigned ra: 1; /* recursion available */ + unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned ad: 1; /* authentic data from named */ + unsigned cd: 1; /* checking disabled by resolver */ + unsigned rcode :4; /* response code */ +#endif +#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN + /* fields in third byte */ + unsigned rd :1; /* recursion desired */ + unsigned tc :1; /* truncated message */ + unsigned aa :1; /* authoritive answer */ + unsigned opcode :4; /* purpose of message */ + unsigned qr :1; /* response flag */ + /* fields in fourth byte */ + unsigned rcode :4; /* response code */ + unsigned cd: 1; /* checking disabled by resolver */ + unsigned ad: 1; /* authentic data from named */ + unsigned unused :1; /* unused bits (MBZ as of 4.9.3a3) */ + unsigned ra :1; /* recursion available */ +#endif + /* remaining bytes */ + unsigned qdcount :16; /* number of question entries */ + unsigned ancount :16; /* number of answer entries */ + unsigned nscount :16; /* number of authority entries */ + unsigned arcount :16; /* number of resource entries */ +} HEADER; + +#define PACKETSZ NS_PACKETSZ +#define MAXDNAME NS_MAXDNAME +#define MAXCDNAME NS_MAXCDNAME +#define MAXLABEL NS_MAXLABEL +#define HFIXEDSZ NS_HFIXEDSZ +#define QFIXEDSZ NS_QFIXEDSZ +#define RRFIXEDSZ NS_RRFIXEDSZ +#define INT32SZ NS_INT32SZ +#define INT16SZ NS_INT16SZ +#define INADDRSZ NS_INADDRSZ +#define IN6ADDRSZ NS_IN6ADDRSZ +#define INDIR_MASK NS_CMPRSFLGS +#define NAMESERVER_PORT NS_DEFAULTPORT + +#define S_ZONE ns_s_zn +#define S_PREREQ ns_s_pr +#define S_UPDATE ns_s_ud +#define S_ADDT ns_s_ar + +#define QUERY ns_o_query +#define IQUERY ns_o_iquery +#define STATUS ns_o_status +#define NS_NOTIFY_OP ns_o_notify +#define NS_UPDATE_OP ns_o_update + +#define NOERROR ns_r_noerror +#define FORMERR ns_r_formerr +#define SERVFAIL ns_r_servfail +#define NXDOMAIN ns_r_nxdomain +#define NOTIMP ns_r_notimpl +#define REFUSED ns_r_refused +#define YXDOMAIN ns_r_yxdomain +#define YXRRSET ns_r_yxrrset +#define NXRRSET ns_r_nxrrset +#define NOTAUTH ns_r_notauth +#define NOTZONE ns_r_notzone +/*#define BADSIG ns_r_badsig*/ +/*#define BADKEY ns_r_badkey*/ +/*#define BADTIME ns_r_badtime*/ + + +#define DELETE ns_uop_delete +#define ADD ns_uop_add + +#define T_A ns_t_a +#define T_NS ns_t_ns +#define T_MD ns_t_md +#define T_MF ns_t_mf +#define T_CNAME ns_t_cname +#define T_SOA ns_t_soa +#define T_MB ns_t_mb +#define T_MG ns_t_mg +#define T_MR ns_t_mr +#define T_NULL ns_t_null +#define T_WKS ns_t_wks +#define T_PTR ns_t_ptr +#define T_HINFO ns_t_hinfo +#define T_MINFO ns_t_minfo +#define T_MX ns_t_mx +#define T_TXT ns_t_txt +#define T_RP ns_t_rp +#define T_AFSDB ns_t_afsdb +#define T_X25 ns_t_x25 +#define T_ISDN ns_t_isdn +#define T_RT ns_t_rt +#define T_NSAP ns_t_nsap +#define T_NSAP_PTR ns_t_nsap_ptr +#define T_SIG ns_t_sig +#define T_KEY ns_t_key +#define T_PX ns_t_px +#define T_GPOS ns_t_gpos +#define T_AAAA ns_t_aaaa +#define T_LOC ns_t_loc +#define T_NXT ns_t_nxt +#define T_EID ns_t_eid +#define T_NIMLOC ns_t_nimloc +#define T_SRV ns_t_srv +#define T_ATMA ns_t_atma +#define T_NAPTR ns_t_naptr +#define T_TSIG ns_t_tsig +#define T_IXFR ns_t_ixfr +#define T_AXFR ns_t_axfr +#define T_MAILB ns_t_mailb +#define T_MAILA ns_t_maila +#define T_ANY ns_t_any + +#define C_IN ns_c_in +#define C_CHAOS ns_c_chaos +#define C_HS ns_c_hs +/* BIND_UPDATE */ +#define C_NONE ns_c_none +#define C_ANY ns_c_any + +#define GETSHORT NS_GET16 +#define GETLONG NS_GET32 +#define PUTSHORT NS_PUT16 +#define PUTLONG NS_PUT32 + +#endif /* _ARPA_NAMESER_COMPAT_ */ diff --git a/conts/posix/libposix/include/posix/arpa/telnet.h b/conts/posix/libposix/include/posix/arpa/telnet.h new file mode 100644 index 0000000..3774c89 --- /dev/null +++ b/conts/posix/libposix/include/posix/arpa/telnet.h @@ -0,0 +1,316 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)telnet.h 8.2 (Berkeley) 12/15/93 + */ + +#ifndef _ARPA_TELNET_H +#define _ARPA_TELNET_H 1 + +/* + * Definitions for the TELNET protocol. + */ +#define IAC 255 /* interpret as command: */ +#define DONT 254 /* you are not to use option */ +#define DO 253 /* please, you use option */ +#define WONT 252 /* I won't use option */ +#define WILL 251 /* I will use option */ +#define SB 250 /* interpret as subnegotiation */ +#define GA 249 /* you may reverse the line */ +#define EL 248 /* erase the current line */ +#define EC 247 /* erase the current character */ +#define AYT 246 /* are you there */ +#define AO 245 /* abort output--but let prog finish */ +#define IP 244 /* interrupt process--permanently */ +#define BREAK 243 /* break */ +#define DM 242 /* data mark--for connect. cleaning */ +#define NOP 241 /* nop */ +#define SE 240 /* end sub negotiation */ +#define EOR 239 /* end of record (transparent mode) */ +#define ABORT 238 /* Abort process */ +#define SUSP 237 /* Suspend process */ +#define xEOF 236 /* End of file: EOF is already used... */ + +#define SYNCH 242 /* for telfunc calls */ + +#ifdef TELCMDS +char *telcmds[] = { + "EOF", "SUSP", "ABORT", "EOR", + "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", + "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0, +}; +#else +extern char *telcmds[]; +#endif + +#define TELCMD_FIRST xEOF +#define TELCMD_LAST IAC +#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \ + (unsigned int)(x) >= TELCMD_FIRST) +#define TELCMD(x) telcmds[(x)-TELCMD_FIRST] + +/* telnet options */ +#define TELOPT_BINARY 0 /* 8-bit data path */ +#define TELOPT_ECHO 1 /* echo */ +#define TELOPT_RCP 2 /* prepare to reconnect */ +#define TELOPT_SGA 3 /* suppress go ahead */ +#define TELOPT_NAMS 4 /* approximate message size */ +#define TELOPT_STATUS 5 /* give status */ +#define TELOPT_TM 6 /* timing mark */ +#define TELOPT_RCTE 7 /* remote controlled transmission and echo */ +#define TELOPT_NAOL 8 /* negotiate about output line width */ +#define TELOPT_NAOP 9 /* negotiate about output page size */ +#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */ +#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */ +#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */ +#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */ +#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */ +#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */ +#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */ +#define TELOPT_XASCII 17 /* extended ascii character set */ +#define TELOPT_LOGOUT 18 /* force logout */ +#define TELOPT_BM 19 /* byte macro */ +#define TELOPT_DET 20 /* data entry terminal */ +#define TELOPT_SUPDUP 21 /* supdup protocol */ +#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */ +#define TELOPT_SNDLOC 23 /* send location */ +#define TELOPT_TTYPE 24 /* terminal type */ +#define TELOPT_EOR 25 /* end or record */ +#define TELOPT_TUID 26 /* TACACS user identification */ +#define TELOPT_OUTMRK 27 /* output marking */ +#define TELOPT_TTYLOC 28 /* terminal location number */ +#define TELOPT_3270REGIME 29 /* 3270 regime */ +#define TELOPT_X3PAD 30 /* X.3 PAD */ +#define TELOPT_NAWS 31 /* window size */ +#define TELOPT_TSPEED 32 /* terminal speed */ +#define TELOPT_LFLOW 33 /* remote flow control */ +#define TELOPT_LINEMODE 34 /* Linemode option */ +#define TELOPT_XDISPLOC 35 /* X Display Location */ +#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */ +#define TELOPT_AUTHENTICATION 37/* Authenticate */ +#define TELOPT_ENCRYPT 38 /* Encryption option */ +#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */ +#define TELOPT_EXOPL 255 /* extended-options-list */ + + +#define NTELOPTS (1+TELOPT_NEW_ENVIRON) +#ifdef TELOPTS +char *telopts[NTELOPTS+1] = { + "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME", + "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP", + "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS", + "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO", + "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT", + "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD", + "TACACS UID", "OUTPUT MARKING", "TTYLOC", + "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", + "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", + "ENCRYPT", "NEW-ENVIRON", + 0, +}; +#define TELOPT_FIRST TELOPT_BINARY +#define TELOPT_LAST TELOPT_NEW_ENVIRON +#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST) +#define TELOPT(x) telopts[(x)-TELOPT_FIRST] +#endif + +/* sub-option qualifiers */ +#define TELQUAL_IS 0 /* option is... */ +#define TELQUAL_SEND 1 /* send option */ +#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */ +#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */ +#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */ + +#define LFLOW_OFF 0 /* Disable remote flow control */ +#define LFLOW_ON 1 /* Enable remote flow control */ +#define LFLOW_RESTART_ANY 2 /* Restart output on any char */ +#define LFLOW_RESTART_XON 3 /* Restart output only on XON */ + +/* + * LINEMODE suboptions + */ + +#define LM_MODE 1 +#define LM_FORWARDMASK 2 +#define LM_SLC 3 + +#define MODE_EDIT 0x01 +#define MODE_TRAPSIG 0x02 +#define MODE_ACK 0x04 +#define MODE_SOFT_TAB 0x08 +#define MODE_LIT_ECHO 0x10 + +#define MODE_MASK 0x1f + +/* Not part of protocol, but needed to simplify things... */ +#define MODE_FLOW 0x0100 +#define MODE_ECHO 0x0200 +#define MODE_INBIN 0x0400 +#define MODE_OUTBIN 0x0800 +#define MODE_FORCE 0x1000 + +#define SLC_SYNCH 1 +#define SLC_BRK 2 +#define SLC_IP 3 +#define SLC_AO 4 +#define SLC_AYT 5 +#define SLC_EOR 6 +#define SLC_ABORT 7 +#define SLC_EOF 8 +#define SLC_SUSP 9 +#define SLC_EC 10 +#define SLC_EL 11 +#define SLC_EW 12 +#define SLC_RP 13 +#define SLC_LNEXT 14 +#define SLC_XON 15 +#define SLC_XOFF 16 +#define SLC_FORW1 17 +#define SLC_FORW2 18 + +#define NSLC 18 + +/* + * For backwards compatibility, we define SLC_NAMES to be the + * list of names if SLC_NAMES is not defined. + */ +#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ + "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ + "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0, +#ifdef SLC_NAMES +char *slc_names[] = { + SLC_NAMELIST +}; +#else +extern char *slc_names[]; +#define SLC_NAMES SLC_NAMELIST +#endif + +#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC) +#define SLC_NAME(x) slc_names[x] + +#define SLC_NOSUPPORT 0 +#define SLC_CANTCHANGE 1 +#define SLC_VARIABLE 2 +#define SLC_DEFAULT 3 +#define SLC_LEVELBITS 0x03 + +#define SLC_FUNC 0 +#define SLC_FLAGS 1 +#define SLC_VALUE 2 + +#define SLC_ACK 0x80 +#define SLC_FLUSHIN 0x40 +#define SLC_FLUSHOUT 0x20 + +#define OLD_ENV_VAR 1 +#define OLD_ENV_VALUE 0 +#define NEW_ENV_VAR 0 +#define NEW_ENV_VALUE 1 +#define ENV_ESC 2 +#define ENV_USERVAR 3 + +/* + * AUTHENTICATION suboptions + */ + +/* + * Who is authenticating who ... + */ +#define AUTH_WHO_CLIENT 0 /* Client authenticating server */ +#define AUTH_WHO_SERVER 1 /* Server authenticating client */ +#define AUTH_WHO_MASK 1 + +/* + * amount of authentication done + */ +#define AUTH_HOW_ONE_WAY 0 +#define AUTH_HOW_MUTUAL 2 +#define AUTH_HOW_MASK 2 + +#define AUTHTYPE_NULL 0 +#define AUTHTYPE_KERBEROS_V4 1 +#define AUTHTYPE_KERBEROS_V5 2 +#define AUTHTYPE_SPX 3 +#define AUTHTYPE_MINK 4 +#define AUTHTYPE_CNT 5 + +#define AUTHTYPE_TEST 99 + +#ifdef AUTH_NAMES +char *authtype_names[] = { + "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0, +}; +#else +extern char *authtype_names[]; +#endif + +#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT) +#define AUTHTYPE_NAME(x) authtype_names[x] + +/* + * ENCRYPTion suboptions + */ +#define ENCRYPT_IS 0 /* I pick encryption type ... */ +#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */ +#define ENCRYPT_REPLY 2 /* Initial setup response */ +#define ENCRYPT_START 3 /* Am starting to send encrypted */ +#define ENCRYPT_END 4 /* Am ending encrypted */ +#define ENCRYPT_REQSTART 5 /* Request you start encrypting */ +#define ENCRYPT_REQEND 6 /* Request you send encrypting */ +#define ENCRYPT_ENC_KEYID 7 +#define ENCRYPT_DEC_KEYID 8 +#define ENCRYPT_CNT 9 + +#define ENCTYPE_ANY 0 +#define ENCTYPE_DES_CFB64 1 +#define ENCTYPE_DES_OFB64 2 +#define ENCTYPE_CNT 3 + +#ifdef ENCRYPT_NAMES +char *encrypt_names[] = { + "IS", "SUPPORT", "REPLY", "START", "END", + "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID", + 0, +}; +char *enctype_names[] = { + "ANY", "DES_CFB64", "DES_OFB64", 0, +}; +#else +extern char *encrypt_names[]; +extern char *enctype_names[]; +#endif + + +#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT) +#define ENCRYPT_NAME(x) encrypt_names[x] + +#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT) +#define ENCTYPE_NAME(x) enctype_names[x] + +#endif /* arpa/telnet.h */ diff --git a/conts/posix/libposix/include/posix/arpa/tftp.h b/conts/posix/libposix/include/posix/arpa/tftp.h new file mode 100644 index 0000000..21b0559 --- /dev/null +++ b/conts/posix/libposix/include/posix/arpa/tftp.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)tftp.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _ARPA_TFTP_H +#define _ARPA_TFTP_H 1 + +/* + * Trivial File Transfer Protocol (IEN-133) + */ +#define SEGSIZE 512 /* data segment size */ + +/* + * Packet types. + */ +#define RRQ 01 /* read request */ +#define WRQ 02 /* write request */ +#define DATA 03 /* data packet */ +#define ACK 04 /* acknowledgement */ +#define ERROR 05 /* error code */ + +struct tftphdr { + short th_opcode; /* packet type */ + union { + unsigned short tu_block; /* block # */ + short tu_code; /* error code */ + char tu_stuff[1]; /* request packet stuff */ + } __attribute__ ((__packed__)) th_u; + char th_data[1]; /* data or error string */ +} __attribute__ ((__packed__)); + +#define th_block th_u.tu_block +#define th_code th_u.tu_code +#define th_stuff th_u.tu_stuff +#define th_msg th_data + +/* + * Error codes. + */ +#define EUNDEF 0 /* not defined */ +#define ENOTFOUND 1 /* file not found */ +#define EACCESS 2 /* access violation */ +#define ENOSPACE 3 /* disk full or allocation exceeded */ +#define EBADOP 4 /* illegal TFTP operation */ +#define EBADID 5 /* unknown transfer ID */ +#define EEXISTS 6 /* file already exists */ +#define ENOUSER 7 /* no such user */ + +#endif /* arpa/tftp.h */ diff --git a/conts/posix/libposix/include/posix/assert.h b/conts/posix/libposix/include/posix/assert.h new file mode 100644 index 0000000..a67dd43 --- /dev/null +++ b/conts/posix/libposix/include/posix/assert.h @@ -0,0 +1,82 @@ +/* Copyright (C) 1991,1992,1994-2001,2003,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard: 7.2 Diagnostics + */ + +#ifdef _ASSERT_H + +# undef _ASSERT_H +# undef assert +# undef __ASSERT_VOID_CAST + +#endif /* assert.h */ + +#define _ASSERT_H 1 +#include + +#if defined __cplusplus && __GNUC_PREREQ(2,95) +# define __ASSERT_VOID_CAST static_cast +#else +# define __ASSERT_VOID_CAST (void) +#endif + +/* void assert (int expression); + + If NDEBUG is defined, do nothing. + If not, and EXPRESSION is zero, print an error message and abort. */ + +#ifdef NDEBUG + +# define assert(expr) (__ASSERT_VOID_CAST (0)) + +#else /* Not NDEBUG. */ + +__BEGIN_DECLS + +/* This prints an "Assertion failed" message and aborts. */ +extern void __assert __P((const char *, const char *, int, const char *)); + +__END_DECLS + +# define assert(expr) \ + (__ASSERT_VOID_CAST ((expr) ? 0 : \ + (__assert (__STRING(expr), __FILE__, __LINE__, \ + __ASSERT_FUNCTION), 0))) + +/* Define some temporaries to workaround tinyx makedepend bug */ +#define __GNUC_PREREQ_2_6 __GNUC_PREREQ(2, 6) +#define __GNUC_PREREQ_2_4 __GNUC_PREREQ(2, 4) +/* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__' + which contains the name of the function currently being defined. + This is broken in G++ before version 2.6. + C9x has a similar variable called __func__, but prefer the GCC one since + it demangles C++ function names. */ + +# if defined __cplusplus ? __GNUC_PREREQ_2_6 : __GNUC_PREREQ_2_4 +# define __ASSERT_FUNCTION __PRETTY_FUNCTION__ +# else +# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +# define __ASSERT_FUNCTION __func__ +# else +# define __ASSERT_FUNCTION ((__const char *) 0) +# endif +# endif + +#endif /* NDEBUG. */ diff --git a/conts/posix/libposix/include/posix/atomic.h b/conts/posix/libposix/include/posix/atomic.h new file mode 100644 index 0000000..8a23f6e --- /dev/null +++ b/conts/posix/libposix/include/posix/atomic.h @@ -0,0 +1,261 @@ +/* Internal macros for atomic operations for GNU C Library. + Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2002. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _ATOMIC_H +#define _ATOMIC_H 1 + +#include + +#include + +/* Wrapper macros to call pre_NN_post (mem, ...) where NN is the + bit width of *MEM. The calling macro puts parens around MEM + and following args. */ +#define __atomic_val_bysize(pre, post, mem, ...) \ + ({ \ + __typeof (*mem) __result; \ + if (sizeof (*mem) == 1) \ + __result = pre##_8_##post (mem, __VA_ARGS__); \ + else if (sizeof (*mem) == 2) \ + __result = pre##_16_##post (mem, __VA_ARGS__); \ + else if (sizeof (*mem) == 4) \ + __result = pre##_32_##post (mem, __VA_ARGS__); \ + else if (sizeof (*mem) == 8) \ + __result = pre##_64_##post (mem, __VA_ARGS__); \ + else \ + abort (); \ + __result; \ + }) +#define __atomic_bool_bysize(pre, post, mem, ...) \ + ({ \ + int __result; \ + if (sizeof (*mem) == 1) \ + __result = pre##_8_##post (mem, __VA_ARGS__); \ + else if (sizeof (*mem) == 2) \ + __result = pre##_16_##post (mem, __VA_ARGS__); \ + else if (sizeof (*mem) == 4) \ + __result = pre##_32_##post (mem, __VA_ARGS__); \ + else if (sizeof (*mem) == 8) \ + __result = pre##_64_##post (mem, __VA_ARGS__); \ + else \ + abort (); \ + __result; \ + }) + + +/* Atomically store NEWVAL in *MEM if *MEM is equal to OLDVAL. + Return the old *MEM value. */ +#if !defined atomic_compare_and_exchange_val_acq \ + && defined __arch_compare_and_exchange_val_32_acq +# define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \ + __atomic_val_bysize (__arch_compare_and_exchange_val,acq, \ + mem, newval, oldval) +#endif + + +#ifndef atomic_compare_and_exchange_val_rel +# define atomic_compare_and_exchange_val_rel(mem, newval, oldval) \ + atomic_compare_and_exchange_val_acq (mem, newval, oldval) +#endif + + +/* Atomically store NEWVAL in *MEM if *MEM is equal to OLDVAL. + Return zero if *MEM was changed or non-zero if no exchange happened. */ +#ifndef atomic_compare_and_exchange_bool_acq +# ifdef __arch_compare_and_exchange_bool_32_acq +# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ + __atomic_bool_bysize (__arch_compare_and_exchange_bool,acq, \ + mem, newval, oldval) +# else +# define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ + ({ /* Cannot use __oldval here, because macros later in this file might \ + call this macro with __oldval argument. */ \ + __typeof (oldval) __old = (oldval); \ + atomic_compare_and_exchange_val_acq (mem, newval, __old) != __old; \ + }) +# endif +#endif + + +#ifndef atomic_compare_and_exchange_bool_rel +# define atomic_compare_and_exchange_bool_rel(mem, newval, oldval) \ + atomic_compare_and_exchange_bool_acq (mem, newval, oldval) +#endif + + +/* Store NEWVALUE in *MEM and return the old value. */ +#ifndef atomic_exchange_acq +# define atomic_exchange_acq(mem, newvalue) \ + ({ __typeof (*(mem)) __oldval; \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __value = (newvalue); \ + \ + do \ + __oldval = (*__memp); \ + while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \ + __value, \ + __oldval),\ + 0)); \ + \ + __oldval; }) +#endif + +#ifndef atomic_exchange_rel +# define atomic_exchange_rel(mem, newvalue) atomic_exchange_acq (mem, newvalue) +#endif + + +/* Add VALUE to *MEM and return the old value of *MEM. */ +#ifndef atomic_exchange_and_add +# define atomic_exchange_and_add(mem, value) \ + ({ __typeof (*(mem)) __oldval; \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __value = (value); \ + \ + do \ + __oldval = (*__memp); \ + while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \ + __oldval \ + + __value,\ + __oldval),\ + 0)); \ + \ + __oldval; }) +#endif + + +#ifndef atomic_add +# define atomic_add(mem, value) (void) atomic_exchange_and_add ((mem), (value)) +#endif + + +#ifndef atomic_increment +# define atomic_increment(mem) atomic_add ((mem), 1) +#endif + + +#ifndef atomic_increment_val +# define atomic_increment_val(mem) (atomic_exchange_and_add ((mem), 1) + 1) +#endif + + +/* Add one to *MEM and return true iff it's now zero. */ +#ifndef atomic_increment_and_test +# define atomic_increment_and_test(mem) \ + (atomic_exchange_and_add ((mem), 1) + 1 == 0) +#endif + + +#ifndef atomic_decrement +# define atomic_decrement(mem) atomic_add ((mem), -1) +#endif + + +#ifndef atomic_decrement_val +# define atomic_decrement_val(mem) (atomic_exchange_and_add ((mem), -1) - 1) +#endif + + +/* Subtract 1 from *MEM and return true iff it's now zero. */ +#ifndef atomic_decrement_and_test +# define atomic_decrement_and_test(mem) \ + (atomic_exchange_and_add ((mem), -1) == 1) +#endif + + +/* Decrement *MEM if it is > 0, and return the old value. */ +#ifndef atomic_decrement_if_positive +# define atomic_decrement_if_positive(mem) \ + ({ __typeof (*(mem)) __oldval; \ + __typeof (mem) __memp = (mem); \ + \ + do \ + { \ + __oldval = *__memp; \ + if (__builtin_expect (__oldval <= 0, 0)) \ + break; \ + } \ + while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \ + __oldval \ + - 1, \ + __oldval),\ + 0));\ + __oldval; }) +#endif + + +#ifndef atomic_add_negative +# define atomic_add_negative(mem, value) \ + ({ __typeof (value) __aan_value = (value); \ + atomic_exchange_and_add (mem, __aan_value) < -__aan_value; }) +#endif + + +#ifndef atomic_add_zero +# define atomic_add_zero(mem, value) \ + ({ __typeof (value) __aaz_value = (value); \ + atomic_exchange_and_add (mem, __aaz_value) == -__aaz_value; }) +#endif + + +#ifndef atomic_bit_set +# define atomic_bit_set(mem, bit) \ + (void) atomic_bit_test_set(mem, bit) +#endif + + +#ifndef atomic_bit_test_set +# define atomic_bit_test_set(mem, bit) \ + ({ __typeof (*(mem)) __oldval; \ + __typeof (mem) __memp = (mem); \ + __typeof (*(mem)) __mask = ((__typeof (*(mem))) 1 << (bit)); \ + \ + do \ + __oldval = (*__memp); \ + while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp, \ + __oldval \ + | __mask, \ + __oldval),\ + 0)); \ + \ + __oldval & __mask; }) +#endif + + +#ifndef atomic_full_barrier +# define atomic_full_barrier() __asm ("" ::: "memory") +#endif + + +#ifndef atomic_read_barrier +# define atomic_read_barrier() atomic_full_barrier () +#endif + + +#ifndef atomic_write_barrier +# define atomic_write_barrier() atomic_full_barrier () +#endif + + +#ifndef atomic_delay +# define atomic_delay() do { /* nothing */ } while (0) +#endif + +#endif /* atomic.h */ diff --git a/conts/posix/libposix/include/posix/bits/armsigctx.h b/conts/posix/libposix/include/posix/bits/armsigctx.h new file mode 100644 index 0000000..4530cdb --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/armsigctx.h @@ -0,0 +1,73 @@ +/* Definition of `struct sigcontext' for Linux/ARM + Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* The format of struct sigcontext changed between 2.0 and 2.1 kernels. + Fortunately 2.0 puts a magic number in the first word and this is not + a legal value for `trap_no', so we can tell them apart. */ + +/* Early 2.2 and 2.3 kernels do not have the `fault_address' member in + the sigcontext structure. Unfortunately there is no reliable way + to test for its presence and this word will contain garbage for too-old + kernels. Versions 2.2.14 and 2.3.35 (plus later versions) are known to + include this element. */ + +#ifndef __ARMSIGCTX_H +#define __ARMSIGCTX_H 1 + +#include + +union k_sigcontext + { + struct + { + unsigned long int trap_no; + unsigned long int error_code; + unsigned long int oldmask; + unsigned long int arm_r0; + unsigned long int arm_r1; + unsigned long int arm_r2; + unsigned long int arm_r3; + unsigned long int arm_r4; + unsigned long int arm_r5; + unsigned long int arm_r6; + unsigned long int arm_r7; + unsigned long int arm_r8; + unsigned long int arm_r9; + unsigned long int arm_r10; + unsigned long int arm_fp; + unsigned long int arm_ip; + unsigned long int arm_sp; + unsigned long int arm_lr; + unsigned long int arm_pc; + unsigned long int arm_cpsr; + unsigned long fault_address; + } v21; + struct + { + unsigned long int magic; + struct pt_regs reg; + unsigned long int trap_no; + unsigned long int error_code; + unsigned long int oldmask; + } v20; +}; + +#define SIGCONTEXT_2_0_MAGIC 0x4B534154 + +#endif /* bits/armsigctx.h */ diff --git a/conts/posix/libposix/include/posix/bits/atomic.h b/conts/posix/libposix/include/posix/bits/atomic.h new file mode 100644 index 0000000..6245130 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/atomic.h @@ -0,0 +1,43 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2003. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _BITS_ATOMIC_H +#define _BITS_ATOMIC_H 1 + +/* We have by default no support for atomic operations. So define + them non-atomic. If this is a problem somebody will have to come + up with real definitions. */ + +/* The only basic operation needed is compare and exchange. */ +#define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \ + ({ __typeof (mem) __gmemp = (mem); \ + __typeof (*mem) __gret = *__gmemp; \ + __typeof (*mem) __gnewval = (newval); \ + \ + if (__gret == (oldval)) \ + *__gmemp = __gnewval; \ + __gret; }) + +#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \ + ({ __typeof (mem) __gmemp = (mem); \ + __typeof (*mem) __gnewval = (newval); \ + \ + *__gmemp == (oldval) ? (*__gmemp = __gnewval, 0) : 1; }) + +#endif /* bits/atomic.h */ diff --git a/conts/posix/libposix/include/posix/bits/byteswap.h b/conts/posix/libposix/include/posix/bits/byteswap.h new file mode 100644 index 0000000..949ed0b --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/byteswap.h @@ -0,0 +1,87 @@ +/* Macros to swap the order of bytes in integer values. + Copyright (C) 1997,1998,2000,2001,2002,2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#if !defined _BYTESWAP_H && !defined _NETINET_IN_H +# error "Never use directly; include instead." +#endif + +#ifndef _BITS_BYTESWAP_H +#define _BITS_BYTESWAP_H 1 + +/* Swap bytes in 16 bit value. */ +#define __bswap_constant_16(x) \ + ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)) + +#ifdef __GNUC__ +# define __bswap_16(x) \ + (__extension__ \ + ({ unsigned short int __bsx = (x); __bswap_constant_16 (__bsx); })) +#else +static __inline unsigned short int +__bswap_16 (unsigned short int __bsx) +{ + return __bswap_constant_16 (__bsx); +} +#endif + +/* Swap bytes in 32 bit value. */ +#define __bswap_constant_32(x) \ + ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \ + (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24)) + +#ifdef __GNUC__ +# define __bswap_32(x) \ + (__extension__ \ + ({ register unsigned int __bsx = (x); __bswap_constant_32 (__bsx); })) +#else +static __inline unsigned int +__bswap_32 (unsigned int __bsx) +{ + return __bswap_constant_32 (__bsx); +} +#endif + +#if defined __GNUC__ && __GNUC__ >= 2 +/* Swap bytes in 64 bit value. */ +# define __bswap_constant_64(x) \ + ((((x) & 0xff00000000000000ull) >> 56) \ + | (((x) & 0x00ff000000000000ull) >> 40) \ + | (((x) & 0x0000ff0000000000ull) >> 24) \ + | (((x) & 0x000000ff00000000ull) >> 8) \ + | (((x) & 0x00000000ff000000ull) << 8) \ + | (((x) & 0x0000000000ff0000ull) << 24) \ + | (((x) & 0x000000000000ff00ull) << 40) \ + | (((x) & 0x00000000000000ffull) << 56)) + +# define __bswap_64(x) \ + (__extension__ \ + ({ union { __extension__ unsigned long long int __ll; \ + unsigned int __l[2]; } __w, __r; \ + if (__builtin_constant_p (x)) \ + __r.__ll = __bswap_constant_64 (x); \ + else \ + { \ + __w.__ll = (x); \ + __r.__l[0] = __bswap_32 (__w.__l[1]); \ + __r.__l[1] = __bswap_32 (__w.__l[0]); \ + } \ + __r.__ll; })) +#endif + +#endif /* _BITS_BYTESWAP_H */ diff --git a/conts/posix/libposix/include/posix/bits/cmathcalls.h b/conts/posix/libposix/include/posix/bits/cmathcalls.h new file mode 100644 index 0000000..c680c6d --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/cmathcalls.h @@ -0,0 +1,158 @@ +/* Prototype declarations for complex math functions; + helper file for . + Copyright (C) 1997, 1998, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* NOTE: Because of the special way this file is used by , this + file must NOT be protected from multiple inclusion as header files + usually are. + + This file provides prototype declarations for the math functions. + Most functions are declared using the macro: + + __MATHCALL (NAME, (ARGS...)); + + This means there is a function `NAME' returning `double' and a function + `NAMEf' returning `float'. Each place `_Mdouble_' appears in the + prototype, that is actually `double' in the prototype for `NAME' and + `float' in the prototype for `NAMEf'. Reentrant variant functions are + called `NAME_r' and `NAMEf_r'. + + Functions returning other types like `int' are declared using the macro: + + __MATHDECL (TYPE, NAME, (ARGS...)); + + This is just like __MATHCALL but for a function returning `TYPE' + instead of `_Mdouble_'. In all of these cases, there is still + both a `NAME' and a `NAMEf' that takes `float' arguments. */ + +#ifndef _COMPLEX_H +#error "Never use directly; include instead." +#endif + +#define _Mdouble_complex_ _Mdouble_ _Complex + + +/* Trigonometric functions. */ + +/* Arc cosine of Z. */ +__MATHCALL (cacos, (_Mdouble_complex_ __z)); +/* Arc sine of Z. */ +__MATHCALL (casin, (_Mdouble_complex_ __z)); +/* Arc tangent of Z. */ +__MATHCALL (catan, (_Mdouble_complex_ __z)); + +/* Cosine of Z. */ +__MATHCALL (ccos, (_Mdouble_complex_ __z)); +/* Sine of Z. */ +__MATHCALL (csin, (_Mdouble_complex_ __z)); +/* Tangent of Z. */ +__MATHCALL (ctan, (_Mdouble_complex_ __z)); + + +/* Hyperbolic functions. */ + +/* Hyperbolic arc cosine of Z. */ +__MATHCALL (cacosh, (_Mdouble_complex_ __z)); +/* Hyperbolic arc sine of Z. */ +__MATHCALL (casinh, (_Mdouble_complex_ __z)); +/* Hyperbolic arc tangent of Z. */ +__MATHCALL (catanh, (_Mdouble_complex_ __z)); + +/* Hyperbolic cosine of Z. */ +__MATHCALL (ccosh, (_Mdouble_complex_ __z)); +/* Hyperbolic sine of Z. */ +__MATHCALL (csinh, (_Mdouble_complex_ __z)); +/* Hyperbolic tangent of Z. */ +__MATHCALL (ctanh, (_Mdouble_complex_ __z)); + + +/* Exponential and logarithmic functions. */ + +/* Exponential function of Z. */ +__MATHCALL (cexp, (_Mdouble_complex_ __z)); + +/* Natural logarithm of Z. */ +__MATHCALL (clog, (_Mdouble_complex_ __z)); + +#ifdef __USE_GNU +/* The base 10 logarithm is not defined by the standard but to implement + the standard C++ library it is handy. */ +__MATHCALL (clog10, (_Mdouble_complex_ __z)); +#endif + +/* Power functions. */ + +/* Return X to the Y power. */ +__MATHCALL (cpow, (_Mdouble_complex_ __x, _Mdouble_complex_ __y)); + +/* Return the square root of Z. */ +__MATHCALL (csqrt, (_Mdouble_complex_ __z)); + + +/* Absolute value, conjugates, and projection. */ + +/* Absolute value of Z. */ +__MATHDECL (_Mdouble_,cabs, (_Mdouble_complex_ __z)); + +/* Argument value of Z. */ +__MATHDECL (_Mdouble_,carg, (_Mdouble_complex_ __z)); + +/* Complex conjugate of Z. */ +__MATHCALL (conj, (_Mdouble_complex_ __z)); + +/* Projection of Z onto the Riemann sphere. */ +__MATHCALL (cproj, (_Mdouble_complex_ __z)); + + +/* Decomposing complex values. */ + +/* Imaginary part of Z. */ +__MATHDECL (_Mdouble_,cimag, (_Mdouble_complex_ __z)); + +/* Real part of Z. */ +__MATHDECL (_Mdouble_,creal, (_Mdouble_complex_ __z)); + + +/* Now some optimized versions. GCC has handy notations for these + functions. Recent GCC handles these as builtin functions so does + not need inlines. */ +#if defined __GNUC__ && !__GNUC_PREREQ (2, 97) && defined __OPTIMIZE__ + +/* Imaginary part of Z. */ +extern __inline _Mdouble_ +__MATH_PRECNAME(cimag) (_Mdouble_complex_ __z) __THROW +{ + return __imag__ __z; +} + +/* Real part of Z. */ +extern __inline _Mdouble_ +__MATH_PRECNAME(creal) (_Mdouble_complex_ __z) __THROW +{ + return __real__ __z; +} + +/* Complex conjugate of Z. */ +extern __inline _Mdouble_complex_ +__MATH_PRECNAME(conj) (_Mdouble_complex_ __z) __THROW +{ + return __extension__ ~__z; +} + +#endif diff --git a/conts/posix/libposix/include/posix/bits/confname.h b/conts/posix/libposix/include/posix/bits/confname.h new file mode 100644 index 0000000..ab7fdee --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/confname.h @@ -0,0 +1,606 @@ +/* `sysconf', `pathconf', and `confstr' NAME values. Generic version. + Copyright (C) 1993,1995-1998,2000,2001,2003,2004 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _UNISTD_H +# error "Never use directly; include instead." +#endif + +/* Values for the NAME argument to `pathconf' and `fpathconf'. */ +enum + { + _PC_LINK_MAX, +#define _PC_LINK_MAX _PC_LINK_MAX + _PC_MAX_CANON, +#define _PC_MAX_CANON _PC_MAX_CANON + _PC_MAX_INPUT, +#define _PC_MAX_INPUT _PC_MAX_INPUT + _PC_NAME_MAX, +#define _PC_NAME_MAX _PC_NAME_MAX + _PC_PATH_MAX, +#define _PC_PATH_MAX _PC_PATH_MAX + _PC_PIPE_BUF, +#define _PC_PIPE_BUF _PC_PIPE_BUF + _PC_CHOWN_RESTRICTED, +#define _PC_CHOWN_RESTRICTED _PC_CHOWN_RESTRICTED + _PC_NO_TRUNC, +#define _PC_NO_TRUNC _PC_NO_TRUNC + _PC_VDISABLE, +#define _PC_VDISABLE _PC_VDISABLE + _PC_SYNC_IO, +#define _PC_SYNC_IO _PC_SYNC_IO + _PC_ASYNC_IO, +#define _PC_ASYNC_IO _PC_ASYNC_IO + _PC_PRIO_IO, +#define _PC_PRIO_IO _PC_PRIO_IO + _PC_SOCK_MAXBUF, +#define _PC_SOCK_MAXBUF _PC_SOCK_MAXBUF + _PC_FILESIZEBITS, +#define _PC_FILESIZEBITS _PC_FILESIZEBITS + _PC_REC_INCR_XFER_SIZE, +#define _PC_REC_INCR_XFER_SIZE _PC_REC_INCR_XFER_SIZE + _PC_REC_MAX_XFER_SIZE, +#define _PC_REC_MAX_XFER_SIZE _PC_REC_MAX_XFER_SIZE + _PC_REC_MIN_XFER_SIZE, +#define _PC_REC_MIN_XFER_SIZE _PC_REC_MIN_XFER_SIZE + _PC_REC_XFER_ALIGN, +#define _PC_REC_XFER_ALIGN _PC_REC_XFER_ALIGN + _PC_ALLOC_SIZE_MIN, +#define _PC_ALLOC_SIZE_MIN _PC_ALLOC_SIZE_MIN + _PC_SYMLINK_MAX, +#define _PC_SYMLINK_MAX _PC_SYMLINK_MAX + _PC_2_SYMLINKS +#define _PC_2_SYMLINKS _PC_2_SYMLINKS + }; + +/* Values for the argument to `sysconf'. */ +enum + { + _SC_ARG_MAX, +#define _SC_ARG_MAX _SC_ARG_MAX + _SC_CHILD_MAX, +#define _SC_CHILD_MAX _SC_CHILD_MAX + _SC_CLK_TCK, +#define _SC_CLK_TCK _SC_CLK_TCK + _SC_NGROUPS_MAX, +#define _SC_NGROUPS_MAX _SC_NGROUPS_MAX + _SC_OPEN_MAX, +#define _SC_OPEN_MAX _SC_OPEN_MAX + _SC_STREAM_MAX, +#define _SC_STREAM_MAX _SC_STREAM_MAX + _SC_TZNAME_MAX, +#define _SC_TZNAME_MAX _SC_TZNAME_MAX + _SC_JOB_CONTROL, +#define _SC_JOB_CONTROL _SC_JOB_CONTROL + _SC_SAVED_IDS, +#define _SC_SAVED_IDS _SC_SAVED_IDS + _SC_REALTIME_SIGNALS, +#define _SC_REALTIME_SIGNALS _SC_REALTIME_SIGNALS + _SC_PRIORITY_SCHEDULING, +#define _SC_PRIORITY_SCHEDULING _SC_PRIORITY_SCHEDULING + _SC_TIMERS, +#define _SC_TIMERS _SC_TIMERS + _SC_ASYNCHRONOUS_IO, +#define _SC_ASYNCHRONOUS_IO _SC_ASYNCHRONOUS_IO + _SC_PRIORITIZED_IO, +#define _SC_PRIORITIZED_IO _SC_PRIORITIZED_IO + _SC_SYNCHRONIZED_IO, +#define _SC_SYNCHRONIZED_IO _SC_SYNCHRONIZED_IO + _SC_FSYNC, +#define _SC_FSYNC _SC_FSYNC + _SC_MAPPED_FILES, +#define _SC_MAPPED_FILES _SC_MAPPED_FILES + _SC_MEMLOCK, +#define _SC_MEMLOCK _SC_MEMLOCK + _SC_MEMLOCK_RANGE, +#define _SC_MEMLOCK_RANGE _SC_MEMLOCK_RANGE + _SC_MEMORY_PROTECTION, +#define _SC_MEMORY_PROTECTION _SC_MEMORY_PROTECTION + _SC_MESSAGE_PASSING, +#define _SC_MESSAGE_PASSING _SC_MESSAGE_PASSING + _SC_SEMAPHORES, +#define _SC_SEMAPHORES _SC_SEMAPHORES + _SC_SHARED_MEMORY_OBJECTS, +#define _SC_SHARED_MEMORY_OBJECTS _SC_SHARED_MEMORY_OBJECTS + _SC_AIO_LISTIO_MAX, +#define _SC_AIO_LISTIO_MAX _SC_AIO_LISTIO_MAX + _SC_AIO_MAX, +#define _SC_AIO_MAX _SC_AIO_MAX + _SC_AIO_PRIO_DELTA_MAX, +#define _SC_AIO_PRIO_DELTA_MAX _SC_AIO_PRIO_DELTA_MAX + _SC_DELAYTIMER_MAX, +#define _SC_DELAYTIMER_MAX _SC_DELAYTIMER_MAX + _SC_MQ_OPEN_MAX, +#define _SC_MQ_OPEN_MAX _SC_MQ_OPEN_MAX + _SC_MQ_PRIO_MAX, +#define _SC_MQ_PRIO_MAX _SC_MQ_PRIO_MAX + _SC_VERSION, +#define _SC_VERSION _SC_VERSION + _SC_PAGESIZE, +#define _SC_PAGESIZE _SC_PAGESIZE +#define _SC_PAGE_SIZE _SC_PAGESIZE + _SC_RTSIG_MAX, +#define _SC_RTSIG_MAX _SC_RTSIG_MAX + _SC_SEM_NSEMS_MAX, +#define _SC_SEM_NSEMS_MAX _SC_SEM_NSEMS_MAX + _SC_SEM_VALUE_MAX, +#define _SC_SEM_VALUE_MAX _SC_SEM_VALUE_MAX + _SC_SIGQUEUE_MAX, +#define _SC_SIGQUEUE_MAX _SC_SIGQUEUE_MAX + _SC_TIMER_MAX, +#define _SC_TIMER_MAX _SC_TIMER_MAX + + /* Values for the argument to `sysconf' + corresponding to _POSIX2_* symbols. */ + _SC_BC_BASE_MAX, +#define _SC_BC_BASE_MAX _SC_BC_BASE_MAX + _SC_BC_DIM_MAX, +#define _SC_BC_DIM_MAX _SC_BC_DIM_MAX + _SC_BC_SCALE_MAX, +#define _SC_BC_SCALE_MAX _SC_BC_SCALE_MAX + _SC_BC_STRING_MAX, +#define _SC_BC_STRING_MAX _SC_BC_STRING_MAX + _SC_COLL_WEIGHTS_MAX, +#define _SC_COLL_WEIGHTS_MAX _SC_COLL_WEIGHTS_MAX + _SC_EQUIV_CLASS_MAX, +#define _SC_EQUIV_CLASS_MAX _SC_EQUIV_CLASS_MAX + _SC_EXPR_NEST_MAX, +#define _SC_EXPR_NEST_MAX _SC_EXPR_NEST_MAX + _SC_LINE_MAX, +#define _SC_LINE_MAX _SC_LINE_MAX + _SC_RE_DUP_MAX, +#define _SC_RE_DUP_MAX _SC_RE_DUP_MAX + _SC_CHARCLASS_NAME_MAX, +#define _SC_CHARCLASS_NAME_MAX _SC_CHARCLASS_NAME_MAX + + _SC_2_VERSION, +#define _SC_2_VERSION _SC_2_VERSION + _SC_2_C_BIND, +#define _SC_2_C_BIND _SC_2_C_BIND + _SC_2_C_DEV, +#define _SC_2_C_DEV _SC_2_C_DEV + _SC_2_FORT_DEV, +#define _SC_2_FORT_DEV _SC_2_FORT_DEV + _SC_2_FORT_RUN, +#define _SC_2_FORT_RUN _SC_2_FORT_RUN + _SC_2_SW_DEV, +#define _SC_2_SW_DEV _SC_2_SW_DEV + _SC_2_LOCALEDEF, +#define _SC_2_LOCALEDEF _SC_2_LOCALEDEF + + _SC_PII, +#define _SC_PII _SC_PII + _SC_PII_XTI, +#define _SC_PII_XTI _SC_PII_XTI + _SC_PII_SOCKET, +#define _SC_PII_SOCKET _SC_PII_SOCKET + _SC_PII_INTERNET, +#define _SC_PII_INTERNET _SC_PII_INTERNET + _SC_PII_OSI, +#define _SC_PII_OSI _SC_PII_OSI + _SC_POLL, +#define _SC_POLL _SC_POLL + _SC_SELECT, +#define _SC_SELECT _SC_SELECT + _SC_UIO_MAXIOV, +#define _SC_UIO_MAXIOV _SC_UIO_MAXIOV + _SC_IOV_MAX = _SC_UIO_MAXIOV, +#define _SC_IOV_MAX _SC_IOV_MAX + _SC_PII_INTERNET_STREAM, +#define _SC_PII_INTERNET_STREAM _SC_PII_INTERNET_STREAM + _SC_PII_INTERNET_DGRAM, +#define _SC_PII_INTERNET_DGRAM _SC_PII_INTERNET_DGRAM + _SC_PII_OSI_COTS, +#define _SC_PII_OSI_COTS _SC_PII_OSI_COTS + _SC_PII_OSI_CLTS, +#define _SC_PII_OSI_CLTS _SC_PII_OSI_CLTS + _SC_PII_OSI_M, +#define _SC_PII_OSI_M _SC_PII_OSI_M + _SC_T_IOV_MAX, +#define _SC_T_IOV_MAX _SC_T_IOV_MAX + + /* Values according to POSIX 1003.1c (POSIX threads). */ + _SC_THREADS, +#define _SC_THREADS _SC_THREADS + _SC_THREAD_SAFE_FUNCTIONS, +#define _SC_THREAD_SAFE_FUNCTIONS _SC_THREAD_SAFE_FUNCTIONS + _SC_GETGR_R_SIZE_MAX, +#define _SC_GETGR_R_SIZE_MAX _SC_GETGR_R_SIZE_MAX + _SC_GETPW_R_SIZE_MAX, +#define _SC_GETPW_R_SIZE_MAX _SC_GETPW_R_SIZE_MAX + _SC_LOGIN_NAME_MAX, +#define _SC_LOGIN_NAME_MAX _SC_LOGIN_NAME_MAX + _SC_TTY_NAME_MAX, +#define _SC_TTY_NAME_MAX _SC_TTY_NAME_MAX + _SC_THREAD_DESTRUCTOR_ITERATIONS, +#define _SC_THREAD_DESTRUCTOR_ITERATIONS _SC_THREAD_DESTRUCTOR_ITERATIONS + _SC_THREAD_KEYS_MAX, +#define _SC_THREAD_KEYS_MAX _SC_THREAD_KEYS_MAX + _SC_THREAD_STACK_MIN, +#define _SC_THREAD_STACK_MIN _SC_THREAD_STACK_MIN + _SC_THREAD_THREADS_MAX, +#define _SC_THREAD_THREADS_MAX _SC_THREAD_THREADS_MAX + _SC_THREAD_ATTR_STACKADDR, +#define _SC_THREAD_ATTR_STACKADDR _SC_THREAD_ATTR_STACKADDR + _SC_THREAD_ATTR_STACKSIZE, +#define _SC_THREAD_ATTR_STACKSIZE _SC_THREAD_ATTR_STACKSIZE + _SC_THREAD_PRIORITY_SCHEDULING, +#define _SC_THREAD_PRIORITY_SCHEDULING _SC_THREAD_PRIORITY_SCHEDULING + _SC_THREAD_PRIO_INHERIT, +#define _SC_THREAD_PRIO_INHERIT _SC_THREAD_PRIO_INHERIT + _SC_THREAD_PRIO_PROTECT, +#define _SC_THREAD_PRIO_PROTECT _SC_THREAD_PRIO_PROTECT + _SC_THREAD_PROCESS_SHARED, +#define _SC_THREAD_PROCESS_SHARED _SC_THREAD_PROCESS_SHARED + + _SC_NPROCESSORS_CONF, +#define _SC_NPROCESSORS_CONF _SC_NPROCESSORS_CONF + _SC_NPROCESSORS_ONLN, +#define _SC_NPROCESSORS_ONLN _SC_NPROCESSORS_ONLN + _SC_PHYS_PAGES, +#define _SC_PHYS_PAGES _SC_PHYS_PAGES + _SC_AVPHYS_PAGES, +#define _SC_AVPHYS_PAGES _SC_AVPHYS_PAGES + _SC_ATEXIT_MAX, +#define _SC_ATEXIT_MAX _SC_ATEXIT_MAX + _SC_PASS_MAX, +#define _SC_PASS_MAX _SC_PASS_MAX + + _SC_XOPEN_VERSION, +#define _SC_XOPEN_VERSION _SC_XOPEN_VERSION + _SC_XOPEN_XCU_VERSION, +#define _SC_XOPEN_XCU_VERSION _SC_XOPEN_XCU_VERSION + _SC_XOPEN_UNIX, +#define _SC_XOPEN_UNIX _SC_XOPEN_UNIX + _SC_XOPEN_CRYPT, +#define _SC_XOPEN_CRYPT _SC_XOPEN_CRYPT + _SC_XOPEN_ENH_I18N, +#define _SC_XOPEN_ENH_I18N _SC_XOPEN_ENH_I18N + _SC_XOPEN_SHM, +#define _SC_XOPEN_SHM _SC_XOPEN_SHM + + _SC_2_CHAR_TERM, +#define _SC_2_CHAR_TERM _SC_2_CHAR_TERM + _SC_2_C_VERSION, +#define _SC_2_C_VERSION _SC_2_C_VERSION + _SC_2_UPE, +#define _SC_2_UPE _SC_2_UPE + + _SC_XOPEN_XPG2, +#define _SC_XOPEN_XPG2 _SC_XOPEN_XPG2 + _SC_XOPEN_XPG3, +#define _SC_XOPEN_XPG3 _SC_XOPEN_XPG3 + _SC_XOPEN_XPG4, +#define _SC_XOPEN_XPG4 _SC_XOPEN_XPG4 + + _SC_CHAR_BIT, +#define _SC_CHAR_BIT _SC_CHAR_BIT + _SC_CHAR_MAX, +#define _SC_CHAR_MAX _SC_CHAR_MAX + _SC_CHAR_MIN, +#define _SC_CHAR_MIN _SC_CHAR_MIN + _SC_INT_MAX, +#define _SC_INT_MAX _SC_INT_MAX + _SC_INT_MIN, +#define _SC_INT_MIN _SC_INT_MIN + _SC_LONG_BIT, +#define _SC_LONG_BIT _SC_LONG_BIT + _SC_WORD_BIT, +#define _SC_WORD_BIT _SC_WORD_BIT + _SC_MB_LEN_MAX, +#define _SC_MB_LEN_MAX _SC_MB_LEN_MAX + _SC_NZERO, +#define _SC_NZERO _SC_NZERO + _SC_SSIZE_MAX, +#define _SC_SSIZE_MAX _SC_SSIZE_MAX + _SC_SCHAR_MAX, +#define _SC_SCHAR_MAX _SC_SCHAR_MAX + _SC_SCHAR_MIN, +#define _SC_SCHAR_MIN _SC_SCHAR_MIN + _SC_SHRT_MAX, +#define _SC_SHRT_MAX _SC_SHRT_MAX + _SC_SHRT_MIN, +#define _SC_SHRT_MIN _SC_SHRT_MIN + _SC_UCHAR_MAX, +#define _SC_UCHAR_MAX _SC_UCHAR_MAX + _SC_UINT_MAX, +#define _SC_UINT_MAX _SC_UINT_MAX + _SC_ULONG_MAX, +#define _SC_ULONG_MAX _SC_ULONG_MAX + _SC_USHRT_MAX, +#define _SC_USHRT_MAX _SC_USHRT_MAX + + _SC_NL_ARGMAX, +#define _SC_NL_ARGMAX _SC_NL_ARGMAX + _SC_NL_LANGMAX, +#define _SC_NL_LANGMAX _SC_NL_LANGMAX + _SC_NL_MSGMAX, +#define _SC_NL_MSGMAX _SC_NL_MSGMAX + _SC_NL_NMAX, +#define _SC_NL_NMAX _SC_NL_NMAX + _SC_NL_SETMAX, +#define _SC_NL_SETMAX _SC_NL_SETMAX + _SC_NL_TEXTMAX, +#define _SC_NL_TEXTMAX _SC_NL_TEXTMAX + + _SC_XBS5_ILP32_OFF32, +#define _SC_XBS5_ILP32_OFF32 _SC_XBS5_ILP32_OFF32 + _SC_XBS5_ILP32_OFFBIG, +#define _SC_XBS5_ILP32_OFFBIG _SC_XBS5_ILP32_OFFBIG + _SC_XBS5_LP64_OFF64, +#define _SC_XBS5_LP64_OFF64 _SC_XBS5_LP64_OFF64 + _SC_XBS5_LPBIG_OFFBIG, +#define _SC_XBS5_LPBIG_OFFBIG _SC_XBS5_LPBIG_OFFBIG + + _SC_XOPEN_LEGACY, +#define _SC_XOPEN_LEGACY _SC_XOPEN_LEGACY + _SC_XOPEN_REALTIME, +#define _SC_XOPEN_REALTIME _SC_XOPEN_REALTIME + _SC_XOPEN_REALTIME_THREADS, +#define _SC_XOPEN_REALTIME_THREADS _SC_XOPEN_REALTIME_THREADS + + _SC_ADVISORY_INFO, +#define _SC_ADVISORY_INFO _SC_ADVISORY_INFO + _SC_BARRIERS, +#define _SC_BARRIERS _SC_BARRIERS + _SC_BASE, +#define _SC_BASE _SC_BASE + _SC_C_LANG_SUPPORT, +#define _SC_C_LANG_SUPPORT _SC_C_LANG_SUPPORT + _SC_C_LANG_SUPPORT_R, +#define _SC_C_LANG_SUPPORT_R _SC_C_LANG_SUPPORT_R + _SC_CLOCK_SELECTION, +#define _SC_CLOCK_SELECTION _SC_CLOCK_SELECTION + _SC_CPUTIME, +#define _SC_CPUTIME _SC_CPUTIME + _SC_THREAD_CPUTIME, +#define _SC_THREAD_CPUTIME _SC_THREAD_CPUTIME + _SC_DEVICE_IO, +#define _SC_DEVICE_IO _SC_DEVICE_IO + _SC_DEVICE_SPECIFIC, +#define _SC_DEVICE_SPECIFIC _SC_DEVICE_SPECIFIC + _SC_DEVICE_SPECIFIC_R, +#define _SC_DEVICE_SPECIFIC_R _SC_DEVICE_SPECIFIC_R + _SC_FD_MGMT, +#define _SC_FD_MGMT _SC_FD_MGMT + _SC_FIFO, +#define _SC_FIFO _SC_FIFO + _SC_PIPE, +#define _SC_PIPE _SC_PIPE + _SC_FILE_ATTRIBUTES, +#define _SC_FILE_ATTRIBUTES _SC_FILE_ATTRIBUTES + _SC_FILE_LOCKING, +#define _SC_FILE_LOCKING _SC_FILE_LOCKING + _SC_FILE_SYSTEM, +#define _SC_FILE_SYSTEM _SC_FILE_SYSTEM + _SC_MONOTONIC_CLOCK, +#define _SC_MONOTONIC_CLOCK _SC_MONOTONIC_CLOCK + _SC_MULTI_PROCESS, +#define _SC_MULTI_PROCESS _SC_MULTI_PROCESS + _SC_SINGLE_PROCESS, +#define _SC_SINGLE_PROCESS _SC_SINGLE_PROCESS + _SC_NETWORKING, +#define _SC_NETWORKING _SC_NETWORKING + _SC_READER_WRITER_LOCKS, +#define _SC_READER_WRITER_LOCKS _SC_READER_WRITER_LOCKS + _SC_SPIN_LOCKS, +#define _SC_SPIN_LOCKS _SC_SPIN_LOCKS + _SC_REGEXP, +#define _SC_REGEXP _SC_REGEXP + _SC_REGEX_VERSION, +#define _SC_REGEX_VERSION _SC_REGEX_VERSION + _SC_SHELL, +#define _SC_SHELL _SC_SHELL + _SC_SIGNALS, +#define _SC_SIGNALS _SC_SIGNALS + _SC_SPAWN, +#define _SC_SPAWN _SC_SPAWN + _SC_SPORADIC_SERVER, +#define _SC_SPORADIC_SERVER _SC_SPORADIC_SERVER + _SC_THREAD_SPORADIC_SERVER, +#define _SC_THREAD_SPORADIC_SERVER _SC_THREAD_SPORADIC_SERVER + _SC_SYSTEM_DATABASE, +#define _SC_SYSTEM_DATABASE _SC_SYSTEM_DATABASE + _SC_SYSTEM_DATABASE_R, +#define _SC_SYSTEM_DATABASE_R _SC_SYSTEM_DATABASE_R + _SC_TIMEOUTS, +#define _SC_TIMEOUTS _SC_TIMEOUTS + _SC_TYPED_MEMORY_OBJECTS, +#define _SC_TYPED_MEMORY_OBJECTS _SC_TYPED_MEMORY_OBJECTS + _SC_USER_GROUPS, +#define _SC_USER_GROUPS _SC_USER_GROUPS + _SC_USER_GROUPS_R, +#define _SC_USER_GROUPS_R _SC_USER_GROUPS_R + _SC_2_PBS, +#define _SC_2_PBS _SC_2_PBS + _SC_2_PBS_ACCOUNTING, +#define _SC_2_PBS_ACCOUNTING _SC_2_PBS_ACCOUNTING + _SC_2_PBS_LOCATE, +#define _SC_2_PBS_LOCATE _SC_2_PBS_LOCATE + _SC_2_PBS_MESSAGE, +#define _SC_2_PBS_MESSAGE _SC_2_PBS_MESSAGE + _SC_2_PBS_TRACK, +#define _SC_2_PBS_TRACK _SC_2_PBS_TRACK + _SC_SYMLOOP_MAX, +#define _SC_SYMLOOP_MAX _SC_SYMLOOP_MAX + _SC_STREAMS, +#define _SC_STREAMS _SC_STREAMS + _SC_2_PBS_CHECKPOINT, +#define _SC_2_PBS_CHECKPOINT _SC_2_PBS_CHECKPOINT + + _SC_V6_ILP32_OFF32, +#define _SC_V6_ILP32_OFF32 _SC_V6_ILP32_OFF32 + _SC_V6_ILP32_OFFBIG, +#define _SC_V6_ILP32_OFFBIG _SC_V6_ILP32_OFFBIG + _SC_V6_LP64_OFF64, +#define _SC_V6_LP64_OFF64 _SC_V6_LP64_OFF64 + _SC_V6_LPBIG_OFFBIG, +#define _SC_V6_LPBIG_OFFBIG _SC_V6_LPBIG_OFFBIG + + _SC_HOST_NAME_MAX, +#define _SC_HOST_NAME_MAX _SC_HOST_NAME_MAX + _SC_TRACE, +#define _SC_TRACE _SC_TRACE + _SC_TRACE_EVENT_FILTER, +#define _SC_TRACE_EVENT_FILTER _SC_TRACE_EVENT_FILTER + _SC_TRACE_INHERIT, +#define _SC_TRACE_INHERIT _SC_TRACE_INHERIT + _SC_TRACE_LOG, +#define _SC_TRACE_LOG _SC_TRACE_LOG + + _SC_LEVEL1_ICACHE_SIZE, +#define _SC_LEVEL1_ICACHE_SIZE _SC_LEVEL1_ICACHE_SIZE + _SC_LEVEL1_ICACHE_ASSOC, +#define _SC_LEVEL1_ICACHE_ASSOC _SC_LEVEL1_ICACHE_ASSOC + _SC_LEVEL1_ICACHE_LINESIZE, +#define _SC_LEVEL1_ICACHE_LINESIZE _SC_LEVEL1_ICACHE_LINESIZE + _SC_LEVEL1_DCACHE_SIZE, +#define _SC_LEVEL1_DCACHE_SIZE _SC_LEVEL1_DCACHE_SIZE + _SC_LEVEL1_DCACHE_ASSOC, +#define _SC_LEVEL1_DCACHE_ASSOC _SC_LEVEL1_DCACHE_ASSOC + _SC_LEVEL1_DCACHE_LINESIZE, +#define _SC_LEVEL1_DCACHE_LINESIZE _SC_LEVEL1_DCACHE_LINESIZE + _SC_LEVEL2_CACHE_SIZE, +#define _SC_LEVEL2_CACHE_SIZE _SC_LEVEL2_CACHE_SIZE + _SC_LEVEL2_CACHE_ASSOC, +#define _SC_LEVEL2_CACHE_ASSOC _SC_LEVEL2_CACHE_ASSOC + _SC_LEVEL2_CACHE_LINESIZE, +#define _SC_LEVEL2_CACHE_LINESIZE _SC_LEVEL2_CACHE_LINESIZE + _SC_LEVEL3_CACHE_SIZE, +#define _SC_LEVEL3_CACHE_SIZE _SC_LEVEL3_CACHE_SIZE + _SC_LEVEL3_CACHE_ASSOC, +#define _SC_LEVEL3_CACHE_ASSOC _SC_LEVEL3_CACHE_ASSOC + _SC_LEVEL3_CACHE_LINESIZE, +#define _SC_LEVEL3_CACHE_LINESIZE _SC_LEVEL3_CACHE_LINESIZE + _SC_LEVEL4_CACHE_SIZE, +#define _SC_LEVEL4_CACHE_SIZE _SC_LEVEL4_CACHE_SIZE + _SC_LEVEL4_CACHE_ASSOC, +#define _SC_LEVEL4_CACHE_ASSOC _SC_LEVEL4_CACHE_ASSOC + _SC_LEVEL4_CACHE_LINESIZE, +#define _SC_LEVEL4_CACHE_LINESIZE _SC_LEVEL4_CACHE_LINESIZE + /* Leave room here, maybe we need a few more cache levels some day. */ + + _SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50, +#define _SC_IPV6 _SC_IPV6 + _SC_RAW_SOCKETS +#define _SC_RAW_SOCKETS _SC_RAW_SOCKETS + }; + +#if (defined __USE_POSIX2 || defined __USE_UNIX98 \ + || defined __USE_FILE_OFFSET64 || defined __USE_LARGEFILE64 \ + || defined __USE_LARGEFILE) +/* Values for the NAME argument to `confstr'. */ +enum + { + _CS_PATH, /* The default search path. */ +#define _CS_PATH _CS_PATH + + _CS_V6_WIDTH_RESTRICTED_ENVS, +# define _CS_V6_WIDTH_RESTRICTED_ENVS _CS_V6_WIDTH_RESTRICTED_ENVS + +# if (defined __USE_FILE_OFFSET64 || defined __USE_LARGEFILE64 \ + || defined __USE_LARGEFILE) + _CS_LFS_CFLAGS = 1000, +#define _CS_LFS_CFLAGS _CS_LFS_CFLAGS + _CS_LFS_LDFLAGS, +#define _CS_LFS_LDFLAGS _CS_LFS_LDFLAGS + _CS_LFS_LIBS, +#define _CS_LFS_LIBS _CS_LFS_LIBS + _CS_LFS_LINTFLAGS, +#define _CS_LFS_LINTFLAGS _CS_LFS_LINTFLAGS + _CS_LFS64_CFLAGS, +#define _CS_LFS64_CFLAGS _CS_LFS64_CFLAGS + _CS_LFS64_LDFLAGS, +#define _CS_LFS64_LDFLAGS _CS_LFS64_LDFLAGS + _CS_LFS64_LIBS, +#define _CS_LFS64_LIBS _CS_LFS64_LIBS + _CS_LFS64_LINTFLAGS, +#define _CS_LFS64_LINTFLAGS _CS_LFS64_LINTFLAGS +# endif + +# ifdef __USE_UNIX98 + _CS_XBS5_ILP32_OFF32_CFLAGS = 1100, +#define _CS_XBS5_ILP32_OFF32_CFLAGS _CS_XBS5_ILP32_OFF32_CFLAGS + _CS_XBS5_ILP32_OFF32_LDFLAGS, +#define _CS_XBS5_ILP32_OFF32_LDFLAGS _CS_XBS5_ILP32_OFF32_LDFLAGS + _CS_XBS5_ILP32_OFF32_LIBS, +#define _CS_XBS5_ILP32_OFF32_LIBS _CS_XBS5_ILP32_OFF32_LIBS + _CS_XBS5_ILP32_OFF32_LINTFLAGS, +#define _CS_XBS5_ILP32_OFF32_LINTFLAGS _CS_XBS5_ILP32_OFF32_LINTFLAGS + _CS_XBS5_ILP32_OFFBIG_CFLAGS, +#define _CS_XBS5_ILP32_OFFBIG_CFLAGS _CS_XBS5_ILP32_OFFBIG_CFLAGS + _CS_XBS5_ILP32_OFFBIG_LDFLAGS, +#define _CS_XBS5_ILP32_OFFBIG_LDFLAGS _CS_XBS5_ILP32_OFFBIG_LDFLAGS + _CS_XBS5_ILP32_OFFBIG_LIBS, +#define _CS_XBS5_ILP32_OFFBIG_LIBS _CS_XBS5_ILP32_OFFBIG_LIBS + _CS_XBS5_ILP32_OFFBIG_LINTFLAGS, +#define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS _CS_XBS5_ILP32_OFFBIG_LINTFLAGS + _CS_XBS5_LP64_OFF64_CFLAGS, +#define _CS_XBS5_LP64_OFF64_CFLAGS _CS_XBS5_LP64_OFF64_CFLAGS + _CS_XBS5_LP64_OFF64_LDFLAGS, +#define _CS_XBS5_LP64_OFF64_LDFLAGS _CS_XBS5_LP64_OFF64_LDFLAGS + _CS_XBS5_LP64_OFF64_LIBS, +#define _CS_XBS5_LP64_OFF64_LIBS _CS_XBS5_LP64_OFF64_LIBS + _CS_XBS5_LP64_OFF64_LINTFLAGS, +#define _CS_XBS5_LP64_OFF64_LINTFLAGS _CS_XBS5_LP64_OFF64_LINTFLAGS + _CS_XBS5_LPBIG_OFFBIG_CFLAGS, +#define _CS_XBS5_LPBIG_OFFBIG_CFLAGS _CS_XBS5_LPBIG_OFFBIG_CFLAGS + _CS_XBS5_LPBIG_OFFBIG_LDFLAGS, +#define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS _CS_XBS5_LPBIG_OFFBIG_LDFLAGS + _CS_XBS5_LPBIG_OFFBIG_LIBS, +#define _CS_XBS5_LPBIG_OFFBIG_LIBS _CS_XBS5_LPBIG_OFFBIG_LIBS + _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS, +#define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS +# endif +# ifdef __USE_XOPEN2K + _CS_POSIX_V6_ILP32_OFF32_CFLAGS, +#define _CS_POSIX_V6_ILP32_OFF32_CFLAGS _CS_POSIX_V6_ILP32_OFF32_CFLAGS + _CS_POSIX_V6_ILP32_OFF32_LDFLAGS, +#define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS _CS_POSIX_V6_ILP32_OFF32_LDFLAGS + _CS_POSIX_V6_ILP32_OFF32_LIBS, +#define _CS_POSIX_V6_ILP32_OFF32_LIBS _CS_POSIX_V6_ILP32_OFF32_LIBS + _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS, +#define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS + _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS, +#define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS + _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS, +#define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS + _CS_POSIX_V6_ILP32_OFFBIG_LIBS, +#define _CS_POSIX_V6_ILP32_OFFBIG_LIBS _CS_POSIX_V6_ILP32_OFFBIG_LIBS + _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS, +#define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS + _CS_POSIX_V6_LP64_OFF64_CFLAGS, +#define _CS_POSIX_V6_LP64_OFF64_CFLAGS _CS_POSIX_V6_LP64_OFF64_CFLAGS + _CS_POSIX_V6_LP64_OFF64_LDFLAGS, +#define _CS_POSIX_V6_LP64_OFF64_LDFLAGS _CS_POSIX_V6_LP64_OFF64_LDFLAGS + _CS_POSIX_V6_LP64_OFF64_LIBS, +#define _CS_POSIX_V6_LP64_OFF64_LIBS _CS_POSIX_V6_LP64_OFF64_LIBS + _CS_POSIX_V6_LP64_OFF64_LINTFLAGS, +#define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS _CS_POSIX_V6_LP64_OFF64_LINTFLAGS + _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS, +#define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS + _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS, +#define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS + _CS_POSIX_V6_LPBIG_OFFBIG_LIBS, +#define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V6_LPBIG_OFFBIG_LIBS + _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS +#define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS +# endif + }; +#endif diff --git a/conts/posix/libposix/include/posix/bits/dirent.h b/conts/posix/libposix/include/posix/bits/dirent.h new file mode 100644 index 0000000..76794b0 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/dirent.h @@ -0,0 +1,53 @@ +/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _DIRENT_H +# error "Never use directly; include instead." +#endif + +struct dirent + { +#ifndef __USE_FILE_OFFSET64 + __ino_t d_ino; + __off_t d_off; +#else + __ino64_t d_ino; + __off64_t d_off; +#endif + unsigned short int d_reclen; + unsigned char d_type; + char d_name[256]; /* We must not include limits.h! */ + }; + +#ifdef __USE_LARGEFILE64 +struct dirent64 + { + __ino64_t d_ino; + __off64_t d_off; + unsigned short int d_reclen; + unsigned char d_type; + char d_name[256]; /* We must not include limits.h! */ + }; +#endif + +#define d_fileno d_ino /* Backwards compatibility. */ + +#undef _DIRENT_HAVE_D_NAMLEN +#define _DIRENT_HAVE_D_RECLEN +#define _DIRENT_HAVE_D_OFF +#define _DIRENT_HAVE_D_TYPE diff --git a/conts/posix/libposix/include/posix/bits/dlfcn.h b/conts/posix/libposix/include/posix/bits/dlfcn.h new file mode 100644 index 0000000..4bfbbff --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/dlfcn.h @@ -0,0 +1,67 @@ +/* System dependent definitions for run-time dynamic loading. + Copyright (C) 1996-2001, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _DLFCN_H +# error "Never use directly; include instead." +#endif + +/* The MODE argument to `dlopen' contains one of the following: */ +#define RTLD_LAZY 0x00001 /* Lazy function call binding. */ +#define RTLD_NOW 0x00002 /* Immediate function call binding. */ +#if 0 /* uClibc doesnt support these */ +#define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */ +#define RTLD_NOLOAD 0x00004 /* Do not load the object. */ +#define RTLD_DEEPBIND 0x00008 /* Use deep binding. */ +#endif + +/* If the following bit is set in the MODE argument to `dlopen', + the symbols of the loaded object and its dependencies are made + visible as if the object were linked directly into the program. */ +#define RTLD_GLOBAL 0x00100 + +/* Unix98 demands the following flag which is the inverse to RTLD_GLOBAL. + The implementation does this by default and so we can define the + value to zero. */ +#define RTLD_LOCAL 0 + +/* Do not delete object when closed. */ +#define RTLD_NODELETE 0x01000 + +#if 0 /*def __USE_GNU*/ +/* To support profiling of shared objects it is a good idea to call + the function found using `dlsym' using the following macro since + these calls do not use the PLT. But this would mean the dynamic + loader has no chance to find out when the function is called. The + macro applies the necessary magic so that profiling is possible. + Rewrite + foo = (*fctp) (arg1, arg2); + into + foo = DL_CALL_FCT (fctp, (arg1, arg2)); +*/ +# define DL_CALL_FCT(fctp, args) \ + (_dl_mcount_wrapper_check ((void *) (fctp)), (*(fctp)) args) + +__BEGIN_DECLS + +/* This function calls the profiling functions. */ +extern void _dl_mcount_wrapper_check (void *__selfpc) __THROW; + +__END_DECLS + +#endif diff --git a/conts/posix/libposix/include/posix/bits/elfclass.h b/conts/posix/libposix/include/posix/bits/elfclass.h new file mode 100644 index 0000000..180227d --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/elfclass.h @@ -0,0 +1,14 @@ +/* This file specifies the native word size of the machine, which indicates + the ELF file class used for executables and shared objects on this + machine. */ + +#ifndef _LINK_H +# error "Never use directly; include instead." +#endif + +#include + +#define __ELF_NATIVE_CLASS __WORDSIZE + +/* The entries in the .hash table always have a size of 32 bits. */ +typedef uint32_t Elf_Symndx; diff --git a/conts/posix/libposix/include/posix/bits/endian.h b/conts/posix/libposix/include/posix/bits/endian.h new file mode 100644 index 0000000..27946cd --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/endian.h @@ -0,0 +1,19 @@ +#ifndef _ENDIAN_H +# error "Never use directly; include instead." +#endif + +/* ARM can be either big or little endian. */ +#ifdef __ARMEB__ +# define __BYTE_ORDER __BIG_ENDIAN +#else +# define __BYTE_ORDER __LITTLE_ENDIAN +#endif + +/* FPA floating point units are always big-endian, irrespective of the + CPU endianness. VFP floating point units use the same endianness + as the rest of the system. */ +#if defined __VFP_FP__ || defined __MAVERICK__ +# define __FLOAT_WORD_ORDER __BYTE_ORDER +#else +# define __FLOAT_WORD_ORDER __BIG_ENDIAN +#endif diff --git a/conts/posix/libposix/include/posix/bits/environments.h b/conts/posix/libposix/include/posix/bits/environments.h new file mode 100644 index 0000000..4617dc4 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/environments.h @@ -0,0 +1,78 @@ +/* Copyright (C) 1999, 2001, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _UNISTD_H +# error "Never include this file directly. Use instead" +#endif + +#include + +/* This header should define the following symbols under the described + situations. A value `1' means that the model is always supported, + `-1' means it is never supported. Undefined means it cannot be + statically decided. + + _POSIX_V6_ILP32_OFF32 32bit int, long, pointers, and off_t type + _POSIX_V6_ILP32_OFFBIG 32bit int, long, and pointers and larger off_t type + + _POSIX_V6_LP64_OFF32 64bit long and pointers and 32bit off_t type + _POSIX_V6_LPBIG_OFFBIG 64bit long and pointers and large off_t type + + The macros _XBS5_ILP32_OFF32, _XBS5_ILP32_OFFBIG, _XBS5_LP64_OFF32, and + _XBS5_LPBIG_OFFBIG were used in previous versions of the Unix standard + and are available only for compatibility. +*/ + +#if __WORDSIZE == 64 + +/* We can never provide environments with 32-bit wide pointers. */ +# define _POSIX_V6_ILP32_OFF32 -1 +# define _POSIX_V6_ILP32_OFFBIG -1 +# define _XBS5_ILP32_OFF32 -1 +# define _XBS5_ILP32_OFFBIG -1 +/* We also have no use (for now) for an environment with bigger pointers + and offsets. */ +# define _POSIX_V6_LPBIG_OFFBIG -1 +# define _XBS5_LPBIG_OFFBIG -1 + +/* By default we have 64-bit wide `long int', pointers and `off_t'. */ +# define _POSIX_V6_LP64_OFF64 1 +# define _XBS5_LP64_OFF64 1 + +#else /* __WORDSIZE == 32 */ + +/* By default we have 32-bit wide `int', `long int', pointers and `off_t' + and all platforms support LFS. */ +# define _POSIX_V6_ILP32_OFF32 1 +# define _POSIX_V6_ILP32_OFFBIG 1 +# define _XBS5_ILP32_OFF32 1 +# define _XBS5_ILP32_OFFBIG 1 + +/* We optionally provide an environment with the above size but an 64-bit + side `off_t'. Therefore we don't define _XBS5_ILP32_OFFBIG. */ + +/* We can never provide environments with 64-bit wide pointers. */ +# define _POSIX_V6_LP64_OFF64 -1 +# define _POSIX_V6_LPBIG_OFFBIG -1 +# define _XBS5_LP64_OFF64 -1 +# define _XBS5_LPBIG_OFFBIG -1 + +/* CFLAGS. */ +#define __ILP32_OFFBIG_CFLAGS "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" + +#endif /* __WORDSIZE == 32 */ diff --git a/conts/posix/libposix/include/posix/bits/errno.h b/conts/posix/libposix/include/posix/bits/errno.h new file mode 100644 index 0000000..78e8c69 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/errno.h @@ -0,0 +1,59 @@ +/* Error constants. Linux specific version. + Copyright (C) 1996, 1997, 1998, 1999, 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifdef _ERRNO_H + +# undef EDOM +# undef EILSEQ +# undef ERANGE +# include + +/* Linux has no ENOTSUP error code. */ +# define ENOTSUP EOPNOTSUPP + +/* Older Linux versions also had no ECANCELED error code. */ +# ifndef ECANCELED +# define ECANCELED 125 +# endif + +/* Support for error codes to support robust mutexes was added later, too. */ +# ifndef EOWNERDEAD +# define EOWNERDEAD 130 +# define ENOTRECOVERABLE 131 +# endif + +# ifndef __ASSEMBLER__ +/* Function to get address of global `errno' variable. */ +extern int *__errno_location (void) __THROW __attribute__ ((__const__)); + +# ifdef __UCLIBC_HAS_THREADS__ +/* When using threads, errno is a per-thread value. */ +# define errno (*__errno_location ()) +# endif +# endif /* !__ASSEMBLER__ */ +#endif /* _ERRNO_H */ + +#if !defined _ERRNO_H && defined __need_Emath +/* This is ugly but the kernel header is not clean enough. We must + define only the values EDOM, EILSEQ and ERANGE in case __need_Emath is + defined. */ +# define EDOM 33 /* Math argument out of domain of function. */ +# define EILSEQ 84 /* Illegal byte sequence. */ +# define ERANGE 34 /* Math result not representable. */ +#endif /* !_ERRNO_H && __need_Emath */ diff --git a/conts/posix/libposix/include/posix/bits/errno_values.h b/conts/posix/libposix/include/posix/bits/errno_values.h new file mode 100644 index 0000000..18e829d --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/errno_values.h @@ -0,0 +1,137 @@ +#ifndef _BITS_ERRNO_VALUES_H +#define _BITS_ERRNO_VALUES_H + +/* Most architectures use these errno values (i.e. arm cris + * i386 ia64 m68k parisc ppc ppc64 s390 s390x sh x86_64, etc) + * + * A few arches do their own wierd thing, specifically alpha, + * mips, and sparc. + * + */ + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Argument list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ +#define EDEADLOCK EDEADLK +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ +#define ENOMEDIUM 123 /* No medium found */ +#define EMEDIUMTYPE 124 /* Wrong medium type */ + +#endif /* _BITS_ERRNO_VALUES_H */ diff --git a/conts/posix/libposix/include/posix/bits/fcntl.h b/conts/posix/libposix/include/posix/bits/fcntl.h new file mode 100644 index 0000000..1153d27 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/fcntl.h @@ -0,0 +1,237 @@ +/* O_*, F_*, FD_* bit values for Linux. + Copyright (C) 1995-1998, 2000, 2004, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _FCNTL_H +# error "Never use directly; include instead." +#endif + +#include +#ifdef __USE_GNU +# include +#endif + + +/* open/fcntl - O_SYNC is only implemented on blocks devices and on files + located on an ext2 file system */ +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 0100 /* not fcntl */ +#define O_EXCL 0200 /* not fcntl */ +#define O_NOCTTY 0400 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +#define O_NDELAY O_NONBLOCK +#define O_SYNC 010000 +#define O_FSYNC O_SYNC +#define O_ASYNC 020000 + +#ifdef __USE_GNU +# define O_DIRECTORY 040000 /* Must be a directory. */ +# define O_NOFOLLOW 0100000 /* Do not follow links. */ +# define O_DIRECT 0200000 /* Direct disk access. */ +# define O_NOATIME 01000000 /* Do not set atime. */ +#endif + +/* For now Linux has synchronisity options for data and read operations. + We define the symbols here but let them do the same as O_SYNC since + this is a superset. */ +#if defined __USE_POSIX199309 || defined __USE_UNIX98 +# define O_DSYNC O_SYNC /* Synchronize data. */ +# define O_RSYNC O_SYNC /* Synchronize read operations. */ +#endif + +#ifdef __USE_LARGEFILE64 +# define O_LARGEFILE 0400000 +#endif + +/* Values for the second argument to `fcntl'. */ +#define F_DUPFD 0 /* Duplicate file descriptor. */ +#define F_GETFD 1 /* Get file descriptor flags. */ +#define F_SETFD 2 /* Set file descriptor flags. */ +#define F_GETFL 3 /* Get file status flags. */ +#define F_SETFL 4 /* Set file status flags. */ +#ifndef __USE_FILE_OFFSET64 +# define F_GETLK 5 /* Get record locking info. */ +# define F_SETLK 6 /* Set record locking info (non-blocking). */ +# define F_SETLKW 7 /* Set record locking info (blocking). */ +#else +# define F_GETLK F_GETLK64 /* Get record locking info. */ +# define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/ +# define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */ +#endif +#define F_GETLK64 12 /* Get record locking info. */ +#define F_SETLK64 13 /* Set record locking info (non-blocking). */ +#define F_SETLKW64 14 /* Set record locking info (blocking). */ + +#if defined __USE_BSD || defined __USE_UNIX98 +# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */ +# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */ +#endif + +#ifdef __USE_GNU +# define F_SETSIG 10 /* Set number of signal to be sent. */ +# define F_GETSIG 11 /* Get number of signal to be sent. */ +#endif + +#ifdef __USE_GNU +# define F_SETLEASE 1024 /* Set a lease. */ +# define F_GETLEASE 1025 /* Enquire what lease is active. */ +# define F_NOTIFY 1026 /* Request notfications on a directory. */ +#endif + +/* For F_[GET|SET]FL. */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */ +#define F_RDLCK 0 /* Read lock. */ +#define F_WRLCK 1 /* Write lock. */ +#define F_UNLCK 2 /* Remove lock. */ + +/* For old implementation of bsd flock(). */ +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ + +#ifdef __USE_BSD +/* Operations for bsd flock(), also used by the kernel implementation. */ +# define LOCK_SH 1 /* shared lock */ +# define LOCK_EX 2 /* exclusive lock */ +# define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +# define LOCK_UN 8 /* remove lock */ +#endif + +#ifdef __USE_GNU +# define LOCK_MAND 32 /* This is a mandatory flock: */ +# define LOCK_READ 64 /* ... which allows concurrent read operations. */ +# define LOCK_WRITE 128 /* ... which allows concurrent write operations. */ +# define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */ +#endif + +#ifdef __USE_GNU +/* Types of directory notifications that may be requested with F_NOTIFY. */ +# define DN_ACCESS 0x00000001 /* File accessed. */ +# define DN_MODIFY 0x00000002 /* File modified. */ +# define DN_CREATE 0x00000004 /* File created. */ +# define DN_DELETE 0x00000008 /* File removed. */ +# define DN_RENAME 0x00000010 /* File renamed. */ +# define DN_ATTRIB 0x00000020 /* File changed attibutes. */ +# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */ +#endif + +struct flock + { + short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */ + short int l_whence; /* Where `l_start' is relative to (like `lseek'). */ +#ifndef __USE_FILE_OFFSET64 + __off_t l_start; /* Offset where the lock begins. */ + __off_t l_len; /* Size of the locked area; zero means until EOF. */ +#else + __off64_t l_start; /* Offset where the lock begins. */ + __off64_t l_len; /* Size of the locked area; zero means until EOF. */ +#endif + __pid_t l_pid; /* Process holding the lock. */ + }; + +#ifdef __USE_LARGEFILE64 +struct flock64 + { + short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */ + short int l_whence; /* Where `l_start' is relative to (like `lseek'). */ + __off64_t l_start; /* Offset where the lock begins. */ + __off64_t l_len; /* Size of the locked area; zero means until EOF. */ + __pid_t l_pid; /* Process holding the lock. */ + }; +#endif + +/* Define some more compatibility macros to be backward compatible with + BSD systems which did not managed to hide these kernel macros. */ +#ifdef __USE_BSD +# define FAPPEND O_APPEND +# define FFSYNC O_FSYNC +# define FASYNC O_ASYNC +# define FNONBLOCK O_NONBLOCK +# define FNDELAY O_NDELAY +#endif /* Use BSD. */ + +/* Advise to `posix_fadvise'. */ +#ifdef __USE_XOPEN2K +# define POSIX_FADV_NORMAL 0 /* No further special treatment. */ +# define POSIX_FADV_RANDOM 1 /* Expect random page references. */ +# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */ +# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */ +# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */ +# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ +#endif + + +#ifdef __USE_GNU +/* Flags for SYNC_FILE_RANGE. */ +# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages + in the range before performing the + write. */ +# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those + dirty pages in the range which are + not presently under writeback. */ +# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in + the range after performing the + write. */ + +/* Flags for SPLICE and VMSPLICE. */ +# define SPLICE_F_MOVE 1 /* Move pages instead of copying. */ +# define SPLICE_F_NONBLOCK 2 /* Don't block on the pipe splicing + (but we may still block on the fd + we splice from/to). */ +# define SPLICE_F_MORE 4 /* Expect more data. */ +# define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */ +#endif + +__BEGIN_DECLS + +#ifdef __USE_GNU + +/* Provide kernel hint to read ahead. */ +extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) + __THROW; + + +#if 0 +/* Selective file content synch'ing. */ +extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to, + unsigned int __flags); + + +/* Splice address range into a pipe. */ +extern int vmsplice (int __fdout, const struct iovec *__iov, size_t __count, + unsigned int __flags); + +/* Splice two files together. */ +extern int splice (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; + +/* In-kernel implementation of tee for pipe buffers. */ +extern int tee (int __fdin, int __fdout, size_t __len, unsigned int __flags) + __THROW; +#endif + +#endif + +__END_DECLS diff --git a/conts/posix/libposix/include/posix/bits/fenv.h b/conts/posix/libposix/include/posix/bits/fenv.h new file mode 100644 index 0000000..3764d77 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/fenv.h @@ -0,0 +1,99 @@ +/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _FENV_H +# error "Never use directly; include instead." +#endif + +#ifdef __MAVERICK__ + +/* Define bits representing exceptions in the FPU status word. */ +enum + { + FE_INVALID = 1, +#define FE_INVALID FE_INVALID + FE_OVERFLOW = 4, +#define FE_OVERFLOW FE_OVERFLOW + FE_UNDERFLOW = 8, +#define FE_UNDERFLOW FE_UNDERFLOW + FE_INEXACT = 16, +#define FE_INEXACT FE_INEXACT + }; + +/* Amount to shift by to convert an exception to a mask bit. */ +#define FE_EXCEPT_SHIFT 5 + +/* All supported exceptions. */ +#define FE_ALL_EXCEPT \ + (FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT) + +/* IEEE rounding modes. */ +enum + { + FE_TONEAREST = 0, +#define FE_TONEAREST FE_TONEAREST + FE_TOWARDZERO = 0x400, +#define FE_TOWARDZERO FE_TOWARDZERO + FE_DOWNWARD = 0x800, +#define FE_DOWNWARD FE_DOWNWARD + FE_UPWARD = 0xc00, +#define FE_UPWARD FE_UPWARD + }; + +#define FE_ROUND_MASK (FE_UPWARD) + +#else /* !__MAVERICK__ */ + +/* Define bits representing exceptions in the FPU status word. */ +enum + { + FE_INVALID = 1, +#define FE_INVALID FE_INVALID + FE_DIVBYZERO = 2, +#define FE_DIVBYZERO FE_DIVBYZERO + FE_OVERFLOW = 4, +#define FE_OVERFLOW FE_OVERFLOW + FE_UNDERFLOW = 8, +#define FE_UNDERFLOW FE_UNDERFLOW + }; + +/* Amount to shift by to convert an exception to a mask bit. */ +#define FE_EXCEPT_SHIFT 16 + +/* All supported exceptions. */ +#define FE_ALL_EXCEPT \ + (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) + +/* The ARM FPU basically only supports round-to-nearest. Other rounding + modes exist, but you have to encode them in the actual instruction. */ +#define FE_TONEAREST 0 + +#endif /* __MAVERICK__ */ + +/* Type representing exception flags. */ +typedef unsigned long int fexcept_t; + +/* Type representing floating-point environment. */ +typedef struct + { + unsigned long int __cw; + } +fenv_t; + +/* If the default argument is used we use this value. */ +#define FE_DFL_ENV ((fenv_t *) -1l) diff --git a/conts/posix/libposix/include/posix/bits/fenvinline.h b/conts/posix/libposix/include/posix/bits/fenvinline.h new file mode 100644 index 0000000..42f77b5 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/fenvinline.h @@ -0,0 +1,8 @@ +/* This file provides inline versions of floating-pint environment + handling functions. If there were any. */ + +#ifndef __NO_MATH_INLINES + +/* Here is where the code would go. */ + +#endif diff --git a/conts/posix/libposix/include/posix/bits/getopt.h b/conts/posix/libposix/include/posix/bits/getopt.h new file mode 100644 index 0000000..a28d0a4 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/getopt.h @@ -0,0 +1,181 @@ +/* Declarations for getopt. + Copyright (C) 1989-1994,1996-1999,2001,2003,2004 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _GETOPT_H + +#include + +#ifndef __need_getopt +# define _GETOPT_H 1 +#endif + +/* If __GNU_LIBRARY__ is not already defined, either we are being used + standalone, or this is the first header included in the source file. + If we are being used with glibc, we need to include , but + that does not exist if we are standalone. So: if __GNU_LIBRARY__ is + not defined, include , which will pull in for us + if it's from glibc. (Why ctype.h? It's guaranteed to exist and it + doesn't flood the namespace with stuff the way some other headers do.) */ +#if !defined __GNU_LIBRARY__ +# include +#endif + +#ifndef __THROW +# ifndef __GNUC_PREREQ +# define __GNUC_PREREQ(maj, min) (0) +# endif +# if defined __cplusplus && __GNUC_PREREQ (2,8) +# define __THROW throw () +# else +# define __THROW +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +#ifndef __need_getopt +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ + const char *name; + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct option'. */ + +# define no_argument 0 +# define required_argument 1 +# define optional_argument 2 +#endif /* need getopt */ + + +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. + + Return the option character from OPTS just read. Return -1 when + there are no more options. For unrecognized options, or options + missing arguments, `optopt' is set to the option letter, and '?' is + returned. + + The OPTS string is a list of characters which are recognized option + letters, optionally followed by colons, specifying that that letter + takes an argument, to be placed in `optarg'. + + If a letter in OPTS is followed by two colons, its argument is + optional. This behavior is specific to the GNU `getopt'. + + The argument `--' causes premature termination of argument + scanning, explicitly telling `getopt' that there are no more + options. + + If OPTS begins with `--', then non-option arguments are treated as + arguments to the option '\0'. This behavior is specific to the GNU + `getopt'. */ + +#if defined __GNU_LIBRARY__ || defined __UCLIBC__ +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) + __THROW; +#else /* not __GNU_LIBRARY__ */ +extern int getopt (); +#endif /* __GNU_LIBRARY__ */ + +#if defined __UCLIBC_HAS_GNU_GETOPT__ || defined __UCLIBC_HAS_GETOPT_LONG__ +#ifndef __need_getopt +extern int getopt_long (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind) + __THROW; +extern int getopt_long_only (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind) + __THROW; + +#endif +#endif + +#ifdef __cplusplus +} +#endif + +/* Make sure we later can get all the definitions and declarations. */ +#undef __need_getopt + +#endif /* getopt.h */ diff --git a/conts/posix/libposix/include/posix/bits/huge_val.h b/conts/posix/libposix/include/posix/bits/huge_val.h new file mode 100644 index 0000000..a215f3c --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/huge_val.h @@ -0,0 +1,72 @@ +/* `HUGE_VAL' constant for IEEE 754 machines (where it is infinity). + Used by and functions for overflow. + ARM version. + Copyright (C) 1992, 95, 96, 97, 98, 99, 2000, 2004 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + +/* IEEE positive infinity (-HUGE_VAL is negative infinity). */ + +#if __GNUC_PREREQ(3,3) +# define HUGE_VAL (__builtin_huge_val()) +#elif __GNUC_PREREQ(2,96) +# define HUGE_VAL (__extension__ 0x1.0p2047) +#elif defined __GNUC__ + +#ifndef __CONFIG_ARM_EABI__ +# define HUGE_VAL \ + (__extension__ \ + ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \ + { __l: 0x000000007ff00000ULL }).__d) +#else +# define HUGE_VAL \ + (__extension__ \ + ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \ + { __l: 0x7ff0000000000000ULL }).__d) +#endif + +#else /* not GCC */ + +# include + +typedef union { unsigned char __c[8]; double __d; } __huge_val_t; + +#ifndef __CONFIG_ARM_EABI__ +# if __BYTE_ORDER == __BIG_ENDIAN +# define __HUGE_VAL_bytes { 0, 0, 0, 0, 0x7f, 0xf0, 0, 0 } +# endif +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define __HUGE_VAL_bytes { 0, 0, 0xf0, 0x7f, 0, 0, 0, 0 } +# endif +#else +# if __BYTE_ORDER == __BIG_ENDIAN +# define __HUGE_VAL_bytes { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } +# endif +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define __HUGE_VAL_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } +# endif +#endif + +static __huge_val_t __huge_val = { __HUGE_VAL_bytes }; +# define HUGE_VAL (__huge_val.__d) + +#endif /* GCC. */ diff --git a/conts/posix/libposix/include/posix/bits/huge_valf.h b/conts/posix/libposix/include/posix/bits/huge_valf.h new file mode 100644 index 0000000..1785342 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/huge_valf.h @@ -0,0 +1,53 @@ +/* `HUGE_VALF' constant for IEEE 754 machines (where it is infinity). + Used by and functions for overflow. + Copyright (C) 1992, 1995, 1996, 1997, 1999, 2000, 2004 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + +/* IEEE positive infinity (-HUGE_VAL is negative infinity). */ + +#if __GNUC_PREREQ(3,3) +# define HUGE_VALF (__builtin_huge_valf()) +#elif __GNUC_PREREQ(2,96) +# define HUGE_VALF (__extension__ 0x1.0p255f) +#elif defined __GNUC__ + +# define HUGE_VALF \ + (__extension__ \ + ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) \ + { __l: 0x7f800000UL }).__d) + +#else /* not GCC */ + +typedef union { unsigned char __c[4]; float __f; } __huge_valf_t; + +# if __BYTE_ORDER == __BIG_ENDIAN +# define __HUGE_VALF_bytes { 0x7f, 0x80, 0, 0 } +# endif +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define __HUGE_VALF_bytes { 0, 0, 0x80, 0x7f } +# endif + +static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes }; +# define HUGE_VALF (__huge_valf.__f) + +#endif /* GCC. */ diff --git a/conts/posix/libposix/include/posix/bits/huge_vall.h b/conts/posix/libposix/include/posix/bits/huge_vall.h new file mode 100644 index 0000000..d5e8e22 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/huge_vall.h @@ -0,0 +1,29 @@ +/* Default `HUGE_VALL' constant. + Used by and functions for overflow. + Copyright (C) 1992, 1996, 1997, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + +#if __GNUC_PREREQ(3,3) +# define HUGE_VALL (__builtin_huge_vall()) +#else +# define HUGE_VALL ((long double) HUGE_VAL) +#endif diff --git a/conts/posix/libposix/include/posix/bits/in.h b/conts/posix/libposix/include/posix/bits/in.h new file mode 100644 index 0000000..6880a2e --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/in.h @@ -0,0 +1,170 @@ +/* Copyright (C) 1991-1999, 2000, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Linux version. */ + +#ifndef _NETINET_IN_H +# error "Never use directly; include instead." +#endif + +/* Options for use with `getsockopt' and `setsockopt' at the IP level. + The first word in the comment at the right is the data type used; + "bool" means a boolean value stored in an `int'. */ +#define IP_OPTIONS 4 /* ip_opts; IP per-packet options. */ +#define IP_HDRINCL 3 /* int; Header is included with data. */ +#define IP_TOS 1 /* int; IP type of service and precedence. */ +#define IP_TTL 2 /* int; IP time to live. */ +#define IP_RECVOPTS 6 /* bool; Receive all IP options w/datagram. */ +/* For BSD compatibility. */ +#define IP_RECVRETOPTS IP_RETOPTS /* bool; Receive IP options for response. */ +#define IP_RETOPTS 7 /* ip_opts; Set/get IP per-packet options. */ +#define IP_MULTICAST_IF 32 /* in_addr; set/get IP multicast i/f */ +#define IP_MULTICAST_TTL 33 /* u_char; set/get IP multicast ttl */ +#define IP_MULTICAST_LOOP 34 /* i_char; set/get IP multicast loopback */ +#define IP_ADD_MEMBERSHIP 35 /* ip_mreq; add an IP group membership */ +#define IP_DROP_MEMBERSHIP 36 /* ip_mreq; drop an IP group membership */ +#define IP_UNBLOCK_SOURCE 37 /* ip_mreq_source: unblock data from source */ +#define IP_BLOCK_SOURCE 38 /* ip_mreq_source: block data from source */ +#define IP_ADD_SOURCE_MEMBERSHIP 39 /* ip_mreq_source: join source group */ +#define IP_DROP_SOURCE_MEMBERSHIP 40 /* ip_mreq_source: leave source group */ +#define IP_MSFILTER 41 +#define MCAST_JOIN_GROUP 42 /* group_req: join any-source group */ +#define MCAST_BLOCK_SOURCE 43 /* group_source_req: block from given group */ +#define MCAST_UNBLOCK_SOURCE 44 /* group_source_req: unblock from given group*/ +#define MCAST_LEAVE_GROUP 45 /* group_req: leave any-source group */ +#define MCAST_JOIN_SOURCE_GROUP 46 /* group_source_req: join source-spec gr */ +#define MCAST_LEAVE_SOURCE_GROUP 47 /* group_source_req: leave source-spec gr*/ +#define MCAST_MSFILTER 48 + +#define MCAST_EXCLUDE 0 +#define MCAST_INCLUDE 1 + +#define IP_ROUTER_ALERT 5 /* bool */ +#define IP_PKTINFO 8 /* bool */ +#define IP_PKTOPTIONS 9 +#define IP_PMTUDISC 10 /* obsolete name? */ +#define IP_MTU_DISCOVER 10 /* int; see below */ +#define IP_RECVERR 11 /* bool */ +#define IP_RECVTTL 12 /* bool */ +#define IP_RECVTOS 13 /* bool */ + + +/* IP_MTU_DISCOVER arguments. */ +#define IP_PMTUDISC_DONT 0 /* Never send DF frames. */ +#define IP_PMTUDISC_WANT 1 /* Use per route hints. */ +#define IP_PMTUDISC_DO 2 /* Always DF. */ + +/* To select the IP level. */ +#define SOL_IP 0 + +#define IP_DEFAULT_MULTICAST_TTL 1 +#define IP_DEFAULT_MULTICAST_LOOP 1 +#define IP_MAX_MEMBERSHIPS 20 + +/* Structure used to describe IP options for IP_OPTIONS and IP_RETOPTS. + The `ip_dst' field is used for the first-hop gateway when using a + source route (this gets put into the header proper). */ +struct ip_opts + { + struct in_addr ip_dst; /* First hop; zero without source route. */ + char ip_opts[40]; /* Actually variable in size. */ + }; + +/* Like `struct ip_mreq' but including interface specification by index. */ +struct ip_mreqn + { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_address; /* local IP address of interface */ + int imr_ifindex; /* Interface index */ + }; + +/* Structure used for IP_PKTINFO. */ +struct in_pktinfo + { + int ipi_ifindex; /* Interface index */ + struct in_addr ipi_spec_dst; /* Routing destination address */ + struct in_addr ipi_addr; /* Header destination address */ + }; + +/* Options for use with `getsockopt' and `setsockopt' at the IPv6 level. + The first word in the comment at the right is the data type used; + "bool" means a boolean value stored in an `int'. */ +#define IPV6_ADDRFORM 1 +#define IPV6_2292PKTINFO 2 +#define IPV6_2292HOPOPTS 3 +#define IPV6_2292DSTOPTS 4 +#define IPV6_2292RTHDR 5 +#define IPV6_2292PKTOPTIONS 6 +#define IPV6_CHECKSUM 7 +#define IPV6_2292HOPLIMIT 8 + +#define SCM_SRCRT IPV6_RXSRCRT + +#define IPV6_NEXTHOP 9 +#define IPV6_AUTHHDR 10 +#define IPV6_UNICAST_HOPS 16 +#define IPV6_MULTICAST_IF 17 +#define IPV6_MULTICAST_HOPS 18 +#define IPV6_MULTICAST_LOOP 19 +#define IPV6_JOIN_GROUP 20 +#define IPV6_LEAVE_GROUP 21 +#define IPV6_ROUTER_ALERT 22 +#define IPV6_MTU_DISCOVER 23 +#define IPV6_MTU 24 +#define IPV6_RECVERR 25 +#define IPV6_V6ONLY 26 +#define IPV6_JOIN_ANYCAST 27 +#define IPV6_LEAVE_ANYCAST 28 +#define IPV6_IPSEC_POLICY 34 +#define IPV6_XFRM_POLICY 35 + +#define IPV6_RECVPKTINFO 49 +#define IPV6_PKTINFO 50 +#define IPV6_RECVHOPLIMIT 51 +#define IPV6_HOPLIMIT 52 +#define IPV6_RECVHOPOPTS 53 +#define IPV6_HOPOPTS 54 +#define IPV6_RTHDRDSTOPTS 55 +#define IPV6_RECVRTHDR 56 +#define IPV6_RTHDR 57 +#define IPV6_RECVDSTOPTS 58 +#define IPV6_DSTOPTS 59 + +#define IPV6_RECVTCLASS 66 +#define IPV6_TCLASS 67 + +/* Obsolete synonyms for the above. */ +#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP +#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP +#define IPV6_RXHOPOPTS IPV6_HOPOPTS +#define IPV6_RXDSTOPTS IPV6_DSTOPTS + +/* IPV6_MTU_DISCOVER values. */ +#define IPV6_PMTUDISC_DONT 0 /* Never send DF frames. */ +#define IPV6_PMTUDISC_WANT 1 /* Use per route hints. */ +#define IPV6_PMTUDISC_DO 2 /* Always DF. */ + +/* Socket level values for IPv6. */ +#define SOL_IPV6 41 +#define SOL_ICMPV6 58 + +/* Routing header options for IPv6. */ +#define IPV6_RTHDR_LOOSE 0 /* Hop doesn't need to be neighbour. */ +#define IPV6_RTHDR_STRICT 1 /* Hop must be a neighbour. */ + +#define IPV6_RTHDR_TYPE_0 0 /* IPv6 Routing header type 0. */ diff --git a/conts/posix/libposix/include/posix/bits/inf.h b/conts/posix/libposix/include/posix/bits/inf.h new file mode 100644 index 0000000..1619f75 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/inf.h @@ -0,0 +1,30 @@ +/* `INFINITY' constant for IEEE 754 machines. + Copyright (C) 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + +/* IEEE positive infinity. */ + +#if __GNUC_PREREQ(3,3) +# define INFINITY (__builtin_inff()) +#else +# define INFINITY HUGE_VALF +#endif diff --git a/conts/posix/libposix/include/posix/bits/initspin.h b/conts/posix/libposix/include/posix/bits/initspin.h new file mode 100644 index 0000000..a19ec07 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/initspin.h @@ -0,0 +1,28 @@ +/* Generic definitions for spinlock initializers. + Copyright (C) 2000, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* Initial value of a spinlock. Most platforms should use zero, + unless they only implement a "test and clear" operation instead of + the usual "test and set". */ +#define __LT_SPINLOCK_INIT 0 + +/* Macros for lock initializers, using the above definition. */ +#define __LOCK_INITIALIZER { 0, __LT_SPINLOCK_INIT } +#define __ALT_LOCK_INITIALIZER { 0, __LT_SPINLOCK_INIT } +#define __ATOMIC_INITIALIZER { 0, __LT_SPINLOCK_INIT } diff --git a/conts/posix/libposix/include/posix/bits/ioctl-types.h b/conts/posix/libposix/include/posix/bits/ioctl-types.h new file mode 100644 index 0000000..e856a04 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/ioctl-types.h @@ -0,0 +1,78 @@ +/* Structure types for pre-termios terminal ioctls. Linux version. + Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_IOCTL_H +# error "Never use directly; include instead." +#endif + +/* Get definition of constants for use with `ioctl'. */ +#include + + +struct winsize + { + unsigned short int ws_row; + unsigned short int ws_col; + unsigned short int ws_xpixel; + unsigned short int ws_ypixel; + }; + +#define NCC 8 +struct termio + { + unsigned short int c_iflag; /* input mode flags */ + unsigned short int c_oflag; /* output mode flags */ + unsigned short int c_cflag; /* control mode flags */ + unsigned short int c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG + +/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ + +/* line disciplines */ +#define N_TTY 0 +#define N_SLIP 1 +#define N_MOUSE 2 +#define N_PPP 3 +#define N_STRIP 4 +#define N_AX25 5 +#define N_X25 6 /* X.25 async */ +#define N_6PACK 7 +#define N_MASC 8 /* Mobitex module */ +#define N_R3964 9 /* Simatic R3964 module */ +#define N_PROFIBUS_FDL 10 /* Profibus */ +#define N_IRDA 11 /* Linux IR */ +#define N_SMSBLOCK 12 /* SMS block mode */ +#define N_HDLC 13 /* synchronous HDLC */ +#define N_SYNC_PPP 14 /* synchronous PPP */ +#define N_HCI 15 /* Bluetooth HCI UART */ diff --git a/conts/posix/libposix/include/posix/bits/ioctls.h b/conts/posix/libposix/include/posix/bits/ioctls.h new file mode 100644 index 0000000..11bb4c4 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/ioctls.h @@ -0,0 +1,109 @@ +/* Copyright (C) 1996, 1997, 1998, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_IOCTL_H +# error "Never use directly; include instead." +#endif + +/* Use the definitions from the kernel header files. */ +#include + +/* Routing table calls. */ +#define SIOCADDRT 0x890B /* add routing table entry */ +#define SIOCDELRT 0x890C /* delete routing table entry */ +#define SIOCRTMSG 0x890D /* call to routing system */ + +/* Socket configuration controls. */ +#define SIOCGIFNAME 0x8910 /* get iface name */ +#define SIOCSIFLINK 0x8911 /* set iface channel */ +#define SIOCGIFCONF 0x8912 /* get iface list */ +#define SIOCGIFFLAGS 0x8913 /* get flags */ +#define SIOCSIFFLAGS 0x8914 /* set flags */ +#define SIOCGIFADDR 0x8915 /* get PA address */ +#define SIOCSIFADDR 0x8916 /* set PA address */ +#define SIOCGIFDSTADDR 0x8917 /* get remote PA address */ +#define SIOCSIFDSTADDR 0x8918 /* set remote PA address */ +#define SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */ +#define SIOCSIFBRDADDR 0x891a /* set broadcast PA address */ +#define SIOCGIFNETMASK 0x891b /* get network PA mask */ +#define SIOCSIFNETMASK 0x891c /* set network PA mask */ +#define SIOCGIFMETRIC 0x891d /* get metric */ +#define SIOCSIFMETRIC 0x891e /* set metric */ +#define SIOCGIFMEM 0x891f /* get memory address (BSD) */ +#define SIOCSIFMEM 0x8920 /* set memory address (BSD) */ +#define SIOCGIFMTU 0x8921 /* get MTU size */ +#define SIOCSIFMTU 0x8922 /* set MTU size */ +#define SIOCSIFNAME 0x8923 /* set interface name */ +#define SIOCSIFHWADDR 0x8924 /* set hardware address */ +#define SIOCGIFENCAP 0x8925 /* get/set encapsulations */ +#define SIOCSIFENCAP 0x8926 +#define SIOCGIFHWADDR 0x8927 /* Get hardware address */ +#define SIOCGIFSLAVE 0x8929 /* Driver slaving support */ +#define SIOCSIFSLAVE 0x8930 +#define SIOCADDMULTI 0x8931 /* Multicast address lists */ +#define SIOCDELMULTI 0x8932 +#define SIOCGIFINDEX 0x8933 /* name -> if_index mapping */ +#define SIOGIFINDEX SIOCGIFINDEX /* misprint compatibility :-) */ +#define SIOCSIFPFLAGS 0x8934 /* set/get extended flags set */ +#define SIOCGIFPFLAGS 0x8935 +#define SIOCDIFADDR 0x8936 /* delete PA address */ +#define SIOCSIFHWBROADCAST 0x8937 /* set hardware broadcast addr */ +#define SIOCGIFCOUNT 0x8938 /* get number of devices */ + +#define SIOCGIFBR 0x8940 /* Bridging support */ +#define SIOCSIFBR 0x8941 /* Set bridging options */ + +#define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */ +#define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */ + + +/* ARP cache control calls. */ + /* 0x8950 - 0x8952 * obsolete calls, don't re-use */ +#define SIOCDARP 0x8953 /* delete ARP table entry */ +#define SIOCGARP 0x8954 /* get ARP table entry */ +#define SIOCSARP 0x8955 /* set ARP table entry */ + +/* RARP cache control calls. */ +#define SIOCDRARP 0x8960 /* delete RARP table entry */ +#define SIOCGRARP 0x8961 /* get RARP table entry */ +#define SIOCSRARP 0x8962 /* set RARP table entry */ + +/* Driver configuration calls */ + +#define SIOCGIFMAP 0x8970 /* Get device parameters */ +#define SIOCSIFMAP 0x8971 /* Set device parameters */ + +/* DLCI configuration calls */ + +#define SIOCADDDLCI 0x8980 /* Create new DLCI device */ +#define SIOCDELDLCI 0x8981 /* Delete DLCI device */ + +/* Device private ioctl calls. */ + +/* These 16 ioctls are available to devices via the do_ioctl() device + vector. Each device should include this file and redefine these + names as their own. Because these are device dependent it is a good + idea _NOT_ to issue them to random objects and hope. */ + +#define SIOCDEVPRIVATE 0x89F0 /* to 89FF */ + +/* + * These 16 ioctl calls are protocol private + */ + +#define SIOCPROTOPRIVATE 0x89E0 /* to 89EF */ diff --git a/conts/posix/libposix/include/posix/bits/ipc.h b/conts/posix/libposix/include/posix/bits/ipc.h new file mode 100644 index 0000000..f1a043f --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/ipc.h @@ -0,0 +1,56 @@ +/* Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_IPC_H +# error "Never use directly; include instead." +#endif + +#include + +/* Mode bits for `msgget', `semget', and `shmget'. */ +#define IPC_CREAT 01000 /* Create key if key does not exist. */ +#define IPC_EXCL 02000 /* Fail if key exists. */ +#define IPC_NOWAIT 04000 /* Return error on wait. */ + +/* Control commands for `msgctl', `semctl', and `shmctl'. */ +#define IPC_RMID 0 /* Remove identifier. */ +#define IPC_SET 1 /* Set `ipc_perm' options. */ +#define IPC_STAT 2 /* Get `ipc_perm' options. */ +#ifdef __USE_GNU +# define IPC_INFO 3 /* See ipcs. */ +#endif + +/* Special key values. */ +#define IPC_PRIVATE ((__key_t) 0) /* Private key. */ + + +/* Data structure used to pass permission information to IPC operations. */ +struct ipc_perm + { + __key_t __key; /* Key. */ + __uid_t uid; /* Owner's user ID. */ + __gid_t gid; /* Owner's group ID. */ + __uid_t cuid; /* Creator's user ID. */ + __gid_t cgid; /* Creator's group ID. */ + unsigned short int mode; /* Read/write permission. */ + unsigned short int __pad1; + unsigned short int __seq; /* Sequence number. */ + unsigned short int __pad2; + unsigned long int __unused1; + unsigned long int __unused2; + }; diff --git a/conts/posix/libposix/include/posix/bits/kernel_sigaction.h b/conts/posix/libposix/include/posix/bits/kernel_sigaction.h new file mode 100644 index 0000000..2fdfc89 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/kernel_sigaction.h @@ -0,0 +1,68 @@ +#ifndef _BITS_SIGACTION_STRUCT_H +#define _BITS_SIGACTION_STRUCT_H + +/* This file provides whatever this particular arch's kernel thinks + * the sigaction struct should look like... */ + +#undef NO_OLD_SIGACTION + +#if defined(__mips__) +#undef HAVE_SA_RESTORER +/* This is the sigaction structure from the Linux 2.1.24 kernel. */ +#include +struct old_kernel_sigaction { + __sighandler_t k_sa_handler; + unsigned int sa_flags; + unsigned long sa_mask; +}; +#define _KERNEL_NSIG 128 +#define _KERNEL_NSIG_BPW 32 +#define _KERNEL_NSIG_WORDS (_KERNEL_NSIG / _KERNEL_NSIG_BPW) + +typedef struct { + unsigned long sig[_KERNEL_NSIG_WORDS]; +} kernel_sigset_t; + +/* This is the sigaction structure from the Linux 2.1.68 kernel. */ +struct kernel_sigaction { + unsigned int sa_flags; + __sighandler_t k_sa_handler; + kernel_sigset_t sa_mask; + void (*sa_restorer)(void); + int s_resv[1]; /* reserved */ +}; +#elif defined(__ia64__) +#define NO_OLD_SIGACTION +#undef HAVE_SA_RESTORER +struct kernel_sigaction { + __sighandler_t k_sa_handler; + unsigned long sa_flags; + sigset_t sa_mask; +}; +#else +#define HAVE_SA_RESTORER +/* This is the sigaction structure from the Linux 2.1.20 kernel. */ +struct old_kernel_sigaction { + __sighandler_t k_sa_handler; + unsigned long sa_mask; + unsigned long sa_flags; + void (*sa_restorer) (void); +}; +/* This is the sigaction structure from the Linux 2.1.68 kernel. */ +struct kernel_sigaction { + __sighandler_t k_sa_handler; + unsigned long sa_flags; + void (*sa_restorer) (void); + sigset_t sa_mask; +}; +#endif + +#ifndef NO_OLD_SIGACTION +extern int __syscall_sigaction (int, const struct old_kernel_sigaction *__unbounded, + struct old_kernel_sigaction *__unbounded) attribute_hidden; +#endif + +extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *__unbounded, + struct kernel_sigaction *__unbounded, size_t) attribute_hidden; + +#endif /* _BITS_SIGACTION_STRUCT_H */ diff --git a/conts/posix/libposix/include/posix/bits/kernel_stat.h b/conts/posix/libposix/include/posix/bits/kernel_stat.h new file mode 100644 index 0000000..b686c47 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/kernel_stat.h @@ -0,0 +1,76 @@ +#ifndef _BITS_STAT_STRUCT_H +#define _BITS_STAT_STRUCT_H + +#ifndef _LIBC +#error bits/kernel_stat.h is for internal uClibc use only! +#endif + +/* This file provides whatever this particular arch's kernel thinks + * struct kernel_stat should look like... It turns out each arch has a + * different opinion on the subject... */ + +#define STAT_HAVE_NSEC 1 + +struct kernel_stat { +#if defined(__ARMEB__) + unsigned short st_dev; + unsigned short __pad1; +#else + unsigned long st_dev; +#endif + unsigned long st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; +#if defined(__ARMEB__) + unsigned short st_rdev; + unsigned short __pad2; +#else + unsigned long st_rdev; +#endif + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + unsigned long st_atime; + unsigned long st_atime_nsec; + unsigned long st_mtime; + unsigned long st_mtime_nsec; + unsigned long st_ctime; + unsigned long st_ctime_nsec; + unsigned long __unused4; + unsigned long __unused5; +}; + +struct kernel_stat64 { + unsigned long long st_dev; + unsigned char __pad0[4]; + +#define _HAVE_STAT64___ST_INO + unsigned long __st_ino; + unsigned int st_mode; + unsigned int st_nlink; + unsigned long st_uid; + unsigned long st_gid; + + unsigned long long st_rdev; + unsigned char __pad3[4]; + + long long st_size; + unsigned long st_blksize; + unsigned long long st_blocks; /* Number 512-byte blocks allocated. */ + + unsigned long st_atime; + unsigned long st_atime_nsec; + unsigned long st_mtime; + unsigned long st_mtime_nsec; + unsigned long st_ctime; + unsigned long st_ctime_nsec; + unsigned long long st_ino; +#ifndef __ARM_EABI__ +} __attribute__((packed)); +#else +}; +#endif + +#endif /* _BITS_STAT_STRUCT_H */ diff --git a/conts/posix/libposix/include/posix/bits/kernel_types.h b/conts/posix/libposix/include/posix/bits/kernel_types.h new file mode 100644 index 0000000..d7a1b15 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/kernel_types.h @@ -0,0 +1,44 @@ +/* Note that we use the exact same include guard #define names + * as asm/posix_types.h. This will avoid gratuitous conflicts + * with the posix_types.h kernel header, and will ensure that + * our private content, and not the kernel header, will win. + * -Erik + */ +#ifndef __ARCH_ARM_POSIX_TYPES_H +#define __ARCH_ARM_POSIX_TYPES_H + +typedef unsigned short __kernel_dev_t; +typedef unsigned long __kernel_ino_t; +typedef unsigned short __kernel_mode_t; +typedef unsigned short __kernel_nlink_t; +typedef long __kernel_off_t; +typedef int __kernel_pid_t; +typedef unsigned short __kernel_ipc_pid_t; +typedef unsigned short __kernel_uid_t; +typedef unsigned short __kernel_gid_t; +typedef unsigned int __kernel_size_t; +typedef int __kernel_ssize_t; +typedef int __kernel_ptrdiff_t; +typedef long __kernel_time_t; +typedef long __kernel_suseconds_t; +typedef long __kernel_clock_t; +typedef int __kernel_daddr_t; +typedef char * __kernel_caddr_t; +typedef unsigned short __kernel_uid16_t; +typedef unsigned short __kernel_gid16_t; +typedef unsigned int __kernel_uid32_t; +typedef unsigned int __kernel_gid32_t; +typedef unsigned short __kernel_old_uid_t; +typedef unsigned short __kernel_old_gid_t; +typedef long long __kernel_loff_t; +typedef __kernel_dev_t __kernel_old_dev_t; + +typedef struct { +#ifdef __USE_ALL + int val[2]; +#else + int __val[2]; +#endif +} __kernel_fsid_t; + +#endif /* __ARCH_ARM_POSIX_TYPES_H */ diff --git a/conts/posix/libposix/include/posix/bits/local_lim.h b/conts/posix/libposix/include/posix/bits/local_lim.h new file mode 100644 index 0000000..023ebf3 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/local_lim.h @@ -0,0 +1,87 @@ +/* Minimum guaranteed maximum values for system limits. Linux version. + Copyright (C) 1993-1998,2000,2002,2003,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* The kernel header pollutes the namespace with the NR_OPEN symbol + and defines LINK_MAX although filesystems have different maxima. A + similar thing is true for OPEN_MAX: the limit can be changed at + runtime and therefore the macro must not be defined. Remove this + after including the header if necessary. */ +#ifndef NR_OPEN +# define __undef_NR_OPEN +#endif +#ifndef LINK_MAX +# define __undef_LINK_MAX +#endif +#ifndef OPEN_MAX +# define __undef_OPEN_MAX +#endif + +/* The kernel sources contain a file with all the needed information. */ +#include + +/* Have to remove NR_OPEN? */ +#ifdef __undef_NR_OPEN +# undef NR_OPEN +# undef __undef_NR_OPEN +#endif +/* Have to remove LINK_MAX? */ +#ifdef __undef_LINK_MAX +# undef LINK_MAX +# undef __undef_LINK_MAX +#endif +/* Have to remove OPEN_MAX? */ +#ifdef __undef_OPEN_MAX +# undef OPEN_MAX +# undef __undef_OPEN_MAX +#endif + +/* The number of data keys per process. */ +#define _POSIX_THREAD_KEYS_MAX 128 +/* This is the value this implementation supports. */ +#define PTHREAD_KEYS_MAX 1024 + +/* Controlling the iterations of destructors for thread-specific data. */ +#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 +/* Number of iterations this implementation does. */ +#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS + +/* The number of threads per process. */ +#define _POSIX_THREAD_THREADS_MAX 64 + +/* Maximum amount by which a process can descrease its asynchronous I/O + priority level. */ +#define AIO_PRIO_DELTA_MAX 20 + +/* Minimum size for a thread. We are free to choose a reasonable value. */ +#define PTHREAD_STACK_MIN 16384 + +/* Maximum number of timer expiration overruns. */ +#define DELAYTIMER_MAX 2147483647 + +/* Maximum tty name length. */ +#define TTY_NAME_MAX 32 + +/* Maximum login name length. This is arbitrary. */ +#define LOGIN_NAME_MAX 256 + +/* Maximum host name length. */ +#define HOST_NAME_MAX 64 + +/* Maximum message queue priority level. */ +#define MQ_PRIO_MAX 32768 diff --git a/conts/posix/libposix/include/posix/bits/locale.h b/conts/posix/libposix/include/posix/bits/locale.h new file mode 100644 index 0000000..5d51783 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/locale.h @@ -0,0 +1,46 @@ +/* Definition of locale category symbol values. + Copyright (C) 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#if !defined _LOCALE_H && !defined _LANGINFO_H +# error "Never use directly; include instead." +#endif + +#ifndef _BITS_LOCALE_H +#define _BITS_LOCALE_H 1 + +enum +{ + __LC_CTYPE = 0, + __LC_NUMERIC = 1, + __LC_TIME = 2, + __LC_COLLATE = 3, + __LC_MONETARY = 4, + __LC_MESSAGES = 5, + __LC_ALL = 6, +#if 0 + __LC_PAPER = 7, + __LC_NAME = 8, + __LC_ADDRESS = 9, + __LC_TELEPHONE = 10, + __LC_MEASUREMENT = 11, + __LC_IDENTIFICATION = 12 +#endif +}; + +#endif /* bits/locale.h */ diff --git a/conts/posix/libposix/include/posix/bits/mathcalls.h b/conts/posix/libposix/include/posix/bits/mathcalls.h new file mode 100644 index 0000000..c020072 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/mathcalls.h @@ -0,0 +1,365 @@ +/* Prototype declarations for math functions; helper file for . + Copyright (C) 1996-2002, 2003, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* NOTE: Because of the special way this file is used by , this + file must NOT be protected from multiple inclusion as header files + usually are. + + This file provides prototype declarations for the math functions. + Most functions are declared using the macro: + + __MATHCALL (NAME,[_r], (ARGS...)); + + This means there is a function `NAME' returning `double' and a function + `NAMEf' returning `float'. Each place `_Mdouble_' appears in the + prototype, that is actually `double' in the prototype for `NAME' and + `float' in the prototype for `NAMEf'. Reentrant variant functions are + called `NAME_r' and `NAMEf_r'. + + Functions returning other types like `int' are declared using the macro: + + __MATHDECL (TYPE, NAME,[_r], (ARGS...)); + + This is just like __MATHCALL but for a function returning `TYPE' + instead of `_Mdouble_'. In all of these cases, there is still + both a `NAME' and a `NAMEf' that takes `float' arguments. + + Note that there must be no whitespace before the argument passed for + NAME, to make token pasting work with -traditional. */ + +#ifndef _MATH_H +# error "Never include directly; include instead." +#endif + + +/* Trigonometric functions. */ + +_Mdouble_BEGIN_NAMESPACE +/* Arc cosine of X. */ +__MATHCALL (acos,, (_Mdouble_ __x)); +/* Arc sine of X. */ +__MATHCALL (asin,, (_Mdouble_ __x)); +/* Arc tangent of X. */ +__MATHCALL (atan,, (_Mdouble_ __x)); +/* Arc tangent of Y/X. */ +__MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x)); + +/* Cosine of X. */ +__MATHCALL (cos,, (_Mdouble_ __x)); +/* Sine of X. */ +__MATHCALL (sin,, (_Mdouble_ __x)); +/* Tangent of X. */ +__MATHCALL (tan,, (_Mdouble_ __x)); + +/* Hyperbolic functions. */ + +/* Hyperbolic cosine of X. */ +__MATHCALL (cosh,, (_Mdouble_ __x)); +/* Hyperbolic sine of X. */ +__MATHCALL (sinh,, (_Mdouble_ __x)); +/* Hyperbolic tangent of X. */ +__MATHCALL (tanh,, (_Mdouble_ __x)); +_Mdouble_END_NAMESPACE + +#if 0 /*def __USE_GNU*/ +/* Cosine and sine of X. */ +__MATHDECL (void,sincos,, + (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx)); +#endif + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +/* Hyperbolic arc cosine of X. */ +__MATHCALL (acosh,, (_Mdouble_ __x)); +/* Hyperbolic arc sine of X. */ +__MATHCALL (asinh,, (_Mdouble_ __x)); +/* Hyperbolic arc tangent of X. */ +__MATHCALL (atanh,, (_Mdouble_ __x)); +__END_NAMESPACE_C99 +#endif + +/* Exponential and logarithmic functions. */ + +_Mdouble_BEGIN_NAMESPACE +/* Exponential function of X. */ +__MATHCALL (exp,, (_Mdouble_ __x)); + +/* Break VALUE into a normalized fraction and an integral power of 2. */ +__MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent)); + +/* X times (two to the EXP power). */ +__MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent)); + +/* Natural logarithm of X. */ +__MATHCALL (log,, (_Mdouble_ __x)); + +/* Base-ten logarithm of X. */ +__MATHCALL (log10,, (_Mdouble_ __x)); + +/* Break VALUE into integral and fractional parts. */ +__MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr)); +_Mdouble_END_NAMESPACE + +#if 0 /*def __USE_GNU*/ +/* A function missing in all standards: compute exponent to base ten. */ +__MATHCALL (exp10,, (_Mdouble_ __x)); +/* Another name occasionally used. */ +__MATHCALL (pow10,, (_Mdouble_ __x)); +#endif + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +/* Return exp(X) - 1. */ +__MATHCALL (expm1,, (_Mdouble_ __x)); + +/* Return log(1 + X). */ +__MATHCALL (log1p,, (_Mdouble_ __x)); + +/* Return the base 2 signed integral exponent of X. */ +__MATHCALL (logb,, (_Mdouble_ __x)); +__END_NAMESPACE_C99 +#endif + +#ifdef __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +/* Compute base-2 exponential of X. */ +__MATHCALL (exp2,, (_Mdouble_ __x)); + +/* Compute base-2 logarithm of X. */ +__MATHCALL (log2,, (_Mdouble_ __x)); +__END_NAMESPACE_C99 +#endif + + +/* Power functions. */ + +_Mdouble_BEGIN_NAMESPACE +/* Return X to the Y power. */ +__MATHCALL (pow,, (_Mdouble_ __x, _Mdouble_ __y)); + +/* Return the square root of X. */ +__MATHCALL (sqrt,, (_Mdouble_ __x)); +_Mdouble_END_NAMESPACE + +#if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +/* Return `sqrt(X*X + Y*Y)'. */ +__MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y)); +__END_NAMESPACE_C99 +#endif + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +/* Return the cube root of X. */ +__MATHCALL (cbrt,, (_Mdouble_ __x)); +__END_NAMESPACE_C99 +#endif + + +/* Nearest integer, absolute value, and remainder functions. */ + +_Mdouble_BEGIN_NAMESPACE +/* Smallest integral value not less than X. */ +__MATHCALLX (ceil,, (_Mdouble_ __x), (__const__)); + +/* Absolute value of X. */ +__MATHCALLX (fabs,, (_Mdouble_ __x), (__const__)); + +/* Largest integer not greater than X. */ +__MATHCALLX (floor,, (_Mdouble_ __x), (__const__)); + +/* Floating-point modulo remainder of X/Y. */ +__MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y)); + + +/* Return 0 if VALUE is finite or NaN, +1 if it + is +Infinity, -1 if it is -Infinity. */ +__MATHDECL_1 (int,__isinf,, (_Mdouble_ __value)) __attribute__ ((__const__)); + +/* Return nonzero if VALUE is finite and not NaN. */ +__MATHDECL_1 (int,__finite,, (_Mdouble_ __value)) __attribute__ ((__const__)); +_Mdouble_END_NAMESPACE + +#ifdef __USE_MISC +/* Return 0 if VALUE is finite or NaN, +1 if it + is +Infinity, -1 if it is -Infinity. */ +__MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__)); + +/* Return nonzero if VALUE is finite and not NaN. */ +__MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__)); + +/* Return the remainder of X/Y. */ +__MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y)); + + +/* Return the fractional part of X after dividing out `ilogb (X)'. */ +__MATHCALL (significand,, (_Mdouble_ __x)); +#endif /* Use misc. */ + +#if defined __USE_MISC || defined __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +/* Return X with its signed changed to Y's. */ +__MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); +__END_NAMESPACE_C99 +#endif + +#ifdef __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +/* Return representation of NaN for double type. */ +__MATHCALLX (nan,, (__const char *__tagb), (__const__)); +__END_NAMESPACE_C99 +#endif + + +/* Return nonzero if VALUE is not a number. */ +__MATHDECL_1 (int,__isnan,, (_Mdouble_ __value)) __attribute__ ((__const__)); + +#if defined __USE_MISC || defined __USE_XOPEN +/* Return nonzero if VALUE is not a number. */ +__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__)); + +/* Bessel functions. */ +__MATHCALL (j0,, (_Mdouble_)); +__MATHCALL (j1,, (_Mdouble_)); +__MATHCALL (jn,, (int, _Mdouble_)); +__MATHCALL (y0,, (_Mdouble_)); +__MATHCALL (y1,, (_Mdouble_)); +__MATHCALL (yn,, (int, _Mdouble_)); +#endif + + +#if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +/* Error and gamma functions. */ +__MATHCALL (erf,, (_Mdouble_)); +__MATHCALL (erfc,, (_Mdouble_)); +__MATHCALL (lgamma,, (_Mdouble_)); +__END_NAMESPACE_C99 +#endif + +#ifdef __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +/* True gamma function. */ +__MATHCALL (tgamma,, (_Mdouble_)); +__END_NAMESPACE_C99 +#endif + +#if defined __USE_MISC || defined __USE_XOPEN +/* Obsolete alias for `lgamma'. */ +__MATHCALL (gamma,, (_Mdouble_)); +#endif + +#ifdef __USE_MISC +/* Reentrant version of lgamma. This function uses the global variable + `signgam'. The reentrant version instead takes a pointer and stores + the value through it. */ +__MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp)); +#endif + + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +/* Return the integer nearest X in the direction of the + prevailing rounding mode. */ +__MATHCALL (rint,, (_Mdouble_ __x)); + +/* Return X + epsilon if X < Y, X - epsilon if X > Y. */ +__MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__)); +# if defined __USE_ISOC99 && !defined __LDBL_COMPAT +__MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__)); +# endif + +/* Return the remainder of integer divison X / Y with infinite precision. */ +__MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y)); + +# if defined __USE_MISC || defined __USE_ISOC99 +/* Return X times (2 to the Nth power). */ +__MATHCALL (scalbn,, (_Mdouble_ __x, int __n)); +# endif + +/* Return the binary exponent of X, which must be nonzero. */ +__MATHDECL (int,ilogb,, (_Mdouble_ __x)); +#endif + +#ifdef __USE_ISOC99 +/* Return X times (2 to the Nth power). */ +__MATHCALL (scalbln,, (_Mdouble_ __x, long int __n)); + +/* Round X to integral value in floating-point format using current + rounding direction, but do not raise inexact exception. */ +__MATHCALL (nearbyint,, (_Mdouble_ __x)); + +/* Round X to nearest integral value, rounding halfway cases away from + zero. */ +__MATHCALLX (round,, (_Mdouble_ __x), (__const__)); + +/* Round X to the integral value in floating-point format nearest but + not larger in magnitude. */ +__MATHCALLX (trunc,, (_Mdouble_ __x), (__const__)); + +/* Compute remainder of X and Y and put in *QUO a value with sign of x/y + and magnitude congruent `mod 2^n' to the magnitude of the integral + quotient x/y, with n >= 3. */ +__MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo)); + + +/* Conversion functions. */ + +/* Round X to nearest integral value according to current rounding + direction. */ +__MATHDECL (long int,lrint,, (_Mdouble_ __x)); +__MATHDECL (long long int,llrint,, (_Mdouble_ __x)); + +/* Round X to nearest integral value, rounding halfway cases away from + zero. */ +__MATHDECL (long int,lround,, (_Mdouble_ __x)); +__MATHDECL (long long int,llround,, (_Mdouble_ __x)); + + +/* Return positive difference between X and Y. */ +__MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y)); + +/* Return maximum numeric value from X and Y. */ +__MATHCALL (fmax,, (_Mdouble_ __x, _Mdouble_ __y)); + +/* Return minimum numeric value from X and Y. */ +__MATHCALL (fmin,, (_Mdouble_ __x, _Mdouble_ __y)); + + +/* Classify given number. */ +__MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value)) + __attribute__ ((__const__)); + +/* Test for negative number. */ +__MATHDECL_1 (int, __signbit,, (_Mdouble_ __value)) + __attribute__ ((__const__)); + + +/* Multiply-add function computed as a ternary operation. */ +__MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z)); +#endif /* Use ISO C99. */ + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99 +__END_NAMESPACE_C99 +#endif + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +/* Return X times (2 to the Nth power). */ +__MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n)); +#endif diff --git a/conts/posix/libposix/include/posix/bits/mathdef.h b/conts/posix/libposix/include/posix/bits/mathdef.h new file mode 100644 index 0000000..e013e74 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/mathdef.h @@ -0,0 +1,44 @@ +/* Copyright (C) 1999, 2000, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#if !defined _MATH_H && !defined _COMPLEX_H +# error "Never use directly; include instead" +#endif + +#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF +# define _MATH_H_MATHDEF 1 + +/* GCC does not promote `float' values to `double'. */ +typedef float float_t; /* `float' expressions are evaluated as + `float'. */ +typedef double double_t; /* `double' expressions are evaluated as + `double'. */ + +/* The values returned by `ilogb' for 0 and NaN respectively. */ +# define FP_ILOGB0 (-2147483647) +# define FP_ILOGBNAN (2147483647) + +#endif /* ISO C99 */ + +#ifndef __NO_LONG_DOUBLE_MATH +/* Signal that we do not really have a `long double'. This disables the + declaration of all the `long double' function variants. */ +/* XXX The FPA does support this but the patterns in GCC are currently + turned off. */ +# define __NO_LONG_DOUBLE_MATH 1 +#endif diff --git a/conts/posix/libposix/include/posix/bits/mathinline.h b/conts/posix/libposix/include/posix/bits/mathinline.h new file mode 100644 index 0000000..5498af6 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/mathinline.h @@ -0,0 +1,12 @@ +/* This file should provide inline versions of math functions. + + Surround GCC-specific parts with #ifdef __GNUC__, and use `extern __inline'. + + This file should define __MATH_INLINES if functions are actually defined as + inlines. */ + +#if !defined __NO_MATH_INLINES && defined __OPTIMIZE__ + +/* Here goes the real code. */ + +#endif diff --git a/conts/posix/libposix/include/posix/bits/mman.h b/conts/posix/libposix/include/posix/bits/mman.h new file mode 100644 index 0000000..828ec94 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/mman.h @@ -0,0 +1,103 @@ +/* Definitions for POSIX memory map interface. Linux/ARM version. + Copyright (C) 1997, 2000, 2003, 2005, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_MMAN_H +# error "Never use directly; include instead." +#endif + +/* The following definitions basically come from the kernel headers. + But the kernel header is not namespace clean. */ + + +/* Protections are chosen from these bits, OR'd together. The + implementation does not necessarily support PROT_EXEC or PROT_WRITE + without PROT_READ. The only guarantees are that no writing will be + allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */ + +#define PROT_READ 0x1 /* Page can be read. */ +#define PROT_WRITE 0x2 /* Page can be written. */ +#define PROT_EXEC 0x4 /* Page can be executed. */ +#define PROT_NONE 0x0 /* Page can not be accessed. */ +#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of + growsdown vma (mprotect only). */ +#define PROT_GROWSUP 0x02000000 /* Extend change to start of + growsup vma (mprotect only). */ + +/* Sharing types (must choose one and only one of these). */ +#define MAP_SHARED 0x01 /* Share changes. */ +#define MAP_PRIVATE 0x02 /* Changes are private. */ +#ifdef __USE_MISC +# define MAP_TYPE 0x0f /* Mask for type of mapping. */ +#endif + +/* Other flags. */ +#define MAP_FIXED 0x10 /* Interpret addr exactly. */ +#ifdef __USE_MISC +# define MAP_FILE 0 +# define MAP_ANONYMOUS 0x20 /* Don't use a file. */ +# define MAP_ANON MAP_ANONYMOUS +#endif + +/* These are Linux-specific. */ +#ifdef __USE_MISC +# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */ +# define MAP_DENYWRITE 0x00800 /* ETXTBSY */ +# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */ +# define MAP_LOCKED 0x02000 /* Lock the mapping. */ +# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */ +# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */ +# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */ +#endif + +/* Flags to `msync'. */ +#define MS_ASYNC 1 /* Sync memory asynchronously. */ +#define MS_SYNC 4 /* Synchronous memory sync. */ +#define MS_INVALIDATE 2 /* Invalidate the caches. */ + +/* Flags for `mlockall'. */ +#define MCL_CURRENT 1 /* Lock all currently mapped pages. */ +#define MCL_FUTURE 2 /* Lock all additions to address + space. */ + +/* Flags for `mremap'. */ +#ifdef __USE_GNU +# define MREMAP_MAYMOVE 1 +# define MREMAP_FIXED 2 +#endif + +/* Advice to `madvise'. */ +#ifdef __USE_BSD +# define MADV_NORMAL 0 /* No further special treatment. */ +# define MADV_RANDOM 1 /* Expect random page references. */ +# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */ +# define MADV_WILLNEED 3 /* Will need these pages. */ +# define MADV_DONTNEED 4 /* Don't need these pages. */ +# define MADV_REMOVE 9 /* Remove these pages and resources. */ +# define MADV_DONTFORK 10 /* Do not inherit across fork. */ +# define MADV_DOFORK 11 /* Do inherit across fork. */ +#endif + +/* The POSIX people had to invent similar names for the same things. */ +#ifdef __USE_XOPEN2K +# define POSIX_MADV_NORMAL 0 /* No further special treatment. */ +# define POSIX_MADV_RANDOM 1 /* Expect random page references. */ +# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */ +# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */ +# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */ +#endif diff --git a/conts/posix/libposix/include/posix/bits/mqueue.h b/conts/posix/libposix/include/posix/bits/mqueue.h new file mode 100644 index 0000000..df528f8 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/mqueue.h @@ -0,0 +1,32 @@ +/* Copyright (C) 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _MQUEUE_H +# error "Never use directly; include instead." +#endif + +typedef int mqd_t; + +struct mq_attr +{ + long int mq_flags; /* Message queue flags. */ + long int mq_maxmsg; /* Maximum number of messages. */ + long int mq_msgsize; /* Maximum message size. */ + long int mq_curmsgs; /* Number of messages currently queued. */ + long int __pad[4]; +}; diff --git a/conts/posix/libposix/include/posix/bits/msq.h b/conts/posix/libposix/include/posix/bits/msq.h new file mode 100644 index 0000000..32a49b5 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/msq.h @@ -0,0 +1,77 @@ +/* Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_MSG_H +# error "Never use directly; include instead." +#endif + +#include + +/* Define options for message queue functions. */ +#define MSG_NOERROR 010000 /* no error if message is too big */ +#ifdef __USE_GNU +# define MSG_EXCEPT 020000 /* recv any msg except of specified type */ +#endif + +/* Types used in the structure definition. */ +typedef unsigned long int msgqnum_t; +typedef unsigned long int msglen_t; + + +/* Structure of record for one message inside the kernel. + The type `struct msg' is opaque. */ +struct msqid_ds +{ + struct ipc_perm msg_perm; /* structure describing operation permission */ + __time_t msg_stime; /* time of last msgsnd command */ + unsigned long int __unused1; + __time_t msg_rtime; /* time of last msgrcv command */ + unsigned long int __unused2; + __time_t msg_ctime; /* time of last change */ + unsigned long int __unused3; + unsigned long int __msg_cbytes; /* current number of bytes on queue */ + msgqnum_t msg_qnum; /* number of messages currently on queue */ + msglen_t msg_qbytes; /* max number of bytes allowed on queue */ + __pid_t msg_lspid; /* pid of last msgsnd() */ + __pid_t msg_lrpid; /* pid of last msgrcv() */ + unsigned long int __unused4; + unsigned long int __unused5; +}; + +#ifdef __USE_MISC + +# define msg_cbytes __msg_cbytes + +/* ipcs ctl commands */ +# define MSG_STAT 11 +# define MSG_INFO 12 + +/* buffer for msgctl calls IPC_INFO, MSG_INFO */ +struct msginfo + { + int msgpool; + int msgmap; + int msgmax; + int msgmnb; + int msgmni; + int msgssz; + int msgtql; + unsigned short int msgseg; + }; + +#endif /* __USE_MISC */ diff --git a/conts/posix/libposix/include/posix/bits/nan.h b/conts/posix/libposix/include/posix/bits/nan.h new file mode 100644 index 0000000..bae97f2 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/nan.h @@ -0,0 +1,53 @@ +/* `NAN' constant for IEEE 754 machines. + Copyright (C) 1992,1996,1997,1999,2004,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _MATH_H +# error "Never use directly; include instead." +#endif + + +/* IEEE Not A Number. */ + +#if __GNUC_PREREQ(3,3) + +# define NAN (__builtin_nanf ("")) + +#elif defined __GNUC__ + +# define NAN \ + (__extension__ \ + ((union { unsigned __l __attribute__ ((__mode__ (__SI__))); float __d; }) \ + { __l: 0x7fc00000UL }).__d) + +#else + +# include + +# if __BYTE_ORDER == __BIG_ENDIAN +# define __nan_bytes { 0x7f, 0xc0, 0, 0 } +# endif +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define __nan_bytes { 0, 0, 0xc0, 0x7f } +# endif + +static union { unsigned char __c[4]; float __d; } __nan_union + __attribute_used__ = { __nan_bytes }; +# define NAN (__nan_union.__d) + +#endif /* GCC. */ diff --git a/conts/posix/libposix/include/posix/bits/netdb.h b/conts/posix/libposix/include/posix/bits/netdb.h new file mode 100644 index 0000000..41dc731 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/netdb.h @@ -0,0 +1,33 @@ +/* Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NETDB_H +# error "Never include directly; use instead." +#endif + + +/* Description of data base entry for a single network. NOTE: here a + poor assumption is made. The network number is expected to fit + into an unsigned long int variable. */ +struct netent +{ + char *n_name; /* Official name of network. */ + char **n_aliases; /* Alias list. */ + int n_addrtype; /* Net address type. */ + uint32_t n_net; /* Network number. */ +}; diff --git a/conts/posix/libposix/include/posix/bits/poll.h b/conts/posix/libposix/include/posix/bits/poll.h new file mode 100644 index 0000000..d7996b4 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/poll.h @@ -0,0 +1,50 @@ +/* Copyright (C) 1997, 2001, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_POLL_H +# error "Never use directly; include instead." +#endif + +/* Event types that can be polled for. These bits may be set in `events' + to indicate the interesting event types; they will appear in `revents' + to indicate the status of the file descriptor. */ +#define POLLIN 0x001 /* There is data to read. */ +#define POLLPRI 0x002 /* There is urgent data to read. */ +#define POLLOUT 0x004 /* Writing now will not block. */ + +#ifdef __USE_XOPEN +/* These values are defined in XPG4.2. */ +# define POLLRDNORM 0x040 /* Normal data may be read. */ +# define POLLRDBAND 0x080 /* Priority data may be read. */ +# define POLLWRNORM 0x100 /* Writing now will not block. */ +# define POLLWRBAND 0x200 /* Priority data may be written. */ +#endif + +#ifdef __USE_GNU +/* These are extensions for Linux. */ +# define POLLMSG 0x400 +# define POLLREMOVE 0x1000 +# define POLLRDHUP 0x2000 +#endif + +/* Event types always implicitly polled for. These bits need not be set in + `events', but they will appear in `revents' to indicate the status of + the file descriptor. */ +#define POLLERR 0x008 /* Error condition. */ +#define POLLHUP 0x010 /* Hung up. */ +#define POLLNVAL 0x020 /* Invalid polling request. */ diff --git a/conts/posix/libposix/include/posix/bits/posix1_lim.h b/conts/posix/libposix/include/posix/bits/posix1_lim.h new file mode 100644 index 0000000..3c86dce --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/posix1_lim.h @@ -0,0 +1,169 @@ +/* Copyright (C) 1991-1993,96,98,2000-2003,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * POSIX Standard: 2.9.2 Minimum Values Added to + * + * Never include this file directly; use instead. + */ + +#ifndef _BITS_POSIX1_LIM_H +#define _BITS_POSIX1_LIM_H 1 + + +/* These are the standard-mandated minimum values. */ + +/* Minimum number of operations in one list I/O call. */ +#define _POSIX_AIO_LISTIO_MAX 2 + +/* Minimal number of outstanding asynchronous I/O operations. */ +#define _POSIX_AIO_MAX 1 + +/* Maximum length of arguments to `execve', including environment. */ +#define _POSIX_ARG_MAX 4096 + +/* Maximum simultaneous processes per real user ID. */ +#ifdef __USE_XOPEN2K +# define _POSIX_CHILD_MAX 25 +#else +# define _POSIX_CHILD_MAX 6 +#endif + +/* Minimal number of timer expiration overruns. */ +#define _POSIX_DELAYTIMER_MAX 32 + +/* Maximum length of a host name (not including the terminating null) + as returned from the GETHOSTNAME function. */ +#define _POSIX_HOST_NAME_MAX 255 + +/* Maximum link count of a file. */ +#define _POSIX_LINK_MAX 8 + +/* Maximum length of login name. */ +#define _POSIX_LOGIN_NAME_MAX 9 + +/* Number of bytes in a terminal canonical input queue. */ +#define _POSIX_MAX_CANON 255 + +/* Number of bytes for which space will be + available in a terminal input queue. */ +#define _POSIX_MAX_INPUT 255 + +/* Maximum number of message queues open for a process. */ +#define _POSIX_MQ_OPEN_MAX 8 + +/* Maximum number of supported message priorities. */ +#define _POSIX_MQ_PRIO_MAX 32 + +/* Number of bytes in a filename. */ +#define _POSIX_NAME_MAX 14 + +/* Number of simultaneous supplementary group IDs per process. */ +#ifdef __USE_XOPEN2K +# define _POSIX_NGROUPS_MAX 8 +#else +# define _POSIX_NGROUPS_MAX 0 +#endif + +/* Number of files one process can have open at once. */ +#ifdef __USE_XOPEN2K +# define _POSIX_OPEN_MAX 20 +#else +# define _POSIX_OPEN_MAX 16 +#endif + +/* Number of descriptors that a process may examine with `pselect' or + `select'. */ +#define _POSIX_FD_SETSIZE _POSIX_OPEN_MAX + +/* Number of bytes in a pathname. */ +#define _POSIX_PATH_MAX 256 + +/* Number of bytes than can be written atomically to a pipe. */ +#define _POSIX_PIPE_BUF 512 + +/* The number of repeated occurrences of a BRE permitted by the + REGEXEC and REGCOMP functions when using the interval notation. */ +#define _POSIX_RE_DUP_MAX 255 + +/* Minimal number of realtime signals reserved for the application. */ +#define _POSIX_RTSIG_MAX 8 + +/* Number of semaphores a process can have. */ +#define _POSIX_SEM_NSEMS_MAX 256 + +/* Maximal value of a semaphore. */ +#define _POSIX_SEM_VALUE_MAX 32767 + +/* Number of pending realtime signals. */ +#define _POSIX_SIGQUEUE_MAX 32 + +/* Largest value of a `ssize_t'. */ +#define _POSIX_SSIZE_MAX 32767 + +/* Number of streams a process can have open at once. */ +#define _POSIX_STREAM_MAX 8 + +/* The number of bytes in a symbolic link. */ +#define _POSIX_SYMLINK_MAX 255 + +/* The number of symbolic links that can be traversed in the + resolution of a pathname in the absence of a loop. */ +#define _POSIX_SYMLOOP_MAX 8 + +/* Number of timer for a process. */ +#define _POSIX_TIMER_MAX 32 + +/* Maximum number of characters in a tty name. */ +#define _POSIX_TTY_NAME_MAX 9 + +/* Maximum length of a timezone name (element of `tzname'). */ +#define _POSIX_TZNAME_MAX 6 + +/* Maximum number of connections that can be queued on a socket. */ +#define _POSIX_QLIMIT 1 + +/* Maximum number of bytes that can be buffered on a socket for send + or receive. */ +#define _POSIX_HIWAT _POSIX_PIPE_BUF + +/* Maximum number of elements in an `iovec' array. */ +#define _POSIX_UIO_MAXIOV 16 + +/* Maximum clock resolution in nanoseconds. */ +#define _POSIX_CLOCKRES_MIN 20000000 + + +/* Get the implementation-specific values for the above. */ +#include +#include + + +#ifndef SSIZE_MAX +# define SSIZE_MAX LONG_MAX +#endif + + +/* This value is a guaranteed minimum maximum. + The current maximum can be got from `sysconf'. */ + +#ifndef NGROUPS_MAX +# define NGROUPS_MAX 8 +#endif + +#endif /* bits/posix1_lim.h */ diff --git a/conts/posix/libposix/include/posix/bits/posix2_lim.h b/conts/posix/libposix/include/posix/bits/posix2_lim.h new file mode 100644 index 0000000..24483a0 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/posix2_lim.h @@ -0,0 +1,91 @@ +/* Copyright (C) 1991, 1996, 1999, 2000, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * Never include this file directly; include instead. + */ + +#ifndef _BITS_POSIX2_LIM_H +#define _BITS_POSIX2_LIM_H 1 + + +/* The maximum `ibase' and `obase' values allowed by the `bc' utility. */ +#define _POSIX2_BC_BASE_MAX 99 + +/* The maximum number of elements allowed in an array by the `bc' utility. */ +#define _POSIX2_BC_DIM_MAX 2048 + +/* The maximum `scale' value allowed by the `bc' utility. */ +#define _POSIX2_BC_SCALE_MAX 99 + +/* The maximum length of a string constant accepted by the `bc' utility. */ +#define _POSIX2_BC_STRING_MAX 1000 + +/* The maximum number of weights that can be assigned to an entry of + the LC_COLLATE `order' keyword in the locale definition file. */ +#define _POSIX2_COLL_WEIGHTS_MAX 2 + +/* The maximum number of expressions that can be nested + within parentheses by the `expr' utility. */ +#define _POSIX2_EXPR_NEST_MAX 32 + +/* The maximum length, in bytes, of an input line. */ +#define _POSIX2_LINE_MAX 2048 + +/* The maximum number of repeated occurrences of a regular expression + permitted when using the interval notation `\{M,N\}'. */ +#define _POSIX2_RE_DUP_MAX 255 + +/* The maximum number of bytes in a character class name. We have no + fixed limit, 2048 is a high number. */ +#define _POSIX2_CHARCLASS_NAME_MAX 14 + + +/* These values are implementation-specific, + and may vary within the implementation. + Their precise values can be obtained from sysconf. */ + +#ifndef BC_BASE_MAX +#define BC_BASE_MAX _POSIX2_BC_BASE_MAX +#endif +#ifndef BC_DIM_MAX +#define BC_DIM_MAX _POSIX2_BC_DIM_MAX +#endif +#ifndef BC_SCALE_MAX +#define BC_SCALE_MAX _POSIX2_BC_SCALE_MAX +#endif +#ifndef BC_STRING_MAX +#define BC_STRING_MAX _POSIX2_BC_STRING_MAX +#endif +#ifndef COLL_WEIGHTS_MAX +#define COLL_WEIGHTS_MAX 255 +#endif +#ifndef EXPR_NEST_MAX +#define EXPR_NEST_MAX _POSIX2_EXPR_NEST_MAX +#endif +#ifndef LINE_MAX +#define LINE_MAX _POSIX2_LINE_MAX +#endif +#ifndef CHARCLASS_NAME_MAX +#define CHARCLASS_NAME_MAX 2048 +#endif + +/* This value is defined like this in regex.h. */ +#define RE_DUP_MAX (0x7fff) + +#endif /* bits/posix2_lim.h */ diff --git a/conts/posix/libposix/include/posix/bits/posix_opt.h b/conts/posix/libposix/include/posix/bits/posix_opt.h new file mode 100644 index 0000000..dfe259b --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/posix_opt.h @@ -0,0 +1,180 @@ +/* Define POSIX options for Linux. + Copyright (C) 1996-2001, 2002, 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _POSIX_OPT_H +#define _POSIX_OPT_H 1 + +/* Job control is supported. */ +#define _POSIX_JOB_CONTROL 1 + +/* Processes have a saved set-user-ID and a saved set-group-ID. */ +#define _POSIX_SAVED_IDS 1 + +/* Priority scheduling is supported. */ +#define _POSIX_PRIORITY_SCHEDULING 200112L + +/* Synchronizing file data is supported. */ +#define _POSIX_SYNCHRONIZED_IO 200112L + +/* The fsync function is present. */ +#define _POSIX_FSYNC 200112L + +/* Mapping of files to memory is supported. */ +#define _POSIX_MAPPED_FILES 200112L + +/* Locking of all memory is supported. */ +#define _POSIX_MEMLOCK 200112L + +/* Locking of ranges of memory is supported. */ +#define _POSIX_MEMLOCK_RANGE 200112L + +/* Setting of memory protections is supported. */ +#define _POSIX_MEMORY_PROTECTION 200112L + +/* Only root can change owner of file. */ +#define _POSIX_CHOWN_RESTRICTED 1 + +/* `c_cc' member of 'struct termios' structure can be disabled by + using the value _POSIX_VDISABLE. */ +#define _POSIX_VDISABLE '\0' + +/* Filenames are not silently truncated. */ +#define _POSIX_NO_TRUNC 1 + +/* X/Open realtime support is available. */ +#define _XOPEN_REALTIME 1 + +/* XPG4.2 shared memory is supported. */ +#define _XOPEN_SHM 1 + +/* Tell we have POSIX threads. */ +#define _POSIX_THREADS 200112L + +/* We have the reentrant functions described in POSIX. */ +#define _POSIX_REENTRANT_FUNCTIONS 1 +#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L + +/* We provide priority scheduling for threads. */ +#define _POSIX_THREAD_PRIORITY_SCHEDULING 200112L + +/* We support user-defined stack sizes. */ +#define _POSIX_THREAD_ATTR_STACKSIZE 200112L + +/* We support user-defined stacks. */ +#define _POSIX_THREAD_ATTR_STACKADDR 200112L + +/* We support POSIX.1b semaphores. */ +#define _POSIX_SEMAPHORES 200112L + +/* Real-time signals are supported. */ +#define _POSIX_REALTIME_SIGNALS 200112L + +/* We support asynchronous I/O. */ +#define _POSIX_ASYNCHRONOUS_IO 200112L +#define _POSIX_ASYNC_IO 1 +/* Alternative name for Unix98. */ +#define _LFS_ASYNCHRONOUS_IO 1 +/* Support for prioritization is also available. */ +#define _POSIX_PRIORITIZED_IO 200112L + +/* The LFS support in asynchronous I/O is also available. */ +#define _LFS64_ASYNCHRONOUS_IO 1 + +#ifdef __UCLIBC_HAS_LFS__ +/* The rest of the LFS is also available. */ +#define _LFS_LARGEFILE 1 +#define _LFS64_LARGEFILE 1 +#define _LFS64_STDIO 1 +#endif + +/* POSIX shared memory objects are implemented. */ +#define _POSIX_SHARED_MEMORY_OBJECTS 200112L + +/* CPU-time clocks support needs to be checked at runtime. */ +#define _POSIX_CPUTIME 0 + +/* Clock support in threads must be also checked at runtime. */ +#define _POSIX_THREAD_CPUTIME 0 + +/* GNU libc provides regular expression handling. */ +#define _POSIX_REGEXP 1 + +/* Reader/Writer locks are available. */ +#define _POSIX_READER_WRITER_LOCKS 200112L + +/* We have a POSIX shell. */ +#define _POSIX_SHELL 1 + +/* We support the Timeouts option. */ +#define _POSIX_TIMEOUTS 200112L + +/* We support spinlocks. */ +#define _POSIX_SPIN_LOCKS 200112L + +/* The `spawn' function family is supported. */ +#define _POSIX_SPAWN 200112L + +/* We have POSIX timers. */ +#define _POSIX_TIMERS 200112L + +/* The barrier functions are available. */ +#define _POSIX_BARRIERS 200112L + +/* POSIX message queues are available. */ +#define _POSIX_MESSAGE_PASSING 200112L + +/* Thread process-shared synchronization is supported. */ +#define _POSIX_THREAD_PROCESS_SHARED 200112L + +/* The monotonic clock might be available. */ +#define _POSIX_MONOTONIC_CLOCK 0 + +/* The clock selection interfaces are available. */ +#define _POSIX_CLOCK_SELECTION 200112L + +/* Advisory information interfaces are available. */ +#define _POSIX_ADVISORY_INFO 200112L + +/* IPv6 support is available. */ +#define _POSIX_IPV6 200112L + +/* Raw socket support is available. */ +#define _POSIX_RAW_SOCKETS 200112L + +/* We have at least one terminal. */ +#define _POSIX2_CHAR_TERM 200112L + +/* Neither process nor thread sporadic server interfaces is available. */ +#define _POSIX_SPORADIC_SERVER -1 +#define _POSIX_THREAD_SPORADIC_SERVER -1 + +/* trace.h is not available. */ +#define _POSIX_TRACE -1 +#define _POSIX_TRACE_EVENT_FILTER -1 +#define _POSIX_TRACE_INHERIT -1 +#define _POSIX_TRACE_LOG -1 + +/* Typed memory objects are not available. */ +#define _POSIX_TYPED_MEMORY_OBJECTS -1 + +/* No support for priority inheritance or protection so far. */ +#define _POSIX_THREAD_PRIO_INHERIT -1 +#define _POSIX_THREAD_PRIO_PROTECT -1 + +#endif /* posix_opt.h */ diff --git a/conts/posix/libposix/include/posix/bits/pthreadtypes.h b/conts/posix/libposix/include/posix/bits/pthreadtypes.h new file mode 100644 index 0000000..faec63b --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/pthreadtypes.h @@ -0,0 +1,142 @@ +/* Linuxthreads - a simple clone()-based implementation of Posix */ +/* threads for Linux. */ +/* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */ +/* */ +/* This program is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU Library General Public License */ +/* as published by the Free Software Foundation; either version 2 */ +/* of the License, or (at your option) any later version. */ +/* */ +/* This program is distributed in the hope that it will be useful, */ +/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ +/* GNU Library General Public License for more details. */ + +#if !defined _BITS_TYPES_H && !defined _PTHREAD_H +# error "Never include directly; use instead." +#endif + +#ifndef _BITS_PTHREADTYPES_H +#define _BITS_PTHREADTYPES_H 1 + +#define __need_schedparam +#include + +/* Fast locks (not abstract because mutexes and conditions aren't abstract). */ +struct _pthread_fastlock +{ + long int __status; /* "Free" or "taken" or head of waiting list */ + int __spinlock; /* Used by compare_and_swap emulation. Also, + adaptive SMP lock stores spin count here. */ +}; + +#ifndef _PTHREAD_DESCR_DEFINED +/* Thread descriptors */ +typedef struct _pthread_descr_struct *_pthread_descr; +# define _PTHREAD_DESCR_DEFINED +#endif + + +/* Attributes for threads. */ +typedef struct __pthread_attr_s +{ + int __detachstate; + int __schedpolicy; + struct __sched_param __schedparam; + int __inheritsched; + int __scope; + size_t __guardsize; + int __stackaddr_set; + void *__stackaddr; + size_t __stacksize; +} pthread_attr_t; + + +/* Conditions (not abstract because of PTHREAD_COND_INITIALIZER */ +typedef struct +{ + struct _pthread_fastlock __c_lock; /* Protect against concurrent access */ + _pthread_descr __c_waiting; /* Threads waiting on this condition */ +} pthread_cond_t; + + +/* Attribute for conditionally variables. */ +typedef struct +{ + int __dummy; +} pthread_condattr_t; + +/* Keys for thread-specific data */ +typedef unsigned int pthread_key_t; + + +/* Mutexes (not abstract because of PTHREAD_MUTEX_INITIALIZER). */ +/* (The layout is unnatural to maintain binary compatibility + with earlier releases of LinuxThreads.) */ +typedef struct +{ + int __m_reserved; /* Reserved for future use */ + int __m_count; /* Depth of recursive locking */ + _pthread_descr __m_owner; /* Owner thread (if recursive or errcheck) */ + int __m_kind; /* Mutex kind: fast, recursive or errcheck */ + struct _pthread_fastlock __m_lock; /* Underlying fast lock */ +} pthread_mutex_t; + + +/* Attribute for mutex. */ +typedef struct +{ + int __mutexkind; +} pthread_mutexattr_t; + + +/* Once-only execution */ +typedef int pthread_once_t; + + +#if defined __USE_UNIX98 || defined __USE_XOPEN2K +/* Read-write locks. */ +typedef struct _pthread_rwlock_t +{ + struct _pthread_fastlock __rw_lock; /* Lock to guarantee mutual exclusion */ + int __rw_readers; /* Number of readers */ + _pthread_descr __rw_writer; /* Identity of writer, or NULL if none */ + _pthread_descr __rw_read_waiting; /* Threads waiting for reading */ + _pthread_descr __rw_write_waiting; /* Threads waiting for writing */ + int __rw_kind; /* Reader/Writer preference selection */ + int __rw_pshared; /* Shared between processes or not */ +} pthread_rwlock_t; + + +/* Attribute for read-write locks. */ +typedef struct +{ + int __lockkind; + int __pshared; +} pthread_rwlockattr_t; +#endif + +#ifdef __USE_XOPEN2K +/* POSIX spinlock data type. */ +typedef volatile int pthread_spinlock_t; + +/* POSIX barrier. */ +typedef struct { + struct _pthread_fastlock __ba_lock; /* Lock to guarantee mutual exclusion */ + int __ba_required; /* Threads needed for completion */ + int __ba_present; /* Threads waiting */ + _pthread_descr __ba_waiting; /* Queue of waiting threads */ +} pthread_barrier_t; + +/* barrier attribute */ +typedef struct { + int __pshared; +} pthread_barrierattr_t; + +#endif + + +/* Thread identifiers */ +typedef unsigned long int pthread_t; + +#endif /* bits/pthreadtypes.h */ diff --git a/conts/posix/libposix/include/posix/bits/resource.h b/conts/posix/libposix/include/posix/bits/resource.h new file mode 100644 index 0000000..526cdaf --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/resource.h @@ -0,0 +1,225 @@ +/* Bit values & structures for resource limits. Linux version. + Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2004, 2005 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_RESOURCE_H +# error "Never use directly; include instead." +#endif + +#include + +/* Transmute defines to enumerations. The macro re-definitions are + necessary because some programs want to test for operating system + features with #ifdef RUSAGE_SELF. In ISO C the reflexive + definition is a no-op. */ + +/* Kinds of resource limit. */ +enum __rlimit_resource +{ + /* Per-process CPU limit, in seconds. */ + RLIMIT_CPU = 0, +#define RLIMIT_CPU RLIMIT_CPU + + /* Largest file that can be created, in bytes. */ + RLIMIT_FSIZE = 1, +#define RLIMIT_FSIZE RLIMIT_FSIZE + + /* Maximum size of data segment, in bytes. */ + RLIMIT_DATA = 2, +#define RLIMIT_DATA RLIMIT_DATA + + /* Maximum size of stack segment, in bytes. */ + RLIMIT_STACK = 3, +#define RLIMIT_STACK RLIMIT_STACK + + /* Largest core file that can be created, in bytes. */ + RLIMIT_CORE = 4, +#define RLIMIT_CORE RLIMIT_CORE + + /* Largest resident set size, in bytes. + This affects swapping; processes that are exceeding their + resident set size will be more likely to have physical memory + taken from them. */ + __RLIMIT_RSS = 5, +#define RLIMIT_RSS __RLIMIT_RSS + + /* Number of open files. */ + RLIMIT_NOFILE = 7, + __RLIMIT_OFILE = RLIMIT_NOFILE, /* BSD name for same. */ +#define RLIMIT_NOFILE RLIMIT_NOFILE +#define RLIMIT_OFILE __RLIMIT_OFILE + + /* Address space limit. */ + RLIMIT_AS = 9, +#define RLIMIT_AS RLIMIT_AS + + /* Number of processes. */ + __RLIMIT_NPROC = 6, +#define RLIMIT_NPROC __RLIMIT_NPROC + + /* Locked-in-memory address space. */ + __RLIMIT_MEMLOCK = 8, +#define RLIMIT_MEMLOCK __RLIMIT_MEMLOCK + + /* Maximum number of file locks. */ + __RLIMIT_LOCKS = 10, +#define RLIMIT_LOCKS __RLIMIT_LOCKS + + /* Maximum number of pending signals. */ + __RLIMIT_SIGPENDING = 11, +#define RLIMIT_SIGPENDING __RLIMIT_SIGPENDING + + /* Maximum bytes in POSIX message queues. */ + __RLIMIT_MSGQUEUE = 12, +#define RLIMIT_MSGQUEUE __RLIMIT_MSGQUEUE + + /* Maximum nice priority allowed to raise to. + Nice levels 19 .. -20 correspond to 0 .. 39 + values of this resource limit. */ + __RLIMIT_NICE = 13, +#define RLIMIT_NICE __RLIMIT_NICE + + /* Maximum realtime priority allowed for non-priviledged + processes. */ + __RLIMIT_RTPRIO = 14, +#define RLIMIT_RTPRIO __RLIMIT_RTPRIO + + __RLIMIT_NLIMITS = 15, + __RLIM_NLIMITS = __RLIMIT_NLIMITS +#define RLIMIT_NLIMITS __RLIMIT_NLIMITS +#define RLIM_NLIMITS __RLIM_NLIMITS +}; + +/* Value to indicate that there is no limit. */ +#ifndef __USE_FILE_OFFSET64 +# define RLIM_INFINITY ((unsigned long int)(~0UL)) +#else +# define RLIM_INFINITY 0xffffffffffffffffuLL +#endif + +#ifdef __USE_LARGEFILE64 +# define RLIM64_INFINITY 0xffffffffffffffffuLL +#endif + +/* We can represent all limits. */ +#define RLIM_SAVED_MAX RLIM_INFINITY +#define RLIM_SAVED_CUR RLIM_INFINITY + + +/* Type for resource quantity measurement. */ +#ifndef __USE_FILE_OFFSET64 +typedef __rlim_t rlim_t; +#else +typedef __rlim64_t rlim_t; +#endif +#ifdef __USE_LARGEFILE64 +typedef __rlim64_t rlim64_t; +#endif + +struct rlimit + { + /* The current (soft) limit. */ + rlim_t rlim_cur; + /* The hard limit. */ + rlim_t rlim_max; + }; + +#ifdef __USE_LARGEFILE64 +struct rlimit64 + { + /* The current (soft) limit. */ + rlim64_t rlim_cur; + /* The hard limit. */ + rlim64_t rlim_max; + }; +#endif + +/* Whose usage statistics do you want? */ +enum __rusage_who +{ + /* The calling process. */ + RUSAGE_SELF = 0, +#define RUSAGE_SELF RUSAGE_SELF + + /* All of its terminated child processes. */ + RUSAGE_CHILDREN = -1 +#define RUSAGE_CHILDREN RUSAGE_CHILDREN +}; + +#define __need_timeval +#include /* For `struct timeval'. */ + +/* Structure which says how much of each resource has been used. */ +struct rusage + { + /* Total amount of user time used. */ + struct timeval ru_utime; + /* Total amount of system time used. */ + struct timeval ru_stime; + /* Maximum resident set size (in kilobytes). */ + long int ru_maxrss; + /* Amount of sharing of text segment memory + with other processes (kilobyte-seconds). */ + long int ru_ixrss; + /* Amount of data segment memory used (kilobyte-seconds). */ + long int ru_idrss; + /* Amount of stack memory used (kilobyte-seconds). */ + long int ru_isrss; + /* Number of soft page faults (i.e. those serviced by reclaiming + a page from the list of pages awaiting reallocation. */ + long int ru_minflt; + /* Number of hard page faults (i.e. those that required I/O). */ + long int ru_majflt; + /* Number of times a process was swapped out of physical memory. */ + long int ru_nswap; + /* Number of input operations via the file system. Note: This + and `ru_oublock' do not include operations with the cache. */ + long int ru_inblock; + /* Number of output operations via the file system. */ + long int ru_oublock; + /* Number of IPC messages sent. */ + long int ru_msgsnd; + /* Number of IPC messages received. */ + long int ru_msgrcv; + /* Number of signals delivered. */ + long int ru_nsignals; + /* Number of voluntary context switches, i.e. because the process + gave up the process before it had to (usually to wait for some + resource to be available). */ + long int ru_nvcsw; + /* Number of involuntary context switches, i.e. a higher priority process + became runnable or the current process used up its time slice. */ + long int ru_nivcsw; + }; + +/* Priority limits. */ +#define PRIO_MIN -20 /* Minimum priority a process can have. */ +#define PRIO_MAX 20 /* Maximum priority a process can have. */ + +/* The type of the WHICH argument to `getpriority' and `setpriority', + indicating what flavor of entity the WHO argument specifies. */ +enum __priority_which +{ + PRIO_PROCESS = 0, /* WHO is a process ID. */ +#define PRIO_PROCESS PRIO_PROCESS + PRIO_PGRP = 1, /* WHO is a process group ID. */ +#define PRIO_PGRP PRIO_PGRP + PRIO_USER = 2 /* WHO is a user ID. */ +#define PRIO_USER PRIO_USER +}; diff --git a/conts/posix/libposix/include/posix/bits/sched.h b/conts/posix/libposix/include/posix/bits/sched.h new file mode 100644 index 0000000..a174960 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/sched.h @@ -0,0 +1,132 @@ +/* Definitions of constants and data structure for POSIX 1003.1b-1993 + scheduling interface. + Copyright (C) 1996-1999,2001-2003,2005,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef __need_schedparam + +//#ifndef _SCHED_H +//# error "Never include directly; use instead." +//#endif + + +/* Scheduling algorithms. */ +#define SCHED_OTHER 0 +#define SCHED_FIFO 1 +#define SCHED_RR 2 +#ifdef __USE_GNU +# define SCHED_BATCH 3 +#endif + +#ifdef __USE_MISC +/* Cloning flags. */ +# define CSIGNAL 0x000000ff /* Signal mask to be sent at exit. */ +# define CLONE_VM 0x00000100 /* Set if VM shared between processes. */ +# define CLONE_FS 0x00000200 /* Set if fs info shared between processes. */ +# define CLONE_FILES 0x00000400 /* Set if open files shared between processes. */ +# define CLONE_SIGHAND 0x00000800 /* Set if signal handlers shared. */ +# define CLONE_PTRACE 0x00002000 /* Set if tracing continues on the child. */ +# define CLONE_VFORK 0x00004000 /* Set if the parent wants the child to + wake it up on mm_release. */ +# define CLONE_PARENT 0x00008000 /* Set if we want to have the same + parent as the cloner. */ +# define CLONE_THREAD 0x00010000 /* Set to add to same thread group. */ +# define CLONE_NEWNS 0x00020000 /* Set to create new namespace. */ +# define CLONE_SYSVSEM 0x00040000 /* Set to shared SVID SEM_UNDO semantics. */ +# define CLONE_SETTLS 0x00080000 /* Set TLS info. */ +# define CLONE_PARENT_SETTID 0x00100000 /* Store TID in userlevel buffer + before MM copy. */ +# define CLONE_CHILD_CLEARTID 0x00200000 /* Register exit futex and memory + location to clear. */ +# define CLONE_DETACHED 0x00400000 /* Create clone detached. */ +# define CLONE_UNTRACED 0x00800000 /* Set if the tracing process can't + force CLONE_PTRACE on this clone. */ +# define CLONE_CHILD_SETTID 0x01000000 /* Store TID in userlevel buffer in + the child. */ +# define CLONE_STOPPED 0x02000000 /* Start in stopped state. */ +#endif + +/* The official definition. */ +struct sched_param + { + int __sched_priority; + }; + +__BEGIN_DECLS + +#ifdef __USE_MISC +/* Clone current process. */ +extern int clone (int (*__fn) (void *__arg), void *__child_stack, + int __flags, void *__arg, ...) __THROW; + +#if 0 +/* Unshare the specified resources. */ +extern int unshare (int __flags) __THROW; +#endif +#endif + +__END_DECLS + +#endif /* need schedparam */ + +#if !defined __defined_schedparam \ + && (defined __need_schedparam || defined _SCHED_H) +# define __defined_schedparam 1 +/* Data structure to describe a process' schedulability. */ +struct __sched_param + { + int __sched_priority; + }; +# undef __need_schedparam +#endif + + +#if defined _SCHED_H && !defined __cpu_set_t_defined +# define __cpu_set_t_defined +/* Size definition for CPU sets. */ +# define __CPU_SETSIZE 1024 +# define __NCPUBITS (8 * sizeof (__cpu_mask)) + +/* Type for array elements in 'cpu_set'. */ +typedef unsigned long int __cpu_mask; + +/* Basic access functions. */ +# define __CPUELT(cpu) ((cpu) / __NCPUBITS) +# define __CPUMASK(cpu) ((__cpu_mask) 1 << ((cpu) % __NCPUBITS)) + +/* Data structure to describe CPU mask. */ +typedef struct +{ + __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS]; +} cpu_set_t; + +/* Access functions for CPU masks. */ +# define __CPU_ZERO(cpusetp) \ + do { \ + unsigned int __i; \ + cpu_set_t *__arr = (cpusetp); \ + for (__i = 0; __i < sizeof (cpu_set_t) / sizeof (__cpu_mask); ++__i) \ + __arr->__bits[__i] = 0; \ + } while (0) +# define __CPU_SET(cpu, cpusetp) \ + ((cpusetp)->__bits[__CPUELT (cpu)] |= __CPUMASK (cpu)) +# define __CPU_CLR(cpu, cpusetp) \ + ((cpusetp)->__bits[__CPUELT (cpu)] &= ~__CPUMASK (cpu)) +# define __CPU_ISSET(cpu, cpusetp) \ + (((cpusetp)->__bits[__CPUELT (cpu)] & __CPUMASK (cpu)) != 0) +#endif diff --git a/conts/posix/libposix/include/posix/bits/select.h b/conts/posix/libposix/include/posix/bits/select.h new file mode 100644 index 0000000..47e7ded --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/select.h @@ -0,0 +1,35 @@ +/* Copyright (C) 1997, 1998, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_SELECT_H +# error "Never use directly; include instead." +#endif + + +/* We don't use `memset' because this would require a prototype and + the array isn't too big. */ +#define __FD_ZERO(s) \ + do { \ + unsigned int __i; \ + fd_set *__arr = (s); \ + for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \ + __FDS_BITS (__arr)[__i] = 0; \ + } while (0) +#define __FD_SET(d, s) (__FDS_BITS (s)[__FDELT(d)] |= __FDMASK(d)) +#define __FD_CLR(d, s) (__FDS_BITS (s)[__FDELT(d)] &= ~__FDMASK(d)) +#define __FD_ISSET(d, s) ((__FDS_BITS (s)[__FDELT(d)] & __FDMASK(d)) != 0) diff --git a/conts/posix/libposix/include/posix/bits/sem.h b/conts/posix/libposix/include/posix/bits/sem.h new file mode 100644 index 0000000..6193501 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/sem.h @@ -0,0 +1,87 @@ +/* Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_SEM_H +# error "Never include directly; use instead." +#endif + +#include + +/* Flags for `semop'. */ +#define SEM_UNDO 0x1000 /* undo the operation on exit */ + +/* Commands for `semctl'. */ +#define GETPID 11 /* get sempid */ +#define GETVAL 12 /* get semval */ +#define GETALL 13 /* get all semval's */ +#define GETNCNT 14 /* get semncnt */ +#define GETZCNT 15 /* get semzcnt */ +#define SETVAL 16 /* set semval */ +#define SETALL 17 /* set all semval's */ + + +/* Data structure describing a set of semaphores. */ +struct semid_ds +{ + struct ipc_perm sem_perm; /* operation permission struct */ + __time_t sem_otime; /* last semop() time */ + unsigned long int __unused1; + __time_t sem_ctime; /* last time changed by semctl() */ + unsigned long int __unused2; + unsigned long int sem_nsems; /* number of semaphores in set */ + unsigned long int __unused3; + unsigned long int __unused4; +}; + +/* The user should define a union like the following to use it for arguments + for `semctl'. + + union semun + { + int val; <= value for SETVAL + struct semid_ds *buf; <= buffer for IPC_STAT & IPC_SET + unsigned short int *array; <= array for GETALL & SETALL + struct seminfo *__buf; <= buffer for IPC_INFO + }; + + Previous versions of this file used to define this union but this is + incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether + one must define the union or not. */ +#define _SEM_SEMUN_UNDEFINED 1 + +#ifdef __USE_MISC + +/* ipcs ctl cmds */ +# define SEM_STAT 18 +# define SEM_INFO 19 + +struct seminfo +{ + int semmap; + int semmni; + int semmns; + int semmnu; + int semmsl; + int semopm; + int semume; + int semusz; + int semvmx; + int semaem; +}; + +#endif /* __USE_MISC */ diff --git a/conts/posix/libposix/include/posix/bits/setjmp.h b/conts/posix/libposix/include/posix/bits/setjmp.h new file mode 100644 index 0000000..ac52f12 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/setjmp.h @@ -0,0 +1,52 @@ +/* Copyright (C) 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Define the machine-dependent type `jmp_buf'. ARM version. */ +#ifndef _BITS_SETJMP_H +#define _BITS_SETJMP_H 1 + +#if !defined _SETJMP_H && !defined _PTHREAD_H +# error "Never include directly; use instead." +#endif + +#ifndef _ASM +/* Jump buffer contains v1-v6, sl, fp, sp and pc. Other registers are not + saved. */ +#ifdef __ARM_EABI__ +/* The exact set of registers saved may depend on the particular core + in use, as some coprocessor registers may need to be saved. The C + Library ABI requires that the buffer be 8-byte aligned, and + recommends that the buffer contain 64 words. The first 28 words + are occupied by v1-v6, sl, fp, sp, pc, d8-d15, and fpscr. (Note + that d8-15 require 17 words, due to the use of fstmx.) */ +typedef int __jmp_buf[64] __attribute__((aligned (8))); +#elif defined __MAVERICK__ || defined __IWMMXT__ +typedef int __jmp_buf[34]; +#else +typedef int __jmp_buf[22]; +#endif +#endif + +#define __JMP_BUF_SP 8 + +/* Test if longjmp to JMPBUF would unwind the frame + containing a local variable at ADDRESS. */ +#define _JMPBUF_UNWINDS(jmpbuf, address) \ + ((void *) (address) < (void *) (jmpbuf[__JMP_BUF_SP])) + +#endif /* bits/setjmp.h */ diff --git a/conts/posix/libposix/include/posix/bits/shm.h b/conts/posix/libposix/include/posix/bits/shm.h new file mode 100644 index 0000000..318d601 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/shm.h @@ -0,0 +1,103 @@ +/* Copyright (C) 1995,1996,1997,2000,2002,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_SHM_H +# error "Never include directly; use instead." +#endif + +#include + +/* Permission flag for shmget. */ +#define SHM_R 0400 /* or S_IRUGO from */ +#define SHM_W 0200 /* or S_IWUGO from */ + +/* Flags for `shmat'. */ +#define SHM_RDONLY 010000 /* attach read-only else read-write */ +#define SHM_RND 020000 /* round attach address to SHMLBA */ +#define SHM_REMAP 040000 /* take-over region on attach */ + +/* Commands for `shmctl'. */ +#define SHM_LOCK 11 /* lock segment (root only) */ +#define SHM_UNLOCK 12 /* unlock segment (root only) */ + +__BEGIN_DECLS + +/* Segment low boundary address multiple. */ +#define SHMLBA (__getpagesize ()) +extern int __getpagesize (void) __THROW __attribute__ ((__const__)); + + +/* Type to count number of attaches. */ +typedef unsigned long int shmatt_t; + +/* Data structure describing a set of semaphores. */ +struct shmid_ds + { + struct ipc_perm shm_perm; /* operation permission struct */ + size_t shm_segsz; /* size of segment in bytes */ + __time_t shm_atime; /* time of last shmat() */ + unsigned long int __unused1; + __time_t shm_dtime; /* time of last shmdt() */ + unsigned long int __unused2; + __time_t shm_ctime; /* time of last change by shmctl() */ + unsigned long int __unused3; + __pid_t shm_cpid; /* pid of creator */ + __pid_t shm_lpid; /* pid of last shmop */ + shmatt_t shm_nattch; /* number of current attaches */ + unsigned long int __unused4; + unsigned long int __unused5; + }; + +#ifdef __USE_MISC + +/* ipcs ctl commands */ +# define SHM_STAT 13 +# define SHM_INFO 14 + +/* shm_mode upper byte flags */ +# define SHM_DEST 01000 /* segment will be destroyed on last detach */ +# define SHM_LOCKED 02000 /* segment will not be swapped */ +# define SHM_HUGETLB 04000 /* segment is mapped via hugetlb */ +# define SHM_NORESERVE 010000 /* don't check for reservations */ + +struct shminfo + { + unsigned long int shmmax; + unsigned long int shmmin; + unsigned long int shmmni; + unsigned long int shmseg; + unsigned long int shmall; + unsigned long int __unused1; + unsigned long int __unused2; + unsigned long int __unused3; + unsigned long int __unused4; + }; + +struct shm_info + { + int used_ids; + unsigned long int shm_tot; /* total allocated shm */ + unsigned long int shm_rss; /* total resident shm */ + unsigned long int shm_swp; /* total swapped shm */ + unsigned long int swap_attempts; + unsigned long int swap_successes; + }; + +#endif /* __USE_MISC */ + +__END_DECLS diff --git a/conts/posix/libposix/include/posix/bits/sigaction.h b/conts/posix/libposix/include/posix/bits/sigaction.h new file mode 100644 index 0000000..48cc531 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/sigaction.h @@ -0,0 +1,77 @@ +/* The proper definitions for Linux's sigaction. + Copyright (C) 1993-1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SIGNAL_H +# error "Never include directly; use instead." +#endif + +/* Structure describing the action to be taken when a signal arrives. */ +struct sigaction + { + /* Signal handler. */ +#ifdef __USE_POSIX199309 + union + { + /* Used if SA_SIGINFO is not set. */ + __sighandler_t sa_handler; + /* Used if SA_SIGINFO is set. */ + void (*sa_sigaction) (int, siginfo_t *, void *); + } + __sigaction_handler; +# define sa_handler __sigaction_handler.sa_handler +# define sa_sigaction __sigaction_handler.sa_sigaction +#else + __sighandler_t sa_handler; +#endif + + /* Additional set of signals to be blocked. */ + __sigset_t sa_mask; + + /* Special flags. */ + int sa_flags; + + /* Restore handler. */ + void (*sa_restorer) (void); + }; + +/* Bits in `sa_flags'. */ +#define SA_NOCLDSTOP 1 /* Don't send SIGCHLD when children stop. */ +#define SA_NOCLDWAIT 2 /* Don't create zombie on child death. */ +#define SA_SIGINFO 4 /* Invoke signal-catching function with + three arguments instead of one. */ +#if defined __USE_UNIX98 || defined __USE_MISC +# define SA_ONSTACK 0x08000000 /* Use signal stack by using `sa_restorer'. */ +# define SA_RESTART 0x10000000 /* Restart syscall on signal return. */ +# define SA_NODEFER 0x40000000 /* Don't automatically block the signal when + its handler is being executed. */ +# define SA_RESETHAND 0x80000000 /* Reset to SIG_DFL on entry to handler. */ +#endif +#ifdef __USE_MISC +# define SA_INTERRUPT 0x20000000 /* Historical no-op. */ + +/* Some aliases for the SA_ constants. */ +# define SA_NOMASK SA_NODEFER +# define SA_ONESHOT SA_RESETHAND +# define SA_STACK SA_ONSTACK +#endif + +/* Values for the HOW argument to `sigprocmask'. */ +#define SIG_BLOCK 0 /* Block signals. */ +#define SIG_UNBLOCK 1 /* Unblock signals. */ +#define SIG_SETMASK 2 /* Set the set of blocked signals. */ diff --git a/conts/posix/libposix/include/posix/bits/sigcontext.h b/conts/posix/libposix/include/posix/bits/sigcontext.h new file mode 100644 index 0000000..67dcf94 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/sigcontext.h @@ -0,0 +1,29 @@ +/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#if !defined _SIGNAL_H && !defined _SYS_UCONTEXT_H +# error "Never use directly; include instead." +#endif + +#ifndef sigcontext_struct +/* Kernel headers before 2.1.1 define a struct sigcontext_struct, but + we need sigcontext. */ +# define sigcontext_struct sigcontext + +# include +#endif diff --git a/conts/posix/libposix/include/posix/bits/sigcontextinfo.h b/conts/posix/libposix/include/posix/bits/sigcontextinfo.h new file mode 100644 index 0000000..67167f9 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/sigcontextinfo.h @@ -0,0 +1,51 @@ +/* Copyright (C) 1999, 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Philip Blundell , 1999. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include + +#define SIGCONTEXT int _a2, int _a3, int _a4, union k_sigcontext +#define SIGCONTEXT_EXTRA_ARGS _a2, _a3, _a4, + +/* The sigcontext structure changed between 2.0 and 2.1 kernels. On any + modern system we should be able to assume that the "new" format will be + in use. */ +#if LINUX_VERSION_CODE > 131328 + +#define GET_PC(ctx) ((void *) ctx.v21.arm_pc) +#define GET_FRAME(ctx) ADVANCE_STACK_FRAME ((void *) ctx.v21.arm_fp) +#define GET_STACK(ctx) ((void *) ctx.v21.arm_sp) + +#else + +#define GET_PC(ctx) ((void *)((ctx.v20.magic == SIGCONTEXT_2_0_MAGIC) ? \ + ctx.v20.reg.ARM_pc : ctx.v21.arm_pc)) +#define GET_FRAME(ctx) \ + ADVANCE_STACK_FRAME((void *)((ctx.v20.magic == SIGCONTEXT_2_0_MAGIC) ? \ + ctx.v20.reg.ARM_fp : ctx.v21.arm_fp)) +#define GET_STACK(ctx) ((void *)((ctx.v20.magic == SIGCONTEXT_2_0_MAGIC) ? \ + ctx.v20.reg.ARM_sp : ctx.v21.arm_sp)) + +#endif + +#define ADVANCE_STACK_FRAME(frm) \ + ((struct layout *)frm - 1) + +#define CALL_SIGHANDLER(handler, signo, ctx) \ + (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx)) diff --git a/conts/posix/libposix/include/posix/bits/siginfo.h b/conts/posix/libposix/include/posix/bits/siginfo.h new file mode 100644 index 0000000..4ce319d --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/siginfo.h @@ -0,0 +1,313 @@ +/* siginfo_t, sigevent and constants. Linux version. + Copyright (C) 1997-2002, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#if !defined _SIGNAL_H && !defined __need_siginfo_t \ + && !defined __need_sigevent_t +# error "Never include this file directly. Use instead" +#endif + +#include + +#if (!defined __have_sigval_t \ + && (defined _SIGNAL_H || defined __need_siginfo_t \ + || defined __need_sigevent_t)) +# define __have_sigval_t 1 + +/* Type for data associated with a signal. */ +typedef union sigval + { + int sival_int; + void *sival_ptr; + } sigval_t; +#endif + +#if (!defined __have_siginfo_t \ + && (defined _SIGNAL_H || defined __need_siginfo_t)) +# define __have_siginfo_t 1 + +# define __SI_MAX_SIZE 128 +# if __WORDSIZE == 64 +# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 4) +# else +# define __SI_PAD_SIZE ((__SI_MAX_SIZE / sizeof (int)) - 3) +# endif + +typedef struct siginfo + { + int si_signo; /* Signal number. */ + int si_errno; /* If non-zero, an errno value associated with + this signal, as defined in . */ + int si_code; /* Signal code. */ + + union + { + int _pad[__SI_PAD_SIZE]; + + /* kill(). */ + struct + { + __pid_t si_pid; /* Sending process ID. */ + __uid_t si_uid; /* Real user ID of sending process. */ + } _kill; + + /* POSIX.1b timers. */ + struct + { + int si_tid; /* Timer ID. */ + int si_overrun; /* Overrun count. */ + sigval_t si_sigval; /* Signal value. */ + } _timer; + + /* POSIX.1b signals. */ + struct + { + __pid_t si_pid; /* Sending process ID. */ + __uid_t si_uid; /* Real user ID of sending process. */ + sigval_t si_sigval; /* Signal value. */ + } _rt; + + /* SIGCHLD. */ + struct + { + __pid_t si_pid; /* Which child. */ + __uid_t si_uid; /* Real user ID of sending process. */ + int si_status; /* Exit value or signal. */ + __clock_t si_utime; + __clock_t si_stime; + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS. */ + struct + { + void *si_addr; /* Faulting insn/memory ref. */ + } _sigfault; + + /* SIGPOLL. */ + struct + { + long int si_band; /* Band event for SIGPOLL. */ + int si_fd; + } _sigpoll; + } _sifields; + } siginfo_t; + + +/* X/Open requires some more fields with fixed names. */ +# define si_pid _sifields._kill.si_pid +# define si_uid _sifields._kill.si_uid +# define si_timerid _sifields._timer.si_tid +# define si_overrun _sifields._timer.si_overrun +# define si_status _sifields._sigchld.si_status +# define si_utime _sifields._sigchld.si_utime +# define si_stime _sifields._sigchld.si_stime +# define si_value _sifields._rt.si_sigval +# define si_int _sifields._rt.si_sigval.sival_int +# define si_ptr _sifields._rt.si_sigval.sival_ptr +# define si_addr _sifields._sigfault.si_addr +# define si_band _sifields._sigpoll.si_band +# define si_fd _sifields._sigpoll.si_fd + + +/* Values for `si_code'. Positive values are reserved for kernel-generated + signals. */ +enum +{ + SI_ASYNCNL = -60, /* Sent by asynch name lookup completion. */ +# define SI_ASYNCNL SI_ASYNCNL + SI_TKILL = -6, /* Sent by tkill. */ +# define SI_TKILL SI_TKILL + SI_SIGIO, /* Sent by queued SIGIO. */ +# define SI_SIGIO SI_SIGIO + SI_ASYNCIO, /* Sent by AIO completion. */ +# define SI_ASYNCIO SI_ASYNCIO + SI_MESGQ, /* Sent by real time mesq state change. */ +# define SI_MESGQ SI_MESGQ + SI_TIMER, /* Sent by timer expiration. */ +# define SI_TIMER SI_TIMER + SI_QUEUE, /* Sent by sigqueue. */ +# define SI_QUEUE SI_QUEUE + SI_USER, /* Sent by kill, sigsend, raise. */ +# define SI_USER SI_USER + SI_KERNEL = 0x80 /* Send by kernel. */ +#define SI_KERNEL SI_KERNEL +}; + + +/* `si_code' values for SIGILL signal. */ +enum +{ + ILL_ILLOPC = 1, /* Illegal opcode. */ +# define ILL_ILLOPC ILL_ILLOPC + ILL_ILLOPN, /* Illegal operand. */ +# define ILL_ILLOPN ILL_ILLOPN + ILL_ILLADR, /* Illegal addressing mode. */ +# define ILL_ILLADR ILL_ILLADR + ILL_ILLTRP, /* Illegal trap. */ +# define ILL_ILLTRP ILL_ILLTRP + ILL_PRVOPC, /* Privileged opcode. */ +# define ILL_PRVOPC ILL_PRVOPC + ILL_PRVREG, /* Privileged register. */ +# define ILL_PRVREG ILL_PRVREG + ILL_COPROC, /* Coprocessor error. */ +# define ILL_COPROC ILL_COPROC + ILL_BADSTK /* Internal stack error. */ +# define ILL_BADSTK ILL_BADSTK +}; + +/* `si_code' values for SIGFPE signal. */ +enum +{ + FPE_INTDIV = 1, /* Integer divide by zero. */ +# define FPE_INTDIV FPE_INTDIV + FPE_INTOVF, /* Integer overflow. */ +# define FPE_INTOVF FPE_INTOVF + FPE_FLTDIV, /* Floating point divide by zero. */ +# define FPE_FLTDIV FPE_FLTDIV + FPE_FLTOVF, /* Floating point overflow. */ +# define FPE_FLTOVF FPE_FLTOVF + FPE_FLTUND, /* Floating point underflow. */ +# define FPE_FLTUND FPE_FLTUND + FPE_FLTRES, /* Floating point inexact result. */ +# define FPE_FLTRES FPE_FLTRES + FPE_FLTINV, /* Floating point invalid operation. */ +# define FPE_FLTINV FPE_FLTINV + FPE_FLTSUB /* Subscript out of range. */ +# define FPE_FLTSUB FPE_FLTSUB +}; + +/* `si_code' values for SIGSEGV signal. */ +enum +{ + SEGV_MAPERR = 1, /* Address not mapped to object. */ +# define SEGV_MAPERR SEGV_MAPERR + SEGV_ACCERR /* Invalid permissions for mapped object. */ +# define SEGV_ACCERR SEGV_ACCERR +}; + +/* `si_code' values for SIGBUS signal. */ +enum +{ + BUS_ADRALN = 1, /* Invalid address alignment. */ +# define BUS_ADRALN BUS_ADRALN + BUS_ADRERR, /* Non-existant physical address. */ +# define BUS_ADRERR BUS_ADRERR + BUS_OBJERR /* Object specific hardware error. */ +# define BUS_OBJERR BUS_OBJERR +}; + +/* `si_code' values for SIGTRAP signal. */ +enum +{ + TRAP_BRKPT = 1, /* Process breakpoint. */ +# define TRAP_BRKPT TRAP_BRKPT + TRAP_TRACE /* Process trace trap. */ +# define TRAP_TRACE TRAP_TRACE +}; + +/* `si_code' values for SIGCHLD signal. */ +enum +{ + CLD_EXITED = 1, /* Child has exited. */ +# define CLD_EXITED CLD_EXITED + CLD_KILLED, /* Child was killed. */ +# define CLD_KILLED CLD_KILLED + CLD_DUMPED, /* Child terminated abnormally. */ +# define CLD_DUMPED CLD_DUMPED + CLD_TRAPPED, /* Traced child has trapped. */ +# define CLD_TRAPPED CLD_TRAPPED + CLD_STOPPED, /* Child has stopped. */ +# define CLD_STOPPED CLD_STOPPED + CLD_CONTINUED /* Stopped child has continued. */ +# define CLD_CONTINUED CLD_CONTINUED +}; + +/* `si_code' values for SIGPOLL signal. */ +enum +{ + POLL_IN = 1, /* Data input available. */ +# define POLL_IN POLL_IN + POLL_OUT, /* Output buffers available. */ +# define POLL_OUT POLL_OUT + POLL_MSG, /* Input message available. */ +# define POLL_MSG POLL_MSG + POLL_ERR, /* I/O error. */ +# define POLL_ERR POLL_ERR + POLL_PRI, /* High priority input available. */ +# define POLL_PRI POLL_PRI + POLL_HUP /* Device disconnected. */ +# define POLL_HUP POLL_HUP +}; + +# undef __need_siginfo_t +#endif /* !have siginfo_t && (have _SIGNAL_H || need siginfo_t). */ + + +#if (defined _SIGNAL_H || defined __need_sigevent_t) \ + && !defined __have_sigevent_t +# define __have_sigevent_t 1 + +/* Structure to transport application-defined values with signals. */ +# define __SIGEV_MAX_SIZE 64 +# if __WORDSIZE == 64 +# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 4) +# else +# define __SIGEV_PAD_SIZE ((__SIGEV_MAX_SIZE / sizeof (int)) - 3) +# endif + +typedef struct sigevent + { + sigval_t sigev_value; + int sigev_signo; + int sigev_notify; + + union + { + int _pad[__SIGEV_PAD_SIZE]; + + /* When SIGEV_SIGNAL and SIGEV_THREAD_ID set, LWP ID of the + thread to receive the signal. */ + __pid_t _tid; + + struct + { + void (*_function) (sigval_t); /* Function to start. */ + void *_attribute; /* Really pthread_attr_t. */ + } _sigev_thread; + } _sigev_un; + } sigevent_t; + +/* POSIX names to access some of the members. */ +# define sigev_notify_function _sigev_un._sigev_thread._function +# define sigev_notify_attributes _sigev_un._sigev_thread._attribute + +/* `sigev_notify' values. */ +enum +{ + SIGEV_SIGNAL = 0, /* Notify via signal. */ +# define SIGEV_SIGNAL SIGEV_SIGNAL + SIGEV_NONE, /* Other notification: meaningless. */ +# define SIGEV_NONE SIGEV_NONE + SIGEV_THREAD, /* Deliver via thread creation. */ +# define SIGEV_THREAD SIGEV_THREAD + + SIGEV_THREAD_ID = 4 /* Send signal to specific thread. */ +#define SIGEV_THREAD_ID SIGEV_THREAD_ID +}; + +#endif /* have _SIGNAL_H. */ diff --git a/conts/posix/libposix/include/posix/bits/signum.h b/conts/posix/libposix/include/posix/bits/signum.h new file mode 100644 index 0000000..a18ac11 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/signum.h @@ -0,0 +1,80 @@ +/* Signal number definitions. Linux version. + Copyright (C) 1995,1996,1997,1998,1999,2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifdef _SIGNAL_H + +/* Fake signal functions. */ +#define SIG_ERR ((__sighandler_t) -1) /* Error return. */ +#define SIG_DFL ((__sighandler_t) 0) /* Default action. */ +#define SIG_IGN ((__sighandler_t) 1) /* Ignore signal. */ + +#ifdef __USE_UNIX98 +# define SIG_HOLD ((__sighandler_t) 2) /* Add signal to hold mask. */ +#endif + + +/* Signals. */ +#define SIGHUP 1 /* Hangup (POSIX). */ +#define SIGINT 2 /* Interrupt (ANSI). */ +#define SIGQUIT 3 /* Quit (POSIX). */ +#define SIGILL 4 /* Illegal instruction (ANSI). */ +#define SIGTRAP 5 /* Trace trap (POSIX). */ +#define SIGABRT 6 /* Abort (ANSI). */ +#define SIGIOT 6 /* IOT trap (4.2 BSD). */ +#define SIGBUS 7 /* BUS error (4.2 BSD). */ +#define SIGFPE 8 /* Floating-point exception (ANSI). */ +#define SIGKILL 9 /* Kill, unblockable (POSIX). */ +#define SIGUSR1 10 /* User-defined signal 1 (POSIX). */ +#define SIGSEGV 11 /* Segmentation violation (ANSI). */ +#define SIGUSR2 12 /* User-defined signal 2 (POSIX). */ +#define SIGPIPE 13 /* Broken pipe (POSIX). */ +#define SIGALRM 14 /* Alarm clock (POSIX). */ +#define SIGTERM 15 /* Termination (ANSI). */ +#define SIGSTKFLT 16 /* Stack fault. */ +#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */ +#define SIGCHLD 17 /* Child status has changed (POSIX). */ +#define SIGCONT 18 /* Continue (POSIX). */ +#define SIGSTOP 19 /* Stop, unblockable (POSIX). */ +#define SIGTSTP 20 /* Keyboard stop (POSIX). */ +#define SIGTTIN 21 /* Background read from tty (POSIX). */ +#define SIGTTOU 22 /* Background write to tty (POSIX). */ +#define SIGURG 23 /* Urgent condition on socket (4.2 BSD). */ +#define SIGXCPU 24 /* CPU limit exceeded (4.2 BSD). */ +#define SIGXFSZ 25 /* File size limit exceeded (4.2 BSD). */ +#define SIGVTALRM 26 /* Virtual alarm clock (4.2 BSD). */ +#define SIGPROF 27 /* Profiling alarm clock (4.2 BSD). */ +#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */ +#define SIGPOLL SIGIO /* Pollable event occurred (System V). */ +#define SIGIO 29 /* I/O now possible (4.2 BSD). */ +#define SIGPWR 30 /* Power failure restart (System V). */ +#define SIGSYS 31 /* Bad system call. */ +#define SIGUNUSED 31 + +#define _NSIG 65 /* Biggest signal number + 1 + (including real-time signals). */ + +#define SIGRTMIN (__libc_current_sigrtmin ()) +#define SIGRTMAX (__libc_current_sigrtmax ()) + +/* These are the hard limits of the kernel. These values should not be + used directly at user level. */ +#define __SIGRTMIN 32 +#define __SIGRTMAX (_NSIG - 1) + +#endif /* included. */ diff --git a/conts/posix/libposix/include/posix/bits/sigset.h b/conts/posix/libposix/include/posix/bits/sigset.h new file mode 100644 index 0000000..7ccadda --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/sigset.h @@ -0,0 +1,125 @@ +/* __sig_atomic_t, __sigset_t, and related definitions. Linux version. + Copyright (C) 1991, 1992, 1994, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SIGSET_H_types +# define _SIGSET_H_types 1 + +typedef int __sig_atomic_t; + +/* A `sigset_t' has a bit for each signal. */ + +# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int))) +typedef struct + { + unsigned long int __val[_SIGSET_NWORDS]; + } __sigset_t; + +#endif + + +/* We only want to define these functions if was actually + included; otherwise we were included just to define the types. Since we + are namespace-clean, it wouldn't hurt to define extra macros. But + trouble can be caused by functions being defined (e.g., any global + register vars declared later will cause compilation errors). */ + +#if !defined _SIGSET_H_fns && defined _SIGNAL_H +# define _SIGSET_H_fns 1 + +# ifndef _EXTERN_INLINE +# define _EXTERN_INLINE extern __inline +# endif + +/* Return a mask that includes the bit for SIG only. */ +# define __sigmask(sig) \ + (((unsigned long int) 1) << (((sig) - 1) % (8 * sizeof (unsigned long int)))) + +/* Return the word index for SIG. */ +# define __sigword(sig) (((sig) - 1) / (8 * sizeof (unsigned long int))) + +# if defined __GNUC__ && __GNUC__ >= 2 +# define __sigemptyset(set) \ + (__extension__ ({ int __cnt = _SIGSET_NWORDS; \ + sigset_t *__set = (set); \ + while (--__cnt >= 0) __set->__val[__cnt] = 0; \ + 0; })) +# define __sigfillset(set) \ + (__extension__ ({ int __cnt = _SIGSET_NWORDS; \ + sigset_t *__set = (set); \ + while (--__cnt >= 0) __set->__val[__cnt] = ~0UL; \ + 0; })) + +# ifdef __USE_GNU +/* The POSIX does not specify for handling the whole signal set in one + command. This is often wanted and so we define three more functions + here. */ +# define __sigisemptyset(set) \ + (__extension__ ({ int __cnt = _SIGSET_NWORDS; \ + const sigset_t *__set = (set); \ + int __ret = __set->__val[--__cnt]; \ + while (!__ret && --__cnt >= 0) \ + __ret = __set->__val[__cnt]; \ + __ret == 0; })) +# define __sigandset(dest, left, right) \ + (__extension__ ({ int __cnt = _SIGSET_NWORDS; \ + sigset_t *__dest = (dest); \ + const sigset_t *__left = (left); \ + const sigset_t *__right = (right); \ + while (--__cnt >= 0) \ + __dest->__val[__cnt] = (__left->__val[__cnt] \ + & __right->__val[__cnt]); \ + 0; })) +# define __sigorset(dest, left, right) \ + (__extension__ ({ int __cnt = _SIGSET_NWORDS; \ + sigset_t *__dest = (dest); \ + const sigset_t *__left = (left); \ + const sigset_t *__right = (right); \ + while (--__cnt >= 0) \ + __dest->__val[__cnt] = (__left->__val[__cnt] \ + | __right->__val[__cnt]); \ + 0; })) +# endif +# endif + +/* These functions needn't check for a bogus signal number -- error + checking is done in the non __ versions. */ + +extern int __sigismember (__const __sigset_t *, int); +extern int __sigaddset (__sigset_t *, int); +extern int __sigdelset (__sigset_t *, int); + +# ifdef __USE_EXTERN_INLINES +# define __SIGSETFN(NAME, BODY, CONST) \ + _EXTERN_INLINE int \ + NAME (CONST __sigset_t *__set, int __sig) \ + { \ + unsigned long int __mask = __sigmask (__sig); \ + unsigned long int __word = __sigword (__sig); \ + return BODY; \ + } + +__SIGSETFN (__sigismember, (__set->__val[__word] & __mask) ? 1 : 0, __const) +__SIGSETFN (__sigaddset, ((__set->__val[__word] |= __mask), 0), ) +__SIGSETFN (__sigdelset, ((__set->__val[__word] &= ~__mask), 0), ) + +# undef __SIGSETFN +# endif + + +#endif /* ! _SIGSET_H_fns. */ diff --git a/conts/posix/libposix/include/posix/bits/sigstack.h b/conts/posix/libposix/include/posix/bits/sigstack.h new file mode 100644 index 0000000..7f26036 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/sigstack.h @@ -0,0 +1,55 @@ +/* sigstack, sigaltstack definitions. + Copyright (C) 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SIGNAL_H +# error "Never include this file directly. Use instead" +#endif + + +/* Structure describing a signal stack (obsolete). */ +struct sigstack + { + void *ss_sp; /* Signal stack pointer. */ + int ss_onstack; /* Nonzero if executing on this stack. */ + }; + + +/* Possible values for `ss_flags.'. */ +enum +{ + SS_ONSTACK = 1, +#define SS_ONSTACK SS_ONSTACK + SS_DISABLE +#define SS_DISABLE SS_DISABLE +}; + +/* Minimum stack size for a signal handler. */ +#define MINSIGSTKSZ 2048 + +/* System default stack size. */ +#define SIGSTKSZ 8192 + + +/* Alternate, preferred interface. */ +typedef struct sigaltstack + { + void *ss_sp; + int ss_flags; + size_t ss_size; + } stack_t; diff --git a/conts/posix/libposix/include/posix/bits/sigthread.h b/conts/posix/libposix/include/posix/bits/sigthread.h new file mode 100644 index 0000000..960bde1 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/sigthread.h @@ -0,0 +1,38 @@ +/* Signal handling function for threaded programs. + Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _BITS_SIGTHREAD_H +#define _BITS_SIGTHREAD_H 1 + +#if !defined _SIGNAL_H && !defined _PTHREAD_H +# error "Never include this file directly. Use instead" +#endif + +/* Functions for handling signals. */ + +/* Modify the signal mask for the calling thread. The arguments have + the same meaning as for sigprocmask(2). */ +extern int pthread_sigmask (int __how, + __const __sigset_t *__restrict __newmask, + __sigset_t *__restrict __oldmask)__THROW; + +/* Send signal SIGNO to the given thread. */ +extern int pthread_kill (pthread_t __threadid, int __signo) __THROW; + +#endif /* bits/sigthread.h */ diff --git a/conts/posix/libposix/include/posix/bits/sockaddr.h b/conts/posix/libposix/include/posix/bits/sockaddr.h new file mode 100644 index 0000000..3e1d131 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/sockaddr.h @@ -0,0 +1,40 @@ +/* Definition of `struct sockaddr_*' common members. Generic/4.2 BSD version. + Copyright (C) 1995,1996,1997,1998,2000,2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * Never include this file directly; use instead. + */ + +#ifndef _BITS_SOCKADDR_H +#define _BITS_SOCKADDR_H 1 + + +/* POSIX.1g specifies this type name for the `sa_family' member. */ +typedef unsigned short int sa_family_t; + +/* This macro is used to declare the initial common members + of the data types used for socket addresses, `struct sockaddr', + `struct sockaddr_in', `struct sockaddr_un', etc. */ + +#define __SOCKADDR_COMMON(sa_prefix) \ + sa_family_t sa_prefix##family + +#define __SOCKADDR_COMMON_SIZE (sizeof (unsigned short int)) + +#endif /* bits/sockaddr.h */ diff --git a/conts/posix/libposix/include/posix/bits/socket.h b/conts/posix/libposix/include/posix/bits/socket.h new file mode 100644 index 0000000..2f3dc79 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/socket.h @@ -0,0 +1,327 @@ +/* System-specific socket constants and types. Linux version. + Copyright (C) 1991,1992,1994-2001,2004,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef __BITS_SOCKET_H +#define __BITS_SOCKET_H + +#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H +# error "Never include directly; use instead." +#endif + +#define __need_size_t +#define __need_NULL +#include + +#include +#include + +/* Type for length arguments in socket calls. */ +#ifndef __socklen_t_defined +typedef __socklen_t socklen_t; +# define __socklen_t_defined +#endif + +/* Types of sockets. */ +enum __socket_type +{ + SOCK_STREAM = 1, /* Sequenced, reliable, connection-based + byte streams. */ +#define SOCK_STREAM SOCK_STREAM + SOCK_DGRAM = 2, /* Connectionless, unreliable datagrams + of fixed maximum length. */ +#define SOCK_DGRAM SOCK_DGRAM + SOCK_RAW = 3, /* Raw protocol interface. */ +#define SOCK_RAW SOCK_RAW + SOCK_RDM = 4, /* Reliably-delivered messages. */ +#define SOCK_RDM SOCK_RDM + SOCK_SEQPACKET = 5, /* Sequenced, reliable, connection-based, + datagrams of fixed maximum length. */ +#define SOCK_SEQPACKET SOCK_SEQPACKET + SOCK_PACKET = 10 /* Linux specific way of getting packets + at the dev level. For writing rarp and + other similar things on the user level. */ +#define SOCK_PACKET SOCK_PACKET +}; + +/* Protocol families. */ +#define PF_UNSPEC 0 /* Unspecified. */ +#define PF_LOCAL 1 /* Local to host (pipes and file-domain). */ +#define PF_UNIX PF_LOCAL /* Old BSD name for PF_LOCAL. */ +#define PF_FILE PF_LOCAL /* Another non-standard name for PF_LOCAL. */ +#define PF_INET 2 /* IP protocol family. */ +#define PF_AX25 3 /* Amateur Radio AX.25. */ +#define PF_IPX 4 /* Novell Internet Protocol. */ +#define PF_APPLETALK 5 /* Appletalk DDP. */ +#define PF_NETROM 6 /* Amateur radio NetROM. */ +#define PF_BRIDGE 7 /* Multiprotocol bridge. */ +#define PF_ATMPVC 8 /* ATM PVCs. */ +#define PF_X25 9 /* Reserved for X.25 project. */ +#define PF_INET6 10 /* IP version 6. */ +#define PF_ROSE 11 /* Amateur Radio X.25 PLP. */ +#define PF_DECnet 12 /* Reserved for DECnet project. */ +#define PF_NETBEUI 13 /* Reserved for 802.2LLC project. */ +#define PF_SECURITY 14 /* Security callback pseudo AF. */ +#define PF_KEY 15 /* PF_KEY key management API. */ +#define PF_NETLINK 16 +#define PF_ROUTE PF_NETLINK /* Alias to emulate 4.4BSD. */ +#define PF_PACKET 17 /* Packet family. */ +#define PF_ASH 18 /* Ash. */ +#define PF_ECONET 19 /* Acorn Econet. */ +#define PF_ATMSVC 20 /* ATM SVCs. */ +#define PF_SNA 22 /* Linux SNA Project */ +#define PF_IRDA 23 /* IRDA sockets. */ +#define PF_PPPOX 24 /* PPPoX sockets. */ +#define PF_WANPIPE 25 /* Wanpipe API sockets. */ +#define PF_BLUETOOTH 31 /* Bluetooth sockets. */ +#define PF_MAX 32 /* For now.. */ + +/* Address families. */ +#define AF_UNSPEC PF_UNSPEC +#define AF_LOCAL PF_LOCAL +#define AF_UNIX PF_UNIX +#define AF_FILE PF_FILE +#define AF_INET PF_INET +#define AF_AX25 PF_AX25 +#define AF_IPX PF_IPX +#define AF_APPLETALK PF_APPLETALK +#define AF_NETROM PF_NETROM +#define AF_BRIDGE PF_BRIDGE +#define AF_ATMPVC PF_ATMPVC +#define AF_X25 PF_X25 +#define AF_INET6 PF_INET6 +#define AF_ROSE PF_ROSE +#define AF_DECnet PF_DECnet +#define AF_NETBEUI PF_NETBEUI +#define AF_SECURITY PF_SECURITY +#define AF_KEY PF_KEY +#define AF_NETLINK PF_NETLINK +#define AF_ROUTE PF_ROUTE +#define AF_PACKET PF_PACKET +#define AF_ASH PF_ASH +#define AF_ECONET PF_ECONET +#define AF_ATMSVC PF_ATMSVC +#define AF_SNA PF_SNA +#define AF_IRDA PF_IRDA +#define AF_PPPOX PF_PPPOX +#define AF_WANPIPE PF_WANPIPE +#define AF_BLUETOOTH PF_BLUETOOTH +#define AF_MAX PF_MAX + +/* Socket level values. Others are defined in the appropriate headers. + + XXX These definitions also should go into the appropriate headers as + far as they are available. */ +#define SOL_RAW 255 +#define SOL_DECNET 261 +#define SOL_X25 262 +#define SOL_PACKET 263 +#define SOL_ATM 264 /* ATM layer (cell level). */ +#define SOL_AAL 265 /* ATM Adaption Layer (packet level). */ +#define SOL_IRDA 266 + +/* Maximum queue length specifiable by listen. */ +#define SOMAXCONN 128 + +/* Get the definition of the macro to define the common sockaddr members. */ +#include + +/* Structure describing a generic socket address. */ +struct sockaddr + { + __SOCKADDR_COMMON (sa_); /* Common data: address family and length. */ + char sa_data[14]; /* Address data. */ + }; + + +/* Structure large enough to hold any socket address (with the historical + exception of AF_UNIX). We reserve 128 bytes. */ +#if ULONG_MAX > 0xffffffff +# define __ss_aligntype __uint64_t +#else +# define __ss_aligntype __uint32_t +#endif +#define _SS_SIZE 128 +#define _SS_PADSIZE (_SS_SIZE - (2 * sizeof (__ss_aligntype))) + +struct sockaddr_storage + { + __SOCKADDR_COMMON (ss_); /* Address family, etc. */ + __ss_aligntype __ss_align; /* Force desired alignment. */ + char __ss_padding[_SS_PADSIZE]; + }; + + +/* Bits in the FLAGS argument to `send', `recv', et al. */ +enum + { + MSG_OOB = 0x01, /* Process out-of-band data. */ +#define MSG_OOB MSG_OOB + MSG_PEEK = 0x02, /* Peek at incoming messages. */ +#define MSG_PEEK MSG_PEEK + MSG_DONTROUTE = 0x04, /* Don't use local routing. */ +#define MSG_DONTROUTE MSG_DONTROUTE +#ifdef __USE_GNU + /* DECnet uses a different name. */ + MSG_TRYHARD = MSG_DONTROUTE, +# define MSG_TRYHARD MSG_DONTROUTE +#endif + MSG_CTRUNC = 0x08, /* Control data lost before delivery. */ +#define MSG_CTRUNC MSG_CTRUNC + MSG_PROXY = 0x10, /* Supply or ask second address. */ +#define MSG_PROXY MSG_PROXY + MSG_TRUNC = 0x20, +#define MSG_TRUNC MSG_TRUNC + MSG_DONTWAIT = 0x40, /* Nonblocking IO. */ +#define MSG_DONTWAIT MSG_DONTWAIT + MSG_EOR = 0x80, /* End of record. */ +#define MSG_EOR MSG_EOR + MSG_WAITALL = 0x100, /* Wait for a full request. */ +#define MSG_WAITALL MSG_WAITALL + MSG_FIN = 0x200, +#define MSG_FIN MSG_FIN + MSG_SYN = 0x400, +#define MSG_SYN MSG_SYN + MSG_CONFIRM = 0x800, /* Confirm path validity. */ +#define MSG_CONFIRM MSG_CONFIRM + MSG_RST = 0x1000, +#define MSG_RST MSG_RST + MSG_ERRQUEUE = 0x2000, /* Fetch message from error queue. */ +#define MSG_ERRQUEUE MSG_ERRQUEUE + MSG_NOSIGNAL = 0x4000, /* Do not generate SIGPIPE. */ +#define MSG_NOSIGNAL MSG_NOSIGNAL + MSG_MORE = 0x8000 /* Sender will send more. */ +#define MSG_MORE MSG_MORE + }; + + +/* Structure describing messages sent by + `sendmsg' and received by `recvmsg'. */ +/* Note: do not change these members to match glibc; these match the + SuSv3 spec already (e.g. msg_iovlen/msg_controllen). + http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/socket.h.html */ +/* Note: linux kernel uses __kernel_size_t (which is 8bytes on 64bit + platforms, and 4bytes on 32bit platforms) for msg_iovlen/msg_controllen */ +struct msghdr + { + void *msg_name; /* Address to send to/receive from. */ + socklen_t msg_namelen; /* Length of address data. */ + + struct iovec *msg_iov; /* Vector of data to send/receive into. */ +#if __WORDSIZE == 32 + int msg_iovlen; /* Number of elements in the vector. */ +#else + size_t msg_iovlen; /* Number of elements in the vector. */ +#endif + + void *msg_control; /* Ancillary data (eg BSD filedesc passing). */ +#if __WORDSIZE == 32 + socklen_t msg_controllen; /* Ancillary data buffer length. */ +#else + size_t msg_controllen; /* Ancillary data buffer length. */ +#endif + + int msg_flags; /* Flags on received message. */ + }; + +/* Structure used for storage of ancillary data object information. */ +struct cmsghdr + { + size_t cmsg_len; /* Length of data in cmsg_data plus length + of cmsghdr structure. */ + int cmsg_level; /* Originating protocol. */ + int cmsg_type; /* Protocol specific type. */ +#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L + __extension__ unsigned char __cmsg_data __flexarr; /* Ancillary data. */ +#endif + }; + +/* Ancillary data object manipulation macros. */ +#if (!defined __STRICT_ANSI__ && __GNUC__ >= 2) || __STDC_VERSION__ >= 199901L +# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data) +#else +# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1)) +#endif +#define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg) +#define CMSG_FIRSTHDR(mhdr) \ + ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \ + ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) NULL) +#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \ + & (size_t) ~(sizeof (size_t) - 1)) +#define CMSG_SPACE(len) (CMSG_ALIGN (len) \ + + CMSG_ALIGN (sizeof (struct cmsghdr))) +#define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len)) + +extern struct cmsghdr *__cmsg_nxthdr (struct msghdr *__mhdr, + struct cmsghdr *__cmsg) __THROW; +#ifdef __USE_EXTERN_INLINES +# ifndef _EXTERN_INLINE +# define _EXTERN_INLINE extern __inline +# endif +_EXTERN_INLINE struct cmsghdr * +__NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg)) +{ + if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr)) + /* The kernel header does this so there may be a reason. */ + return 0; + + __cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg + + CMSG_ALIGN (__cmsg->cmsg_len)); + if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control + + __mhdr->msg_controllen) + || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len) + > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen))) + /* No more entries. */ + return 0; + return __cmsg; +} +#endif /* Use `extern inline'. */ + +/* Socket level message types. This must match the definitions in + . */ +enum + { + SCM_RIGHTS = 0x01 /* Transfer file descriptors. */ +#define SCM_RIGHTS SCM_RIGHTS +#ifdef __USE_BSD + , SCM_CREDENTIALS = 0x02 /* Credentials passing. */ +# define SCM_CREDENTIALS SCM_CREDENTIALS +#endif + }; + +/* User visible structure for SCM_CREDENTIALS message */ + +struct ucred +{ + pid_t pid; /* PID of sending process. */ + uid_t uid; /* UID of sending process. */ + gid_t gid; /* GID of sending process. */ +}; + +/* Get socket manipulation related informations from kernel headers. */ +#include + + +/* Structure used to manipulate the SO_LINGER option. */ +struct linger + { + int l_onoff; /* Nonzero to linger on close. */ + int l_linger; /* Time to linger. */ + }; + +#endif /* bits/socket.h */ diff --git a/conts/posix/libposix/include/posix/bits/stackinfo.h b/conts/posix/libposix/include/posix/bits/stackinfo.h new file mode 100644 index 0000000..2410ba9 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/stackinfo.h @@ -0,0 +1,28 @@ +/* Copyright (C) 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This file contains a bit of information about the stack allocation + of the processor. */ + +#ifndef _STACKINFO_H +#define _STACKINFO_H 1 + +/* On Arm the stack grows down. */ +#define _STACK_GROWS_DOWN 1 + +#endif /* stackinfo.h */ diff --git a/conts/posix/libposix/include/posix/bits/stat.h b/conts/posix/libposix/include/posix/bits/stat.h new file mode 100644 index 0000000..bd5aae2 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/stat.h @@ -0,0 +1,165 @@ +/* Copyright (C) 1992, 1995-2001, 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_STAT_H +# error "Never include directly; use instead." +#endif + +/* Versions of the `struct stat' data structure. */ +#define _STAT_VER_LINUX_OLD 1 +#define _STAT_VER_KERNEL 1 +#define _STAT_VER_SVR4 2 +#define _STAT_VER_LINUX 3 +#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */ + +/* Versions of the `xmknod' interface. */ +#define _MKNOD_VER_LINUX 1 +#define _MKNOD_VER_SVR4 2 +#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */ + + +struct stat + { + __dev_t st_dev; /* Device. */ +#ifndef __USE_FILE_OFFSET64 + unsigned short int __pad1; + __ino_t st_ino; /* File serial number. */ +#else + unsigned int __pad1; + __ino_t __st_ino; /* 32bit file serial number. */ +#endif + __mode_t st_mode; /* File mode. */ + __nlink_t st_nlink; /* Link count. */ + __uid_t st_uid; /* User ID of the file's owner. */ + __gid_t st_gid; /* Group ID of the file's group.*/ + __dev_t st_rdev; /* Device number, if device. */ +#ifndef __USE_FILE_OFFSET64 + unsigned short int __pad2; + __off_t st_size; /* Size of file, in bytes. */ +#else + unsigned int __pad2; + __off64_t st_size; /* Size of file, in bytes. */ +#endif + __blksize_t st_blksize; /* Optimal block size for I/O. */ + +#ifndef __USE_FILE_OFFSET64 + __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */ +#else + __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */ +#endif +#if 0 /*def __USE_MISC*/ + /* Nanosecond resolution timestamps are stored in a format + equivalent to 'struct timespec'. This is the type used + whenever possible but the Unix namespace rules do not allow the + identifier 'timespec' to appear in the header. + Therefore we have to handle the use of this header in strictly + standard-compliant sources special. */ + struct timespec st_atim; /* Time of last access. */ + struct timespec st_mtim; /* Time of last modification. */ + struct timespec st_ctim; /* Time of last status change. */ +# define st_atime st_atim.tv_sec /* Backward compatibility. */ +# define st_mtime st_mtim.tv_sec +# define st_ctime st_ctim.tv_sec +#else + __time_t st_atime; /* Time of last access. */ + unsigned long int st_atimensec; /* Nscecs of last access. */ + __time_t st_mtime; /* Time of last modification. */ + unsigned long int st_mtimensec; /* Nsecs of last modification. */ + __time_t st_ctime; /* Time of last status change. */ + unsigned long int st_ctimensec; /* Nsecs of last status change. */ +#endif +#ifndef __USE_FILE_OFFSET64 + unsigned long int __unused4; + unsigned long int __unused5; +#else + __ino64_t st_ino; /* File serial number. */ +#endif + }; + +#ifdef __USE_LARGEFILE64 +struct stat64 + { + __dev_t st_dev; /* Device. */ + unsigned int __pad1; + + __ino_t __st_ino; /* 32bit file serial number. */ + __mode_t st_mode; /* File mode. */ + __nlink_t st_nlink; /* Link count. */ + __uid_t st_uid; /* User ID of the file's owner. */ + __gid_t st_gid; /* Group ID of the file's group.*/ + __dev_t st_rdev; /* Device number, if device. */ + unsigned int __pad2; + __off64_t st_size; /* Size of file, in bytes. */ + __blksize_t st_blksize; /* Optimal block size for I/O. */ + + __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */ +#if 0 /*def __USE_MISC*/ + /* Nanosecond resolution timestamps are stored in a format + equivalent to 'struct timespec'. This is the type used + whenever possible but the Unix namespace rules do not allow the + identifier 'timespec' to appear in the header. + Therefore we have to handle the use of this header in strictly + standard-compliant sources special. */ + struct timespec st_atim; /* Time of last access. */ + struct timespec st_mtim; /* Time of last modification. */ + struct timespec st_ctim; /* Time of last status change. */ +#else + __time_t st_atime; /* Time of last access. */ + unsigned long int st_atimensec; /* Nscecs of last access. */ + __time_t st_mtime; /* Time of last modification. */ + unsigned long int st_mtimensec; /* Nsecs of last modification. */ + __time_t st_ctime; /* Time of last status change. */ + unsigned long int st_ctimensec; /* Nsecs of last status change. */ +#endif + __ino64_t st_ino; /* File serial number. */ + }; +#endif + +/* Tell code we have these members. */ +#define _STATBUF_ST_BLKSIZE +#define _STATBUF_ST_RDEV +/* Nanosecond resolution time values are supported. */ +#define _STATBUF_ST_NSEC + +/* Encoding of the file mode. */ + +#define __S_IFMT 0170000 /* These bits determine file type. */ + +/* File types. */ +#define __S_IFDIR 0040000 /* Directory. */ +#define __S_IFCHR 0020000 /* Character device. */ +#define __S_IFBLK 0060000 /* Block device. */ +#define __S_IFREG 0100000 /* Regular file. */ +#define __S_IFIFO 0010000 /* FIFO. */ +#define __S_IFLNK 0120000 /* Symbolic link. */ +#define __S_IFSOCK 0140000 /* Socket. */ + +/* POSIX.1b objects. Note that these macros always evaluate to zero. But + they do it by enforcing the correct use of the macros. */ +#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode) +#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode) +#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode) + +/* Protection bits. */ + +#define __S_ISUID 04000 /* Set user ID on execution. */ +#define __S_ISGID 02000 /* Set group ID on execution. */ +#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */ +#define __S_IREAD 0400 /* Read by owner. */ +#define __S_IWRITE 0200 /* Write by owner. */ +#define __S_IEXEC 0100 /* Execute by owner. */ diff --git a/conts/posix/libposix/include/posix/bits/statfs.h b/conts/posix/libposix/include/posix/bits/statfs.h new file mode 100644 index 0000000..0e27865 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/statfs.h @@ -0,0 +1,67 @@ +/* Copyright (C) 1997, 1998, 2000, 2002, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_STATFS_H +# error "Never include directly; use instead." +#endif + +#include + +struct statfs + { + __SWORD_TYPE f_type; + __SWORD_TYPE f_bsize; +#ifndef __USE_FILE_OFFSET64 + __fsblkcnt_t f_blocks; + __fsblkcnt_t f_bfree; + __fsblkcnt_t f_bavail; + __fsfilcnt_t f_files; + __fsfilcnt_t f_ffree; +#else + __fsblkcnt64_t f_blocks; + __fsblkcnt64_t f_bfree; + __fsblkcnt64_t f_bavail; + __fsfilcnt64_t f_files; + __fsfilcnt64_t f_ffree; +#endif + __fsid_t f_fsid; + __SWORD_TYPE f_namelen; + __SWORD_TYPE f_frsize; + __SWORD_TYPE f_spare[5]; + }; + +#ifdef __USE_LARGEFILE64 +struct statfs64 + { + __SWORD_TYPE f_type; + __SWORD_TYPE f_bsize; + __fsblkcnt64_t f_blocks; + __fsblkcnt64_t f_bfree; + __fsblkcnt64_t f_bavail; + __fsfilcnt64_t f_files; + __fsfilcnt64_t f_ffree; + __fsid_t f_fsid; + __SWORD_TYPE f_namelen; + __SWORD_TYPE f_frsize; + __SWORD_TYPE f_spare[5]; + }; +#endif + +/* Tell code we have these members. */ +#define _STATFS_F_NAMELEN +#define _STATFS_F_FRSIZE diff --git a/conts/posix/libposix/include/posix/bits/statvfs.h b/conts/posix/libposix/include/posix/bits/statvfs.h new file mode 100644 index 0000000..cca0871 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/statvfs.h @@ -0,0 +1,107 @@ +/* Copyright (C) 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_STATVFS_H +# error "Never include directly; use instead." +#endif + +#include /* For __fsblkcnt_t and __fsfilcnt_t. */ + +#if __WORDSIZE == 32 +#define _STATVFSBUF_F_UNUSED +#endif + +struct statvfs + { + unsigned long int f_bsize; + unsigned long int f_frsize; +#ifndef __USE_FILE_OFFSET64 + __fsblkcnt_t f_blocks; + __fsblkcnt_t f_bfree; + __fsblkcnt_t f_bavail; + __fsfilcnt_t f_files; + __fsfilcnt_t f_ffree; + __fsfilcnt_t f_favail; +#else + __fsblkcnt64_t f_blocks; + __fsblkcnt64_t f_bfree; + __fsblkcnt64_t f_bavail; + __fsfilcnt64_t f_files; + __fsfilcnt64_t f_ffree; + __fsfilcnt64_t f_favail; +#endif + unsigned long int f_fsid; +#ifdef _STATVFSBUF_F_UNUSED + int __f_unused; +#endif + unsigned long int f_flag; + unsigned long int f_namemax; + int __f_spare[6]; + }; + +#ifdef __USE_LARGEFILE64 +struct statvfs64 + { + unsigned long int f_bsize; + unsigned long int f_frsize; + __fsblkcnt64_t f_blocks; + __fsblkcnt64_t f_bfree; + __fsblkcnt64_t f_bavail; + __fsfilcnt64_t f_files; + __fsfilcnt64_t f_ffree; + __fsfilcnt64_t f_favail; + unsigned long int f_fsid; +#ifdef _STATVFSBUF_F_UNUSED + int __f_unused; +#endif + unsigned long int f_flag; + unsigned long int f_namemax; + int __f_spare[6]; + }; +#endif + +/* Definitions for the flag in `f_flag'. These definitions should be + kept in sync with the definitions in . */ +enum +{ + ST_RDONLY = 1, /* Mount read-only. */ +#define ST_RDONLY ST_RDONLY + ST_NOSUID = 2 /* Ignore suid and sgid bits. */ +#define ST_NOSUID ST_NOSUID +#ifdef __USE_GNU + , + ST_NODEV = 4, /* Disallow access to device special files. */ +# define ST_NODEV ST_NODEV + ST_NOEXEC = 8, /* Disallow program execution. */ +# define ST_NOEXEC ST_NOEXEC + ST_SYNCHRONOUS = 16, /* Writes are synced at once. */ +# define ST_SYNCHRONOUS ST_SYNCHRONOUS + ST_MANDLOCK = 64, /* Allow mandatory locks on an FS. */ +# define ST_MANDLOCK ST_MANDLOCK + ST_WRITE = 128, /* Write on file/directory/symlink. */ +# define ST_WRITE ST_WRITE + ST_APPEND = 256, /* Append-only file. */ +# define ST_APPEND ST_APPEND + ST_IMMUTABLE = 512, /* Immutable file. */ +# define ST_IMMUTABLE ST_IMMUTABLE + ST_NOATIME = 1024, /* Do not update access times. */ +# define ST_NOATIME ST_NOATIME + ST_NODIRATIME = 2048 /* Do not update directory access times. */ +# define ST_NODIRATIME ST_NODIRATIME +#endif /* Use GNU. */ +}; diff --git a/conts/posix/libposix/include/posix/bits/stdio.h b/conts/posix/libposix/include/posix/bits/stdio.h new file mode 100644 index 0000000..d0ba463 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/stdio.h @@ -0,0 +1,23 @@ +/* Optimizing macros and inline functions for stdio functions. + Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _STDIO_H +# error "Never include directly; use instead." +#endif + diff --git a/conts/posix/libposix/include/posix/bits/stdio_lim.h b/conts/posix/libposix/include/posix/bits/stdio_lim.h new file mode 100644 index 0000000..ea6d693 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/stdio_lim.h @@ -0,0 +1,41 @@ +/* Copyright (C) 1994, 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#if !defined _STDIO_H && !defined __need_FOPEN_MAX && !defined __need_IOV_MAX +# error "Never include directly; use instead." +#endif + +#ifdef _STDIO_H +# define L_tmpnam 20 +# define TMP_MAX 238328 +# define FILENAME_MAX 4095 + +# ifdef __USE_POSIX +# define L_ctermid 9 +# define L_cuserid 9 +# endif +#endif + +#if defined __need_FOPEN_MAX || defined _STDIO_H +# undef FOPEN_MAX +# define FOPEN_MAX 16 +#endif + +#if defined __need_IOV_MAX && !defined IOV_MAX +# define IOV_MAX 1024 +#endif diff --git a/conts/posix/libposix/include/posix/bits/syscalls.h b/conts/posix/libposix/include/posix/bits/syscalls.h new file mode 100644 index 0000000..97c4993 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/syscalls.h @@ -0,0 +1,244 @@ +#ifndef _BITS_SYSCALLS_H +#define _BITS_SYSCALLS_H +#ifndef _SYSCALL_H +# error "Never use directly; include instead." +#endif + +/* + Some of the sneaky macros in the code were taken from + glibc-2.3.2/sysdeps/unix/sysv/linux/arm/sysdep.h +*/ + +#define SYS_ify(syscall_name) (__NR_##syscall_name) + +#ifdef __ASSEMBLER__ + +/* Call a given syscall, with arguments loaded. For EABI, we must + save and restore r7 for the syscall number. Unlike the DO_CALL + macro in glibc, this macro does not load syscall arguments. */ +#undef DO_CALL +#if defined(__ARM_EABI__) +#define DO_CALL(syscall_name) \ + mov ip, r7; \ + ldr r7, =SYS_ify (syscall_name); \ + swi 0x0; \ + mov r7, ip; +#else +#define DO_CALL(syscall_name) \ + swi SYS_ify (syscall_name); +#endif + +#else + +#include + +#undef _syscall0 +#define _syscall0(type,name) \ +type name(void) \ +{ \ +return (type) (INLINE_SYSCALL(name, 0)); \ +} + +#undef _syscall1 +#define _syscall1(type,name,type1,arg1) \ +type name(type1 arg1) \ +{ \ +return (type) (INLINE_SYSCALL(name, 1, arg1)); \ +} + +#undef _syscall2 +#define _syscall2(type,name,type1,arg1,type2,arg2) \ +type name(type1 arg1,type2 arg2) \ +{ \ +return (type) (INLINE_SYSCALL(name, 2, arg1, arg2)); \ +} + +#undef _syscall3 +#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \ +type name(type1 arg1,type2 arg2,type3 arg3) \ +{ \ +return (type) (INLINE_SYSCALL(name, 3, arg1, arg2, arg3)); \ +} + +#undef _syscall4 +#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \ +type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \ +{ \ +return (type) (INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4)); \ +} + +#undef _syscall5 +#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5) \ +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \ +{ \ +return (type) (INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5)); \ +} + +#undef _syscall6 +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5,type6,arg6) \ +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \ +{ \ +return (type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \ +} + +#undef _syscall7 +#define _syscall7(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ + type5,arg5,type6,arg6,type7,arg7) \ +type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6,type7 arg7) \ +{ \ +return (type) (INLINE_SYSCALL(name, 7, arg1, arg2, arg3, arg4, arg5, arg6, arg7)); \ +} + + +#undef INLINE_SYSCALL +#define INLINE_SYSCALL(name, nr, args...) \ + ({ unsigned int _inline_sys_result = INTERNAL_SYSCALL (name, , nr, args); \ + if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_inline_sys_result, ), 0)) \ + { \ + __set_errno (INTERNAL_SYSCALL_ERRNO (_inline_sys_result, )); \ + _inline_sys_result = (unsigned int) -1; \ + } \ + (int) _inline_sys_result; }) + +#undef INTERNAL_SYSCALL_DECL +#define INTERNAL_SYSCALL_DECL(err) do { } while (0) + +#undef INTERNAL_SYSCALL +#if defined(__ARM_EABI__) +#if !defined(__thumb__) +#define INTERNAL_SYSCALL(name, err, nr, args...) \ + ({unsigned int __sys_result; \ + { \ + register int _a1 __asm__ ("r0"), _nr __asm__ ("r7"); \ + LOAD_ARGS_##nr (args) \ + _nr = SYS_ify(name); \ + __asm__ volatile ("swi 0x0 @ syscall " #name \ + : "=r" (_a1) \ + : "r" (_nr) ASM_ARGS_##nr \ + : "memory"); \ + __sys_result = _a1; \ + } \ + (int) __sys_result; }) +#else /* !defined(__thumb__) */ +/* So hide the use of r7 from the compiler, this would be a lot + * easier but for the fact that the syscalls can exceed 255. + * For the moment the LOAD_ARG_7 is sacrificed. + */ +#define INTERNAL_SYSCALL(name, err, nr, args...) \ + ({ unsigned int __sys_result; \ + { \ + register int _a1 asm ("a1"); \ + LOAD_ARGS_##nr (args) \ + register int _v3 asm ("v3") = (int) (SYS_ify(name)); \ + asm volatile ("push {r7}\n" \ + "\tmov r7, v3\n" \ + "\tswi 0 @ syscall " #name "\n" \ + "\tpop {r7}" \ + : "=r" (_a1) \ + : "r" (_v3) ASM_ARGS_##nr \ + : "memory"); \ + __sys_result = _a1; \ + } \ + (int) __sys_result; }) +#endif /*!defined(__thumb__)*/ +#else /* !defined(__ARM_EABI__) */ +#if !defined(__thumb__) +#define INTERNAL_SYSCALL(name, err, nr, args...) \ + ({ unsigned int __sys_result; \ + { \ + register int _a1 __asm__ ("a1"); \ + LOAD_ARGS_##nr (args) \ + __asm__ volatile ("swi %1 @ syscall " #name \ + : "=r" (_a1) \ + : "i" (SYS_ify(name)) ASM_ARGS_##nr \ + : "memory"); \ + __sys_result = _a1; \ + } \ + (int) __sys_result; }) +#else +#if 0 +/* This doesn't work because GCC uses r7 as a frame pointer in + * some cases and doesn't notice that the _r7 value changes + * it, resulting in mysterious crashes after the SWI. + */ +#define INTERNAL_SYSCALL(name, err, nr, args...) \ + ({ unsigned int __sys_result; \ + { \ + register int _a1 __asm__ ("a1"); \ + LOAD_ARGS_##nr (args) \ + register int _r7 __asm__ ("r7") = (int) (SYS_ify(name)); \ + __asm__ volatile ("swi 0 @ syscall " #name \ + : "=r" (_a1) \ + : "r" (_r7) ASM_ARGS_##nr \ + : "memory"); \ + __sys_result = _a1; \ + } \ + (int) __sys_result; }) +#else +/* So hide the use of r7 from the compiler, this would be a lot + * easier but for the fact that the syscalls can exceed 255. + * For the moment the LOAD_ARG_7 is sacrificed. + */ +#define INTERNAL_SYSCALL(name, err, nr, args...) \ + ({ unsigned int __sys_result; \ + { \ + register int _a1 __asm__ ("a1"); \ + LOAD_ARGS_##nr (args) \ + register int _v3 __asm__ ("v3") = (int) (SYS_ify(name)); \ + __asm__ volatile ("push {r7}\n" \ + "\tmov r7, v3\n" \ + "\tswi 0 @ syscall " #name "\n" \ + "\tpop {r7}" \ + : "=r" (_a1) \ + : "r" (_v3) ASM_ARGS_##nr \ + : "memory"); \ + __sys_result = _a1; \ + } \ + (int) __sys_result; }) +#endif +#endif +#endif /* !defined(__ARM_EABI__) */ + +#undef INTERNAL_SYSCALL_ERROR_P +#define INTERNAL_SYSCALL_ERROR_P(val, err) \ + ((unsigned int) (val) >= 0xfffff001u) + +#undef INTERNAL_SYSCALL_ERRNO +#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) + +#define LOAD_ARGS_0() +#define ASM_ARGS_0 +#define LOAD_ARGS_1(a1) \ + _a1 = (int) (a1); \ + LOAD_ARGS_0 () +#define ASM_ARGS_1 ASM_ARGS_0, "r" (_a1) +#define LOAD_ARGS_2(a1, a2) \ + register int _a2 __asm__ ("a2") = (int) (a2); \ + LOAD_ARGS_1 (a1) +#define ASM_ARGS_2 ASM_ARGS_1, "r" (_a2) +#define LOAD_ARGS_3(a1, a2, a3) \ + register int _a3 __asm__ ("a3") = (int) (a3); \ + LOAD_ARGS_2 (a1, a2) +#define ASM_ARGS_3 ASM_ARGS_2, "r" (_a3) +#define LOAD_ARGS_4(a1, a2, a3, a4) \ + register int _a4 __asm__ ("a4") = (int) (a4); \ + LOAD_ARGS_3 (a1, a2, a3) +#define ASM_ARGS_4 ASM_ARGS_3, "r" (_a4) +#define LOAD_ARGS_5(a1, a2, a3, a4, a5) \ + register int _v1 __asm__ ("v1") = (int) (a5); \ + LOAD_ARGS_4 (a1, a2, a3, a4) +#define ASM_ARGS_5 ASM_ARGS_4, "r" (_v1) +#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \ + register int _v2 __asm__ ("v2") = (int) (a6); \ + LOAD_ARGS_5 (a1, a2, a3, a4, a5) +#define ASM_ARGS_6 ASM_ARGS_5, "r" (_v2) +#define LOAD_ARGS_7(a1, a2, a3, a4, a5, a6, a7) \ + register int _v3 __asm__ ("v3") = (int) (a7); \ + LOAD_ARGS_6 (a1, a2, a3, a4, a5, a6) +#define ASM_ARGS_7 ASM_ARGS_6, "r" (_v3) + + +#endif /* __ASSEMBLER__ */ +#endif /* _BITS_SYSCALLS_H */ diff --git a/conts/posix/libposix/include/posix/bits/sysnum.h b/conts/posix/libposix/include/posix/bits/sysnum.h new file mode 100644 index 0000000..4509180 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/sysnum.h @@ -0,0 +1,980 @@ +/* WARNING!!! AUTO-GENERATED FILE!!! DO NOT EDIT!!! */ + +#ifndef _BITS_SYSNUM_H +#define _BITS_SYSNUM_H + +#ifndef _SYSCALL_H +# error "Never use directly; include instead." +#endif + +#undef __NR_OABI_SYSCALL_BASE +#define __NR_OABI_SYSCALL_BASE 0x900000 +#define SYS_OABI_SYSCALL_BASE __NR_OABI_SYSCALL_BASE +#undef __NR_SYSCALL_BASE +#define __NR_SYSCALL_BASE 0 +#define SYS_SYSCALL_BASE __NR_SYSCALL_BASE +#undef __NR_restart_syscall +#define __NR_restart_syscall (0 + 0) +#define SYS_restart_syscall __NR_restart_syscall +#undef __NR_exit +#define __NR_exit (0 + 1) +#define SYS_exit __NR_exit +#undef __NR_fork +#define __NR_fork (0 + 2) +#define SYS_fork __NR_fork +#undef __NR_read +#define __NR_read (0 + 3) +#define SYS_read __NR_read +#undef __NR_write +#define __NR_write (0 + 4) +#define SYS_write __NR_write +#undef __NR_open +#define __NR_open (0 + 5) +#define SYS_open __NR_open +#undef __NR_close +#define __NR_close (0 + 6) +#define SYS_close __NR_close +#undef __NR_creat +#define __NR_creat (0 + 8) +#define SYS_creat __NR_creat +#undef __NR_link +#define __NR_link (0 + 9) +#define SYS_link __NR_link +#undef __NR_unlink +#define __NR_unlink (0 + 10) +#define SYS_unlink __NR_unlink +#undef __NR_execve +#define __NR_execve (0 + 11) +#define SYS_execve __NR_execve +#undef __NR_chdir +#define __NR_chdir (0 + 12) +#define SYS_chdir __NR_chdir +#undef __NR_time +#define __NR_time __NR_time +#define SYS_time __NR_time +#undef __NR_mknod +#define __NR_mknod (0 + 14) +#define SYS_mknod __NR_mknod +#undef __NR_chmod +#define __NR_chmod (0 + 15) +#define SYS_chmod __NR_chmod +#undef __NR_lchown +#define __NR_lchown (0 + 16) +#define SYS_lchown __NR_lchown +#undef __NR_lseek +#define __NR_lseek (0 + 19) +#define SYS_lseek __NR_lseek +#undef __NR_getpid +#define __NR_getpid (0 + 20) +#define SYS_getpid __NR_getpid +#undef __NR_mount +#define __NR_mount (0 + 21) +#define SYS_mount __NR_mount +#undef __NR_umount +#define __NR_umount __NR_umount +#define SYS_umount __NR_umount +#undef __NR_setuid +#define __NR_setuid (0 + 23) +#define SYS_setuid __NR_setuid +#undef __NR_getuid +#define __NR_getuid (0 + 24) +#define SYS_getuid __NR_getuid +#undef __NR_stime +#define __NR_stime __NR_stime +#define SYS_stime __NR_stime +#undef __NR_ptrace +#define __NR_ptrace (0 + 26) +#define SYS_ptrace __NR_ptrace +#undef __NR_alarm +#define __NR_alarm __NR_alarm +#define SYS_alarm __NR_alarm +#undef __NR_pause +#define __NR_pause (0 + 29) +#define SYS_pause __NR_pause +#undef __NR_utime +#define __NR_utime __NR_utime +#define SYS_utime __NR_utime +#undef __NR_access +#define __NR_access (0 + 33) +#define SYS_access __NR_access +#undef __NR_nice +#define __NR_nice (0 + 34) +#define SYS_nice __NR_nice +#undef __NR_sync +#define __NR_sync (0 + 36) +#define SYS_sync __NR_sync +#undef __NR_kill +#define __NR_kill (0 + 37) +#define SYS_kill __NR_kill +#undef __NR_rename +#define __NR_rename (0 + 38) +#define SYS_rename __NR_rename +#undef __NR_mkdir +#define __NR_mkdir (0 + 39) +#define SYS_mkdir __NR_mkdir +#undef __NR_rmdir +#define __NR_rmdir (0 + 40) +#define SYS_rmdir __NR_rmdir +#undef __NR_dup +#define __NR_dup (0 + 41) +#define SYS_dup __NR_dup +#undef __NR_pipe +#define __NR_pipe (0 + 42) +#define SYS_pipe __NR_pipe +#undef __NR_times +#define __NR_times (0 + 43) +#define SYS_times __NR_times +#undef __NR_brk +#define __NR_brk (0 + 45) +#define SYS_brk __NR_brk +#undef __NR_setgid +#define __NR_setgid (0 + 46) +#define SYS_setgid __NR_setgid +#undef __NR_getgid +#define __NR_getgid (0 + 47) +#define SYS_getgid __NR_getgid +#undef __NR_geteuid +#define __NR_geteuid (0 + 49) +#define SYS_geteuid __NR_geteuid +#undef __NR_getegid +#define __NR_getegid (0 + 50) +#define SYS_getegid __NR_getegid +#undef __NR_acct +#define __NR_acct (0 + 51) +#define SYS_acct __NR_acct +#undef __NR_umount2 +#define __NR_umount2 (0 + 52) +#define SYS_umount2 __NR_umount2 +#undef __NR_ioctl +#define __NR_ioctl (0 + 54) +#define SYS_ioctl __NR_ioctl +#undef __NR_fcntl +#define __NR_fcntl (0 + 55) +#define SYS_fcntl __NR_fcntl +#undef __NR_setpgid +#define __NR_setpgid (0 + 57) +#define SYS_setpgid __NR_setpgid +#undef __NR_umask +#define __NR_umask (0 + 60) +#define SYS_umask __NR_umask +#undef __NR_chroot +#define __NR_chroot (0 + 61) +#define SYS_chroot __NR_chroot +#undef __NR_ustat +#define __NR_ustat (0 + 62) +#define SYS_ustat __NR_ustat +#undef __NR_dup2 +#define __NR_dup2 (0 + 63) +#define SYS_dup2 __NR_dup2 +#undef __NR_getppid +#define __NR_getppid (0 + 64) +#define SYS_getppid __NR_getppid +#undef __NR_getpgrp +#define __NR_getpgrp (0 + 65) +#define SYS_getpgrp __NR_getpgrp +#undef __NR_setsid +#define __NR_setsid (0 + 66) +#define SYS_setsid __NR_setsid +#undef __NR_sigaction +#define __NR_sigaction (0 + 67) +#define SYS_sigaction __NR_sigaction +#undef __NR_setreuid +#define __NR_setreuid (0 + 70) +#define SYS_setreuid __NR_setreuid +#undef __NR_setregid +#define __NR_setregid (0 + 71) +#define SYS_setregid __NR_setregid +#undef __NR_sigsuspend +#define __NR_sigsuspend (0 + 72) +#define SYS_sigsuspend __NR_sigsuspend +#undef __NR_sigpending +#define __NR_sigpending (0 + 73) +#define SYS_sigpending __NR_sigpending +#undef __NR_sethostname +#define __NR_sethostname (0 + 74) +#define SYS_sethostname __NR_sethostname +#undef __NR_setrlimit +#define __NR_setrlimit (0 + 75) +#define SYS_setrlimit __NR_setrlimit +#undef __NR_getrlimit +#define __NR_getrlimit __NR_getrlimit +#define SYS_getrlimit __NR_getrlimit +#undef __NR_getrusage +#define __NR_getrusage (0 + 77) +#define SYS_getrusage __NR_getrusage +#undef __NR_gettimeofday +#define __NR_gettimeofday (0 + 78) +#define SYS_gettimeofday __NR_gettimeofday +#undef __NR_settimeofday +#define __NR_settimeofday (0 + 79) +#define SYS_settimeofday __NR_settimeofday +#undef __NR_getgroups +#define __NR_getgroups (0 + 80) +#define SYS_getgroups __NR_getgroups +#undef __NR_setgroups +#define __NR_setgroups (0 + 81) +#define SYS_setgroups __NR_setgroups +#undef __NR_select +#define __NR_select __NR_select +#define SYS_select __NR_select +#undef __NR_symlink +#define __NR_symlink (0 + 83) +#define SYS_symlink __NR_symlink +#undef __NR_readlink +#define __NR_readlink (0 + 85) +#define SYS_readlink __NR_readlink +#undef __NR_uselib +#define __NR_uselib (0 + 86) +#define SYS_uselib __NR_uselib +#undef __NR_swapon +#define __NR_swapon (0 + 87) +#define SYS_swapon __NR_swapon +#undef __NR_reboot +#define __NR_reboot (0 + 88) +#define SYS_reboot __NR_reboot +#undef __NR_readdir +#define __NR_readdir __NR_readdir +#define SYS_readdir __NR_readdir +#undef __NR_mmap +#define __NR_mmap __NR_mmap +#define SYS_mmap __NR_mmap +#undef __NR_munmap +#define __NR_munmap (0 + 91) +#define SYS_munmap __NR_munmap +#undef __NR_truncate +#define __NR_truncate (0 + 92) +#define SYS_truncate __NR_truncate +#undef __NR_ftruncate +#define __NR_ftruncate (0 + 93) +#define SYS_ftruncate __NR_ftruncate +#undef __NR_fchmod +#define __NR_fchmod (0 + 94) +#define SYS_fchmod __NR_fchmod +#undef __NR_fchown +#define __NR_fchown (0 + 95) +#define SYS_fchown __NR_fchown +#undef __NR_getpriority +#define __NR_getpriority (0 + 96) +#define SYS_getpriority __NR_getpriority +#undef __NR_setpriority +#define __NR_setpriority (0 + 97) +#define SYS_setpriority __NR_setpriority +#undef __NR_statfs +#define __NR_statfs (0 + 99) +#define SYS_statfs __NR_statfs +#undef __NR_fstatfs +#define __NR_fstatfs (0 +100) +#define SYS_fstatfs __NR_fstatfs +#undef __NR_socketcall +#define __NR_socketcall __NR_socketcall +#define SYS_socketcall __NR_socketcall +#undef __NR_syslog +#define __NR_syslog (0 +103) +#define SYS_syslog __NR_syslog +#undef __NR_setitimer +#define __NR_setitimer (0 +104) +#define SYS_setitimer __NR_setitimer +#undef __NR_getitimer +#define __NR_getitimer (0 +105) +#define SYS_getitimer __NR_getitimer +#undef __NR_stat +#define __NR_stat (0 +106) +#define SYS_stat __NR_stat +#undef __NR_lstat +#define __NR_lstat (0 +107) +#define SYS_lstat __NR_lstat +#undef __NR_fstat +#define __NR_fstat (0 +108) +#define SYS_fstat __NR_fstat +#undef __NR_vhangup +#define __NR_vhangup (0 +111) +#define SYS_vhangup __NR_vhangup +#undef __NR_syscall +#define __NR_syscall __NR_syscall +#define SYS_syscall __NR_syscall +#undef __NR_wait4 +#define __NR_wait4 (0 +114) +#define SYS_wait4 __NR_wait4 +#undef __NR_swapoff +#define __NR_swapoff (0 +115) +#define SYS_swapoff __NR_swapoff +#undef __NR_sysinfo +#define __NR_sysinfo (0 +116) +#define SYS_sysinfo __NR_sysinfo +#undef __NR_ipc +#define __NR_ipc __NR_ipc +#define SYS_ipc __NR_ipc +#undef __NR_fsync +#define __NR_fsync (0 +118) +#define SYS_fsync __NR_fsync +#undef __NR_sigreturn +#define __NR_sigreturn (0 +119) +#define SYS_sigreturn __NR_sigreturn +#undef __NR_clone +#define __NR_clone (0 +120) +#define SYS_clone __NR_clone +#undef __NR_setdomainname +#define __NR_setdomainname (0 +121) +#define SYS_setdomainname __NR_setdomainname +#undef __NR_uname +#define __NR_uname (0 +122) +#define SYS_uname __NR_uname +#undef __NR_adjtimex +#define __NR_adjtimex (0 +124) +#define SYS_adjtimex __NR_adjtimex +#undef __NR_mprotect +#define __NR_mprotect (0 +125) +#define SYS_mprotect __NR_mprotect +#undef __NR_sigprocmask +#define __NR_sigprocmask (0 +126) +#define SYS_sigprocmask __NR_sigprocmask +#undef __NR_init_module +#define __NR_init_module (0 +128) +#define SYS_init_module __NR_init_module +#undef __NR_delete_module +#define __NR_delete_module (0 +129) +#define SYS_delete_module __NR_delete_module +#undef __NR_quotactl +#define __NR_quotactl (0 +131) +#define SYS_quotactl __NR_quotactl +#undef __NR_getpgid +#define __NR_getpgid (0 +132) +#define SYS_getpgid __NR_getpgid +#undef __NR_fchdir +#define __NR_fchdir (0 +133) +#define SYS_fchdir __NR_fchdir +#undef __NR_bdflush +#define __NR_bdflush (0 +134) +#define SYS_bdflush __NR_bdflush +#undef __NR_sysfs +#define __NR_sysfs (0 +135) +#define SYS_sysfs __NR_sysfs +#undef __NR_personality +#define __NR_personality (0 +136) +#define SYS_personality __NR_personality +#undef __NR_setfsuid +#define __NR_setfsuid (0 +138) +#define SYS_setfsuid __NR_setfsuid +#undef __NR_setfsgid +#define __NR_setfsgid (0 +139) +#define SYS_setfsgid __NR_setfsgid +#undef __NR__llseek +#define __NR__llseek (0 +140) +#define SYS__llseek __NR__llseek +#undef __NR_getdents +#define __NR_getdents (0 +141) +#define SYS_getdents __NR_getdents +#undef __NR__newselect +#define __NR__newselect (0 +142) +#define SYS__newselect __NR__newselect +#undef __NR_flock +#define __NR_flock (0 +143) +#define SYS_flock __NR_flock +#undef __NR_msync +#define __NR_msync (0 +144) +#define SYS_msync __NR_msync +#undef __NR_readv +#define __NR_readv (0 +145) +#define SYS_readv __NR_readv +#undef __NR_writev +#define __NR_writev (0 +146) +#define SYS_writev __NR_writev +#undef __NR_getsid +#define __NR_getsid (0 +147) +#define SYS_getsid __NR_getsid +#undef __NR_fdatasync +#define __NR_fdatasync (0 +148) +#define SYS_fdatasync __NR_fdatasync +#undef __NR__sysctl +#define __NR__sysctl (0 +149) +#define SYS__sysctl __NR__sysctl +#undef __NR_mlock +#define __NR_mlock (0 +150) +#define SYS_mlock __NR_mlock +#undef __NR_munlock +#define __NR_munlock (0 +151) +#define SYS_munlock __NR_munlock +#undef __NR_mlockall +#define __NR_mlockall (0 +152) +#define SYS_mlockall __NR_mlockall +#undef __NR_munlockall +#define __NR_munlockall (0 +153) +#define SYS_munlockall __NR_munlockall +#undef __NR_sched_setparam +#define __NR_sched_setparam (0 +154) +#define SYS_sched_setparam __NR_sched_setparam +#undef __NR_sched_getparam +#define __NR_sched_getparam (0 +155) +#define SYS_sched_getparam __NR_sched_getparam +#undef __NR_sched_setscheduler +#define __NR_sched_setscheduler (0 +156) +#define SYS_sched_setscheduler __NR_sched_setscheduler +#undef __NR_sched_getscheduler +#define __NR_sched_getscheduler (0 +157) +#define SYS_sched_getscheduler __NR_sched_getscheduler +#undef __NR_sched_yield +#define __NR_sched_yield (0 +158) +#define SYS_sched_yield __NR_sched_yield +#undef __NR_sched_get_priority_max +#define __NR_sched_get_priority_max (0 +159) +#define SYS_sched_get_priority_max __NR_sched_get_priority_max +#undef __NR_sched_get_priority_min +#define __NR_sched_get_priority_min (0 +160) +#define SYS_sched_get_priority_min __NR_sched_get_priority_min +#undef __NR_sched_rr_get_interval +#define __NR_sched_rr_get_interval (0 +161) +#define SYS_sched_rr_get_interval __NR_sched_rr_get_interval +#undef __NR_nanosleep +#define __NR_nanosleep (0 +162) +#define SYS_nanosleep __NR_nanosleep +#undef __NR_mremap +#define __NR_mremap (0 +163) +#define SYS_mremap __NR_mremap +#undef __NR_setresuid +#define __NR_setresuid (0 +164) +#define SYS_setresuid __NR_setresuid +#undef __NR_getresuid +#define __NR_getresuid (0 +165) +#define SYS_getresuid __NR_getresuid +#undef __NR_poll +#define __NR_poll (0 +168) +#define SYS_poll __NR_poll +#undef __NR_nfsservctl +#define __NR_nfsservctl (0 +169) +#define SYS_nfsservctl __NR_nfsservctl +#undef __NR_setresgid +#define __NR_setresgid (0 +170) +#define SYS_setresgid __NR_setresgid +#undef __NR_getresgid +#define __NR_getresgid (0 +171) +#define SYS_getresgid __NR_getresgid +#undef __NR_prctl +#define __NR_prctl (0 +172) +#define SYS_prctl __NR_prctl +#undef __NR_rt_sigreturn +#define __NR_rt_sigreturn (0 +173) +#define SYS_rt_sigreturn __NR_rt_sigreturn +#undef __NR_rt_sigaction +#define __NR_rt_sigaction (0 +174) +#define SYS_rt_sigaction __NR_rt_sigaction +#undef __NR_rt_sigprocmask +#define __NR_rt_sigprocmask (0 +175) +#define SYS_rt_sigprocmask __NR_rt_sigprocmask +#undef __NR_rt_sigpending +#define __NR_rt_sigpending (0 +176) +#define SYS_rt_sigpending __NR_rt_sigpending +#undef __NR_rt_sigtimedwait +#define __NR_rt_sigtimedwait (0 +177) +#define SYS_rt_sigtimedwait __NR_rt_sigtimedwait +#undef __NR_rt_sigqueueinfo +#define __NR_rt_sigqueueinfo (0 +178) +#define SYS_rt_sigqueueinfo __NR_rt_sigqueueinfo +#undef __NR_rt_sigsuspend +#define __NR_rt_sigsuspend (0 +179) +#define SYS_rt_sigsuspend __NR_rt_sigsuspend +#undef __NR_pread64 +#define __NR_pread64 (0 +180) +#define SYS_pread64 __NR_pread64 +#undef __NR_pwrite64 +#define __NR_pwrite64 (0 +181) +#define SYS_pwrite64 __NR_pwrite64 +#undef __NR_chown +#define __NR_chown (0 +182) +#define SYS_chown __NR_chown +#undef __NR_getcwd +#define __NR_getcwd (0 +183) +#define SYS_getcwd __NR_getcwd +#undef __NR_capget +#define __NR_capget (0 +184) +#define SYS_capget __NR_capget +#undef __NR_capset +#define __NR_capset (0 +185) +#define SYS_capset __NR_capset +#undef __NR_sigaltstack +#define __NR_sigaltstack (0 +186) +#define SYS_sigaltstack __NR_sigaltstack +#undef __NR_sendfile +#define __NR_sendfile (0 +187) +#define SYS_sendfile __NR_sendfile +#undef __NR_vfork +#define __NR_vfork (0 +190) +#define SYS_vfork __NR_vfork +#undef __NR_ugetrlimit +#define __NR_ugetrlimit (0 +191) +#define SYS_ugetrlimit __NR_ugetrlimit +#undef __NR_mmap2 +#define __NR_mmap2 (0 +192) +#define SYS_mmap2 __NR_mmap2 +#undef __NR_truncate64 +#define __NR_truncate64 (0 +193) +#define SYS_truncate64 __NR_truncate64 +#undef __NR_ftruncate64 +#define __NR_ftruncate64 (0 +194) +#define SYS_ftruncate64 __NR_ftruncate64 +#undef __NR_stat64 +#define __NR_stat64 (0 +195) +#define SYS_stat64 __NR_stat64 +#undef __NR_lstat64 +#define __NR_lstat64 (0 +196) +#define SYS_lstat64 __NR_lstat64 +#undef __NR_fstat64 +#define __NR_fstat64 (0 +197) +#define SYS_fstat64 __NR_fstat64 +#undef __NR_lchown32 +#define __NR_lchown32 (0 +198) +#define SYS_lchown32 __NR_lchown32 +#undef __NR_getuid32 +#define __NR_getuid32 (0 +199) +#define SYS_getuid32 __NR_getuid32 +#undef __NR_getgid32 +#define __NR_getgid32 (0 +200) +#define SYS_getgid32 __NR_getgid32 +#undef __NR_geteuid32 +#define __NR_geteuid32 (0 +201) +#define SYS_geteuid32 __NR_geteuid32 +#undef __NR_getegid32 +#define __NR_getegid32 (0 +202) +#define SYS_getegid32 __NR_getegid32 +#undef __NR_setreuid32 +#define __NR_setreuid32 (0 +203) +#define SYS_setreuid32 __NR_setreuid32 +#undef __NR_setregid32 +#define __NR_setregid32 (0 +204) +#define SYS_setregid32 __NR_setregid32 +#undef __NR_getgroups32 +#define __NR_getgroups32 (0 +205) +#define SYS_getgroups32 __NR_getgroups32 +#undef __NR_setgroups32 +#define __NR_setgroups32 (0 +206) +#define SYS_setgroups32 __NR_setgroups32 +#undef __NR_fchown32 +#define __NR_fchown32 (0 +207) +#define SYS_fchown32 __NR_fchown32 +#undef __NR_setresuid32 +#define __NR_setresuid32 (0 +208) +#define SYS_setresuid32 __NR_setresuid32 +#undef __NR_getresuid32 +#define __NR_getresuid32 (0 +209) +#define SYS_getresuid32 __NR_getresuid32 +#undef __NR_setresgid32 +#define __NR_setresgid32 (0 +210) +#define SYS_setresgid32 __NR_setresgid32 +#undef __NR_getresgid32 +#define __NR_getresgid32 (0 +211) +#define SYS_getresgid32 __NR_getresgid32 +#undef __NR_chown32 +#define __NR_chown32 (0 +212) +#define SYS_chown32 __NR_chown32 +#undef __NR_setuid32 +#define __NR_setuid32 (0 +213) +#define SYS_setuid32 __NR_setuid32 +#undef __NR_setgid32 +#define __NR_setgid32 (0 +214) +#define SYS_setgid32 __NR_setgid32 +#undef __NR_setfsuid32 +#define __NR_setfsuid32 (0 +215) +#define SYS_setfsuid32 __NR_setfsuid32 +#undef __NR_setfsgid32 +#define __NR_setfsgid32 (0 +216) +#define SYS_setfsgid32 __NR_setfsgid32 +#undef __NR_getdents64 +#define __NR_getdents64 (0 +217) +#define SYS_getdents64 __NR_getdents64 +#undef __NR_pivot_root +#define __NR_pivot_root (0 +218) +#define SYS_pivot_root __NR_pivot_root +#undef __NR_mincore +#define __NR_mincore (0 +219) +#define SYS_mincore __NR_mincore +#undef __NR_madvise +#define __NR_madvise (0 +220) +#define SYS_madvise __NR_madvise +#undef __NR_fcntl64 +#define __NR_fcntl64 (0 +221) +#define SYS_fcntl64 __NR_fcntl64 +#undef __NR_gettid +#define __NR_gettid (0 +224) +#define SYS_gettid __NR_gettid +#undef __NR_readahead +#define __NR_readahead (0 +225) +#define SYS_readahead __NR_readahead +#undef __NR_setxattr +#define __NR_setxattr (0 +226) +#define SYS_setxattr __NR_setxattr +#undef __NR_lsetxattr +#define __NR_lsetxattr (0 +227) +#define SYS_lsetxattr __NR_lsetxattr +#undef __NR_fsetxattr +#define __NR_fsetxattr (0 +228) +#define SYS_fsetxattr __NR_fsetxattr +#undef __NR_getxattr +#define __NR_getxattr (0 +229) +#define SYS_getxattr __NR_getxattr +#undef __NR_lgetxattr +#define __NR_lgetxattr (0 +230) +#define SYS_lgetxattr __NR_lgetxattr +#undef __NR_fgetxattr +#define __NR_fgetxattr (0 +231) +#define SYS_fgetxattr __NR_fgetxattr +#undef __NR_listxattr +#define __NR_listxattr (0 +232) +#define SYS_listxattr __NR_listxattr +#undef __NR_llistxattr +#define __NR_llistxattr (0 +233) +#define SYS_llistxattr __NR_llistxattr +#undef __NR_flistxattr +#define __NR_flistxattr (0 +234) +#define SYS_flistxattr __NR_flistxattr +#undef __NR_removexattr +#define __NR_removexattr (0 +235) +#define SYS_removexattr __NR_removexattr +#undef __NR_lremovexattr +#define __NR_lremovexattr (0 +236) +#define SYS_lremovexattr __NR_lremovexattr +#undef __NR_fremovexattr +#define __NR_fremovexattr (0 +237) +#define SYS_fremovexattr __NR_fremovexattr +#undef __NR_tkill +#define __NR_tkill (0 +238) +#define SYS_tkill __NR_tkill +#undef __NR_sendfile64 +#define __NR_sendfile64 (0 +239) +#define SYS_sendfile64 __NR_sendfile64 +#undef __NR_futex +#define __NR_futex (0 +240) +#define SYS_futex __NR_futex +#undef __NR_sched_setaffinity +#define __NR_sched_setaffinity (0 +241) +#define SYS_sched_setaffinity __NR_sched_setaffinity +#undef __NR_sched_getaffinity +#define __NR_sched_getaffinity (0 +242) +#define SYS_sched_getaffinity __NR_sched_getaffinity +#undef __NR_io_setup +#define __NR_io_setup (0 +243) +#define SYS_io_setup __NR_io_setup +#undef __NR_io_destroy +#define __NR_io_destroy (0 +244) +#define SYS_io_destroy __NR_io_destroy +#undef __NR_io_getevents +#define __NR_io_getevents (0 +245) +#define SYS_io_getevents __NR_io_getevents +#undef __NR_io_submit +#define __NR_io_submit (0 +246) +#define SYS_io_submit __NR_io_submit +#undef __NR_io_cancel +#define __NR_io_cancel (0 +247) +#define SYS_io_cancel __NR_io_cancel +#undef __NR_exit_group +#define __NR_exit_group (0 +248) +#define SYS_exit_group __NR_exit_group +#undef __NR_lookup_dcookie +#define __NR_lookup_dcookie (0 +249) +#define SYS_lookup_dcookie __NR_lookup_dcookie +#undef __NR_epoll_create +#define __NR_epoll_create (0 +250) +#define SYS_epoll_create __NR_epoll_create +#undef __NR_epoll_ctl +#define __NR_epoll_ctl (0 +251) +#define SYS_epoll_ctl __NR_epoll_ctl +#undef __NR_epoll_wait +#define __NR_epoll_wait (0 +252) +#define SYS_epoll_wait __NR_epoll_wait +#undef __NR_remap_file_pages +#define __NR_remap_file_pages (0 +253) +#define SYS_remap_file_pages __NR_remap_file_pages +#undef __NR_set_tid_address +#define __NR_set_tid_address (0 +256) +#define SYS_set_tid_address __NR_set_tid_address +#undef __NR_timer_create +#define __NR_timer_create (0 +257) +#define SYS_timer_create __NR_timer_create +#undef __NR_timer_settime +#define __NR_timer_settime (0 +258) +#define SYS_timer_settime __NR_timer_settime +#undef __NR_timer_gettime +#define __NR_timer_gettime (0 +259) +#define SYS_timer_gettime __NR_timer_gettime +#undef __NR_timer_getoverrun +#define __NR_timer_getoverrun (0 +260) +#define SYS_timer_getoverrun __NR_timer_getoverrun +#undef __NR_timer_delete +#define __NR_timer_delete (0 +261) +#define SYS_timer_delete __NR_timer_delete +#undef __NR_clock_settime +#define __NR_clock_settime (0 +262) +#define SYS_clock_settime __NR_clock_settime +#undef __NR_clock_gettime +#define __NR_clock_gettime (0 +263) +#define SYS_clock_gettime __NR_clock_gettime +#undef __NR_clock_getres +#define __NR_clock_getres (0 +264) +#define SYS_clock_getres __NR_clock_getres +#undef __NR_clock_nanosleep +#define __NR_clock_nanosleep (0 +265) +#define SYS_clock_nanosleep __NR_clock_nanosleep +#undef __NR_statfs64 +#define __NR_statfs64 (0 +266) +#define SYS_statfs64 __NR_statfs64 +#undef __NR_fstatfs64 +#define __NR_fstatfs64 (0 +267) +#define SYS_fstatfs64 __NR_fstatfs64 +#undef __NR_tgkill +#define __NR_tgkill (0 +268) +#define SYS_tgkill __NR_tgkill +#undef __NR_utimes +#define __NR_utimes (0 +269) +#define SYS_utimes __NR_utimes +#undef __NR_arm_fadvise64_64 +#define __NR_arm_fadvise64_64 (0 +270) +#define SYS_arm_fadvise64_64 __NR_arm_fadvise64_64 +#undef __NR_pciconfig_iobase +#define __NR_pciconfig_iobase (0 +271) +#define SYS_pciconfig_iobase __NR_pciconfig_iobase +#undef __NR_pciconfig_read +#define __NR_pciconfig_read (0 +272) +#define SYS_pciconfig_read __NR_pciconfig_read +#undef __NR_pciconfig_write +#define __NR_pciconfig_write (0 +273) +#define SYS_pciconfig_write __NR_pciconfig_write +#undef __NR_mq_open +#define __NR_mq_open (0 +274) +#define SYS_mq_open __NR_mq_open +#undef __NR_mq_unlink +#define __NR_mq_unlink (0 +275) +#define SYS_mq_unlink __NR_mq_unlink +#undef __NR_mq_timedsend +#define __NR_mq_timedsend (0 +276) +#define SYS_mq_timedsend __NR_mq_timedsend +#undef __NR_mq_timedreceive +#define __NR_mq_timedreceive (0 +277) +#define SYS_mq_timedreceive __NR_mq_timedreceive +#undef __NR_mq_notify +#define __NR_mq_notify (0 +278) +#define SYS_mq_notify __NR_mq_notify +#undef __NR_mq_getsetattr +#define __NR_mq_getsetattr (0 +279) +#define SYS_mq_getsetattr __NR_mq_getsetattr +#undef __NR_waitid +#define __NR_waitid (0 +280) +#define SYS_waitid __NR_waitid +#undef __NR_socket +#define __NR_socket (0 +281) +#define SYS_socket __NR_socket +#undef __NR_bind +#define __NR_bind (0 +282) +#define SYS_bind __NR_bind +#undef __NR_connect +#define __NR_connect (0 +283) +#define SYS_connect __NR_connect +#undef __NR_listen +#define __NR_listen (0 +284) +#define SYS_listen __NR_listen +#undef __NR_accept +#define __NR_accept (0 +285) +#define SYS_accept __NR_accept +#undef __NR_getsockname +#define __NR_getsockname (0 +286) +#define SYS_getsockname __NR_getsockname +#undef __NR_getpeername +#define __NR_getpeername (0 +287) +#define SYS_getpeername __NR_getpeername +#undef __NR_socketpair +#define __NR_socketpair (0 +288) +#define SYS_socketpair __NR_socketpair +#undef __NR_send +#define __NR_send (0 +289) +#define SYS_send __NR_send +#undef __NR_sendto +#define __NR_sendto (0 +290) +#define SYS_sendto __NR_sendto +#undef __NR_recv +#define __NR_recv (0 +291) +#define SYS_recv __NR_recv +#undef __NR_recvfrom +#define __NR_recvfrom (0 +292) +#define SYS_recvfrom __NR_recvfrom +#undef __NR_shutdown +#define __NR_shutdown (0 +293) +#define SYS_shutdown __NR_shutdown +#undef __NR_setsockopt +#define __NR_setsockopt (0 +294) +#define SYS_setsockopt __NR_setsockopt +#undef __NR_getsockopt +#define __NR_getsockopt (0 +295) +#define SYS_getsockopt __NR_getsockopt +#undef __NR_sendmsg +#define __NR_sendmsg (0 +296) +#define SYS_sendmsg __NR_sendmsg +#undef __NR_recvmsg +#define __NR_recvmsg (0 +297) +#define SYS_recvmsg __NR_recvmsg +#undef __NR_semop +#define __NR_semop (0 +298) +#define SYS_semop __NR_semop +#undef __NR_semget +#define __NR_semget (0 +299) +#define SYS_semget __NR_semget +#undef __NR_semctl +#define __NR_semctl (0 +300) +#define SYS_semctl __NR_semctl +#undef __NR_msgsnd +#define __NR_msgsnd (0 +301) +#define SYS_msgsnd __NR_msgsnd +#undef __NR_msgrcv +#define __NR_msgrcv (0 +302) +#define SYS_msgrcv __NR_msgrcv +#undef __NR_msgget +#define __NR_msgget (0 +303) +#define SYS_msgget __NR_msgget +#undef __NR_msgctl +#define __NR_msgctl (0 +304) +#define SYS_msgctl __NR_msgctl +#undef __NR_shmat +#define __NR_shmat (0 +305) +#define SYS_shmat __NR_shmat +#undef __NR_shmdt +#define __NR_shmdt (0 +306) +#define SYS_shmdt __NR_shmdt +#undef __NR_shmget +#define __NR_shmget (0 +307) +#define SYS_shmget __NR_shmget +#undef __NR_shmctl +#define __NR_shmctl (0 +308) +#define SYS_shmctl __NR_shmctl +#undef __NR_add_key +#define __NR_add_key (0 +309) +#define SYS_add_key __NR_add_key +#undef __NR_request_key +#define __NR_request_key (0 +310) +#define SYS_request_key __NR_request_key +#undef __NR_keyctl +#define __NR_keyctl (0 +311) +#define SYS_keyctl __NR_keyctl +#undef __NR_semtimedop +#define __NR_semtimedop (0 +312) +#define SYS_semtimedop __NR_semtimedop +#undef __NR_vserver +#define __NR_vserver (0 +313) +#define SYS_vserver __NR_vserver +#undef __NR_ioprio_set +#define __NR_ioprio_set (0 +314) +#define SYS_ioprio_set __NR_ioprio_set +#undef __NR_ioprio_get +#define __NR_ioprio_get (0 +315) +#define SYS_ioprio_get __NR_ioprio_get +#undef __NR_inotify_init +#define __NR_inotify_init (0 +316) +#define SYS_inotify_init __NR_inotify_init +#undef __NR_inotify_add_watch +#define __NR_inotify_add_watch (0 +317) +#define SYS_inotify_add_watch __NR_inotify_add_watch +#undef __NR_inotify_rm_watch +#define __NR_inotify_rm_watch (0 +318) +#define SYS_inotify_rm_watch __NR_inotify_rm_watch +#undef __NR_mbind +#define __NR_mbind (0 +319) +#define SYS_mbind __NR_mbind +#undef __NR_get_mempolicy +#define __NR_get_mempolicy (0 +320) +#define SYS_get_mempolicy __NR_get_mempolicy +#undef __NR_set_mempolicy +#define __NR_set_mempolicy (0 +321) +#define SYS_set_mempolicy __NR_set_mempolicy +#undef __NR_openat +#define __NR_openat (0 +322) +#define SYS_openat __NR_openat +#undef __NR_mkdirat +#define __NR_mkdirat (0 +323) +#define SYS_mkdirat __NR_mkdirat +#undef __NR_mknodat +#define __NR_mknodat (0 +324) +#define SYS_mknodat __NR_mknodat +#undef __NR_fchownat +#define __NR_fchownat (0 +325) +#define SYS_fchownat __NR_fchownat +#undef __NR_futimesat +#define __NR_futimesat (0 +326) +#define SYS_futimesat __NR_futimesat +#undef __NR_fstatat64 +#define __NR_fstatat64 (0 +327) +#define SYS_fstatat64 __NR_fstatat64 +#undef __NR_unlinkat +#define __NR_unlinkat (0 +328) +#define SYS_unlinkat __NR_unlinkat +#undef __NR_renameat +#define __NR_renameat (0 +329) +#define SYS_renameat __NR_renameat +#undef __NR_linkat +#define __NR_linkat (0 +330) +#define SYS_linkat __NR_linkat +#undef __NR_symlinkat +#define __NR_symlinkat (0 +331) +#define SYS_symlinkat __NR_symlinkat +#undef __NR_readlinkat +#define __NR_readlinkat (0 +332) +#define SYS_readlinkat __NR_readlinkat +#undef __NR_fchmodat +#define __NR_fchmodat (0 +333) +#define SYS_fchmodat __NR_fchmodat +#undef __NR_faccessat +#define __NR_faccessat (0 +334) +#define SYS_faccessat __NR_faccessat +#undef __NR_unshare +#define __NR_unshare (0 +337) +#define SYS_unshare __NR_unshare +#undef __NR_set_robust_list +#define __NR_set_robust_list (0 +338) +#define SYS_set_robust_list __NR_set_robust_list +#undef __NR_get_robust_list +#define __NR_get_robust_list (0 +339) +#define SYS_get_robust_list __NR_get_robust_list +#undef __NR_splice +#define __NR_splice (0 +340) +#define SYS_splice __NR_splice +#undef __NR_arm_sync_file_range +#define __NR_arm_sync_file_range (0 +341) +#define SYS_arm_sync_file_range __NR_arm_sync_file_range +#undef __NR_sync_file_range2 +#define __NR_sync_file_range2 (0 +341) +#define SYS_sync_file_range2 __NR_sync_file_range2 +#undef __NR_tee +#define __NR_tee (0 +342) +#define SYS_tee __NR_tee +#undef __NR_vmsplice +#define __NR_vmsplice (0 +343) +#define SYS_vmsplice __NR_vmsplice +#undef __NR_move_pages +#define __NR_move_pages (0 +344) +#define SYS_move_pages __NR_move_pages +#undef __NR_getcpu +#define __NR_getcpu (0 +345) +#define SYS_getcpu __NR_getcpu +#undef __NR_kexec_load +#define __NR_kexec_load (0 +347) +#define SYS_kexec_load __NR_kexec_load +#undef __NR_utimensat +#define __NR_utimensat (0 +348) +#define SYS_utimensat __NR_utimensat +#undef __NR_signalfd +#define __NR_signalfd (0 +349) +#define SYS_signalfd __NR_signalfd +#undef __NR_timerfd +#define __NR_timerfd (0 +350) +#define SYS_timerfd __NR_timerfd +#undef __NR_eventfd +#define __NR_eventfd (0 +351) +#define SYS_eventfd __NR_eventfd +#undef __NR_time +#undef __NR_umount +#undef __NR_stime +#undef __NR_alarm +#undef __NR_utime +#undef __NR_getrlimit +#undef __NR_select +#undef __NR_readdir +#undef __NR_mmap +#undef __NR_socketcall +#undef __NR_syscall +#undef __NR_ipc + +#endif diff --git a/conts/posix/libposix/include/posix/bits/termios.h b/conts/posix/libposix/include/posix/bits/termios.h new file mode 100644 index 0000000..03a8e41 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/termios.h @@ -0,0 +1,222 @@ +/* termios type and macro definitions. Linux version. + Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2003, 2005 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _TERMIOS_H +# error "Never include directly; use instead." +#endif + +typedef unsigned char cc_t; +typedef unsigned int speed_t; +typedef unsigned int tcflag_t; + +#define NCCS 32 +struct termios + { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[NCCS]; /* control characters */ + speed_t c_ispeed; /* input speed */ + speed_t c_ospeed; /* output speed */ +#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1 +#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1 + }; + +/* c_cc characters */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSWTC 7 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 +#define VREPRINT 12 +#define VDISCARD 13 +#define VWERASE 14 +#define VLNEXT 15 +#define VEOL2 16 + +/* c_iflag bits */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 +#define IUTF8 0040000 + +/* c_oflag bits */ +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#if defined __USE_MISC || defined __USE_XOPEN +# define NLDLY 0000400 +# define NL0 0000000 +# define NL1 0000400 +# define CRDLY 0003000 +# define CR0 0000000 +# define CR1 0001000 +# define CR2 0002000 +# define CR3 0003000 +# define TABDLY 0014000 +# define TAB0 0000000 +# define TAB1 0004000 +# define TAB2 0010000 +# define TAB3 0014000 +# define BSDLY 0020000 +# define BS0 0000000 +# define BS1 0020000 +# define FFDLY 0100000 +# define FF0 0000000 +# define FF1 0100000 +#endif + +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 + +#ifdef __USE_MISC +# define XTABS 0014000 +#endif + +/* c_cflag bit meaning */ +#ifdef __USE_MISC +# define CBAUD 0010017 +#endif +#define B0 0000000 /* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +#ifdef __USE_MISC +# define EXTA B19200 +# define EXTB B38400 +#endif +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 +#ifdef __USE_MISC +# define CBAUDEX 0010000 +#endif +#define B57600 0010001 +#define B115200 0010002 +#if 0 /* limited on uClibc, keep in sync w/ cfsetspeed.c */ +#define B230400 0010003 +#define B460800 0010004 +#define B500000 0010005 +#define B576000 0010006 +#define B921600 0010007 +#define B1000000 0010010 +#define B1152000 0010011 +#define B1500000 0010012 +#define B2000000 0010013 +#define B2500000 0010014 +#define B3000000 0010015 +#define B3500000 0010016 +#define B4000000 0010017 +#define __MAX_BAUD B4000000 +#else +#define __MAX_BAUD B115200 +#endif +#ifdef __USE_MISC +# define CIBAUD 002003600000 /* input baud rate (not used) */ +# define CMSPAR 010000000000 /* mark or space (stick) parity */ +# define CRTSCTS 020000000000 /* flow control */ +#endif + +/* c_lflag bits */ +#define ISIG 0000001 +#define ICANON 0000002 +#if defined __USE_MISC || defined __USE_XOPEN +# define XCASE 0000004 +#endif +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#ifdef __USE_MISC +# define ECHOCTL 0001000 +# define ECHOPRT 0002000 +# define ECHOKE 0004000 +# define FLUSHO 0010000 +# define PENDIN 0040000 +#endif +#define IEXTEN 0100000 + +/* tcflow() and TCXONC use these */ +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + +/* tcflush() and TCFLSH use these */ +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +/* tcsetattr uses these */ +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + + +#define _IOT_termios /* Hurd ioctl type field. */ \ + _IOT (_IOTS (cflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2) diff --git a/conts/posix/libposix/include/posix/bits/time.h b/conts/posix/libposix/include/posix/bits/time.h new file mode 100644 index 0000000..7ed54bf --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/time.h @@ -0,0 +1,79 @@ +/* System-dependent timing definitions. Generic version. + Copyright (C) 1996,1997,1999-2002,2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * Never include this file directly; use instead. + */ + +#ifndef __need_timeval +# ifndef _BITS_TIME_H +# define _BITS_TIME_H 1 + +/* ISO/IEC 9899:1990 7.12.1: + The macro `CLOCKS_PER_SEC' is the number per second of the value + returned by the `clock' function. */ +/* CAE XSH, Issue 4, Version 2: + The value of CLOCKS_PER_SEC is required to be 1 million on all + XSI-conformant systems. */ +# define CLOCKS_PER_SEC 1000000l + +/* Get the arch-specific value of __UCLIBC_CLK_TCK_CONST used for CLK_TCK + * in sysconf() and clock(). */ +#include + +# if !defined __STRICT_ANSI__ && !defined __USE_XOPEN2K +/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK + presents the real value for clock ticks per second for the system. */ +# include +/* Note (uClibc): glibc #defines CLK_TCK as a sysconf() call. */ +# define CLK_TCK ((__clock_t) __UCLIBC_CLK_TCK_CONST) +# endif + +# ifdef __USE_POSIX199309 +/* Identifier for system-wide realtime clock. */ +# define CLOCK_REALTIME 0 +/* Monotonic system-wide clock. */ +# define CLOCK_MONOTONIC 1 +/* High-resolution timer from the CPU. */ +# define CLOCK_PROCESS_CPUTIME_ID 2 +/* Thread-specific CPU-time clock. */ +# define CLOCK_THREAD_CPUTIME_ID 3 + +/* Flag to indicate time is absolute. */ +# define TIMER_ABSTIME 1 +# endif + +# endif /* bits/time.h */ +#endif + +#ifdef __need_timeval +# undef __need_timeval +# ifndef _STRUCT_TIMEVAL +# define _STRUCT_TIMEVAL 1 +# include + +/* A time value that is accurate to the nearest + microsecond but also has a range of years. */ +struct timeval + { + __time_t tv_sec; /* Seconds. */ + __suseconds_t tv_usec; /* Microseconds. */ + }; +# endif /* struct timeval */ +#endif /* need timeval */ diff --git a/conts/posix/libposix/include/posix/bits/types.h b/conts/posix/libposix/include/posix/bits/types.h new file mode 100644 index 0000000..755af2e --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/types.h @@ -0,0 +1,209 @@ +/* bits/types.h -- definitions of __*_t types underlying *_t types. + Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * Never include this file directly; use instead. + */ + +#ifndef _BITS_TYPES_H +#define _BITS_TYPES_H 1 + +#include +#include + +#define __need_size_t +#include +#include + +/* Convenience types. */ +typedef unsigned char __u_char; +typedef unsigned short int __u_short; +typedef unsigned int __u_int; +typedef unsigned long int __u_long; + +/* Fixed-size types, underlying types depend on word size and compiler. */ +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef signed short int __int16_t; +typedef unsigned short int __uint16_t; +typedef signed int __int32_t; +typedef unsigned int __uint32_t; +#if __WORDSIZE == 64 +typedef signed long int __int64_t; +typedef unsigned long int __uint64_t; +#elif defined(__GNUC__) +__extension__ typedef signed long long int __int64_t; +__extension__ typedef unsigned long long int __uint64_t; +#endif + +/* quad_t is also 64 bits. */ +#if __WORDSIZE == 64 +typedef long int __quad_t; +typedef unsigned long int __u_quad_t; +#elif defined(__GNUC__) +__extension__ typedef long long int __quad_t; +__extension__ typedef unsigned long long int __u_quad_t; +#else +typedef struct +{ + long __val[2]; +} __quad_t; +typedef struct +{ + __u_long __val[2]; +} __u_quad_t; +#endif + + +/* The machine-dependent file defines __*_T_TYPE + macros for each of the OS types we define below. The definitions + of those macros must use the following macros for underlying types. + We define __S_TYPE and __U_TYPE for the signed and unsigned + variants of each of the following integer types on this machine. + + 16 -- "natural" 16-bit type (always short) + 32 -- "natural" 32-bit type (always int) + 64 -- "natural" 64-bit type (long or long long) + LONG32 -- 32-bit type, traditionally long + QUAD -- 64-bit type, always long long + WORD -- natural type of __WORDSIZE bits (int or long) + LONGWORD -- type of __WORDSIZE bits, traditionally long + + We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the + conventional uses of `long' or `long long' type modifiers match the + types we define, even when a less-adorned type would be the same size. + This matters for (somewhat) portably writing printf/scanf formats for + these types, where using the appropriate l or ll format modifiers can + make the typedefs and the formats match up across all GNU platforms. If + we used `long' when it's 64 bits where `long long' is expected, then the + compiler would warn about the formats not matching the argument types, + and the programmer changing them to shut up the compiler would break the + program's portability. + + Here we assume what is presently the case in all the GCC configurations + we support: long long is always 64 bits, long is always word/address size, + and int is always 32 bits. */ + +#define __S16_TYPE short int +#define __U16_TYPE unsigned short int +#define __S32_TYPE int +#define __U32_TYPE unsigned int +#define __SLONGWORD_TYPE long int +#define __ULONGWORD_TYPE unsigned long int +#if __WORDSIZE == 32 +# define __SQUAD_TYPE __quad_t +# define __UQUAD_TYPE __u_quad_t +# define __SWORD_TYPE int +# define __UWORD_TYPE unsigned int +# define __SLONG32_TYPE long int +# define __ULONG32_TYPE unsigned long int +# define __S64_TYPE __quad_t +# define __U64_TYPE __u_quad_t +/* We want __extension__ before typedef's that use nonstandard base types + such as `long long' in C89 mode. */ +# define __STD_TYPE __extension__ typedef +#elif __WORDSIZE == 64 +# define __SQUAD_TYPE long int +# define __UQUAD_TYPE unsigned long int +# define __SWORD_TYPE long int +# define __UWORD_TYPE unsigned long int +# define __SLONG32_TYPE int +# define __ULONG32_TYPE unsigned int +# define __S64_TYPE long int +# define __U64_TYPE unsigned long int +/* No need to mark the typedef with __extension__. */ +# define __STD_TYPE typedef +#else +# error +#endif +#include /* Defines __*_T_TYPE macros. */ + + +__STD_TYPE __DEV_T_TYPE __dev_t; /* Type of device numbers. */ +__STD_TYPE __UID_T_TYPE __uid_t; /* Type of user identifications. */ +__STD_TYPE __GID_T_TYPE __gid_t; /* Type of group identifications. */ +__STD_TYPE __INO_T_TYPE __ino_t; /* Type of file serial numbers. */ +__STD_TYPE __INO64_T_TYPE __ino64_t; /* Type of file serial numbers (LFS).*/ +__STD_TYPE __MODE_T_TYPE __mode_t; /* Type of file attribute bitmasks. */ +__STD_TYPE __NLINK_T_TYPE __nlink_t; /* Type of file link counts. */ +__STD_TYPE __OFF_T_TYPE __off_t; /* Type of file sizes and offsets. */ +__STD_TYPE __OFF64_T_TYPE __off64_t; /* Type of file sizes and offsets (LFS). */ +__STD_TYPE __PID_T_TYPE __pid_t; /* Type of process identifications. */ +__STD_TYPE __FSID_T_TYPE __fsid_t; /* Type of file system IDs. */ +__STD_TYPE __CLOCK_T_TYPE __clock_t; /* Type of CPU usage counts. */ +__STD_TYPE __RLIM_T_TYPE __rlim_t; /* Type for resource measurement. */ +__STD_TYPE __RLIM64_T_TYPE __rlim64_t; /* Type for resource measurement (LFS). */ +__STD_TYPE __ID_T_TYPE __id_t; /* General type for IDs. */ +__STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */ +__STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds. */ +__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds. */ + +__STD_TYPE __DADDR_T_TYPE __daddr_t; /* The type of a disk address. */ +__STD_TYPE __SWBLK_T_TYPE __swblk_t; /* Type of a swap block maybe? */ +__STD_TYPE __KEY_T_TYPE __key_t; /* Type of an IPC key. */ + +/* Clock ID used in clock and timer functions. */ +__STD_TYPE __CLOCKID_T_TYPE __clockid_t; + +/* Timer ID returned by `timer_create'. */ +__STD_TYPE __TIMER_T_TYPE __timer_t; + +/* Type to represent block size. */ +__STD_TYPE __BLKSIZE_T_TYPE __blksize_t; + +/* Types from the Large File Support interface. */ + +/* Type to count number of disk blocks. */ +__STD_TYPE __BLKCNT_T_TYPE __blkcnt_t; +__STD_TYPE __BLKCNT64_T_TYPE __blkcnt64_t; + +/* Type to count file system blocks. */ +__STD_TYPE __FSBLKCNT_T_TYPE __fsblkcnt_t; +__STD_TYPE __FSBLKCNT64_T_TYPE __fsblkcnt64_t; + +/* Type to count file system nodes. */ +__STD_TYPE __FSFILCNT_T_TYPE __fsfilcnt_t; +__STD_TYPE __FSFILCNT64_T_TYPE __fsfilcnt64_t; + +__STD_TYPE __SSIZE_T_TYPE __ssize_t; /* Type of a byte count, or error. */ + +/* These few don't really vary by system, they always correspond + to one of the other defined types. */ +typedef __off64_t __loff_t; /* Type of file sizes and offsets (LFS). */ +typedef __quad_t *__qaddr_t; +typedef char *__caddr_t; + +/* Duplicates info from stdint.h but this is used in unistd.h. */ +__STD_TYPE __SWORD_TYPE __intptr_t; + +/* Duplicate info from sys/socket.h. */ +__STD_TYPE __U32_TYPE __socklen_t; + + +#undef __STD_TYPE + +/* Used in `struct shmid_ds'. */ +typedef __kernel_ipc_pid_t __ipc_pid_t; + +/* Now add the thread types. */ +#if defined __UCLIBC_HAS_THREADS__ && (defined __USE_POSIX199506 || defined __USE_UNIX98) +# include +#endif + +#endif /* bits/types.h */ diff --git a/conts/posix/libposix/include/posix/bits/typesizes.h b/conts/posix/libposix/include/posix/bits/typesizes.h new file mode 100644 index 0000000..e9226c4 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/typesizes.h @@ -0,0 +1,66 @@ +/* bits/typesizes.h -- underlying types for *_t. Generic version. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _BITS_TYPES_H +# error "Never include directly; use instead." +#endif + +#ifndef _BITS_TYPESIZES_H +#define _BITS_TYPESIZES_H 1 + +/* See for the meaning of these macros. This file exists so + that need not vary across different GNU platforms. */ + +#define __DEV_T_TYPE __UQUAD_TYPE +#define __UID_T_TYPE __U32_TYPE +#define __GID_T_TYPE __U32_TYPE +#define __INO_T_TYPE __ULONGWORD_TYPE +#define __INO64_T_TYPE __UQUAD_TYPE +#define __MODE_T_TYPE __U32_TYPE +#define __NLINK_T_TYPE __UWORD_TYPE +#define __OFF_T_TYPE __SLONGWORD_TYPE +#define __OFF64_T_TYPE __SQUAD_TYPE +#define __PID_T_TYPE __S32_TYPE +#define __RLIM_T_TYPE __ULONGWORD_TYPE +#define __RLIM64_T_TYPE __UQUAD_TYPE +#define __BLKCNT_T_TYPE __SLONGWORD_TYPE +#define __BLKCNT64_T_TYPE __SQUAD_TYPE +#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE +#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE +#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE +#define __FSFILCNT64_T_TYPE __UQUAD_TYPE +#define __ID_T_TYPE __U32_TYPE +#define __CLOCK_T_TYPE __SLONGWORD_TYPE +#define __TIME_T_TYPE __SLONGWORD_TYPE +#define __USECONDS_T_TYPE __U32_TYPE +#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE +#define __DADDR_T_TYPE __S32_TYPE +#define __SWBLK_T_TYPE __SLONGWORD_TYPE +#define __KEY_T_TYPE __S32_TYPE +#define __CLOCKID_T_TYPE __S32_TYPE +#define __TIMER_T_TYPE void * +#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE +#define __FSID_T_TYPE struct { int __val[2]; } +#define __SSIZE_T_TYPE __SWORD_TYPE + +/* Number of descriptors that can fit in an `fd_set'. */ +#define __FD_SETSIZE 1024 + + +#endif /* bits/typesizes.h */ diff --git a/conts/posix/libposix/include/posix/bits/uClibc_arch_features.h b/conts/posix/libposix/include/posix/bits/uClibc_arch_features.h new file mode 100644 index 0000000..93b523f --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_arch_features.h @@ -0,0 +1,41 @@ +/* + * Track misc arch-specific features that aren't config options + */ + +#ifndef _BITS_UCLIBC_ARCH_FEATURES_H +#define _BITS_UCLIBC_ARCH_FEATURES_H + +/* instruction used when calling abort() to kill yourself */ +#define __UCLIBC_ABORT_INSTRUCTION__ "bl abort" + +/* can your target use syscall6() for mmap ? */ +#undef __UCLIBC_MMAP_HAS_6_ARGS__ + +/* does your target use syscall4() for truncate64 ? (32bit arches only) */ +#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__ + +/* does your target have a broken create_module() ? */ +#define __UCLIBC_BROKEN_CREATE_MODULE__ + +/* does your target prefix all symbols with an _ ? */ +#define __UCLIBC_NO_UNDERSCORES__ + +/* does your target have an asm .set ? */ +#define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__ + +/* define if target doesn't like .global */ +#undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__ + +/* define if target supports .weak */ +#define __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__ + +/* define if target supports .weakext */ +#undef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__ + +/* needed probably only for ppc64 */ +#undef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__ + +/* define if target supports IEEE signed zero floats */ +#define __UCLIBC_HAVE_SIGNED_ZERO__ + +#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */ diff --git a/conts/posix/libposix/include/posix/bits/uClibc_clk_tck.h b/conts/posix/libposix/include/posix/bits/uClibc_clk_tck.h new file mode 100644 index 0000000..00b77bf --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_clk_tck.h @@ -0,0 +1,8 @@ +/* Use a default of 100 for CLK_TCK to implement sysconf() and clock(). + * Override this by supplying an arch-specific version of this header file. + * + * WARNING: It is assumed that this is a constant integer value usable in + * preprocessor conditionals!!! + */ + +#define __UCLIBC_CLK_TCK_CONST 100 diff --git a/conts/posix/libposix/include/posix/bits/uClibc_config.h b/conts/posix/libposix/include/posix/bits/uClibc_config.h new file mode 100644 index 0000000..a4fcc99 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_config.h @@ -0,0 +1,198 @@ +#if !defined __FEATURES_H && !defined __need_uClibc_config_h +# error Never include directly; use instead +#endif + +#define __UCLIBC_MAJOR__ 0 +#define __UCLIBC_MINOR__ 9 +#define __UCLIBC_SUBLEVEL__ 29 +/* Automatically generated make config: don't edit */ +/* Sat Jan 12 11:19:30 2008 */ +#undef __TARGET_alpha__ +#define __TARGET_arm__ 1 +#undef __TARGET_avr32__ +#undef __TARGET_bfin__ +#undef __TARGET_cris__ +#undef __TARGET_e1__ +#undef __TARGET_frv__ +#undef __TARGET_h8300__ +#undef __TARGET_hppa__ +#undef __TARGET_i386__ +#undef __TARGET_i960__ +#undef __TARGET_ia64__ +#undef __TARGET_m68k__ +#undef __TARGET_microblaze__ +#undef __TARGET_mips__ +#undef __TARGET_nios__ +#undef __TARGET_nios2__ +#undef __TARGET_powerpc__ +#undef __TARGET_sh__ +#undef __TARGET_sh64__ +#undef __TARGET_sparc__ +#undef __TARGET_v850__ +#undef __TARGET_vax__ +#undef __TARGET_x86_64__ + +/* Target Architecture Features and Options */ +#define __TARGET_ARCH__ "arm" +#define __FORCE_OPTIONS_FOR_ARCH__ 1 +#undef __CONFIG_ARM_OABI__ +#define __CONFIG_ARM_EABI__ 1 +#define __CONFIG_GENERIC_ARM__ 1 +#undef __CONFIG_ARM610__ +#undef __CONFIG_ARM710__ +#undef __CONFIG_ARM7TDMI__ +#undef __CONFIG_ARM720T__ +#undef __CONFIG_ARM920T__ +#undef __CONFIG_ARM922T__ +#undef __CONFIG_ARM926T__ +#undef __CONFIG_ARM10T__ +#undef __CONFIG_ARM1136JF_S__ +#undef __CONFIG_ARM1176JZ_S__ +#undef __CONFIG_ARM1176JZF_S__ +#undef __CONFIG_ARM_SA110__ +#undef __CONFIG_ARM_SA1100__ +#undef __CONFIG_ARM_XSCALE__ +#undef __CONFIG_ARM_IWMMXT__ +#define __TARGET_SUBARCH__ "" + +/* Using ELF file format */ +#define __ARCH_ANY_ENDIAN__ 1 +#define __ARCH_LITTLE_ENDIAN__ 1 +#undef __ARCH_WANTS_BIG_ENDIAN__ +#define __ARCH_WANTS_LITTLE_ENDIAN__ 1 +#define __ARCH_HAS_MMU__ 1 +#define __ARCH_USE_MMU__ 1 +#define __UCLIBC_HAS_FLOATS__ 1 +#define __UCLIBC_HAS_FPU__ 1 +#define __DO_C99_MATH__ 1 +#define __KERNEL_HEADERS__ "/opt/l4-project/tasks/libc/linux-headers/include" +#define __HAVE_DOT_CONFIG__ 1 + +/* General Library Settings */ +#undef __HAVE_NO_PIC__ +#define __DOPIC__ 1 +#undef __HAVE_NO_SHARED__ +#undef __ARCH_HAS_NO_LDSO__ +#define __HAVE_SHARED__ 1 +#undef __FORCE_SHAREABLE_TEXT_SEGMENTS__ +#define __LDSO_LDD_SUPPORT__ 1 +#define __LDSO_CACHE_SUPPORT__ 1 +#undef __LDSO_PRELOAD_FILE_SUPPORT__ +#define __LDSO_BASE_FILENAME__ "ld.so" +#undef __UCLIBC_STATIC_LDCONFIG__ +#undef __LDSO_RUNPATH__ +#define __UCLIBC_CTOR_DTOR__ 1 +#undef __HAS_NO_THREADS__ +#define __UCLIBC_HAS_THREADS__ 1 +#undef __PTHREADS_DEBUG_SUPPORT__ +#define __LINUXTHREADS_OLD__ 1 +#define __UCLIBC_HAS_LFS__ 1 +#undef __MALLOC__ +#undef __MALLOC_SIMPLE__ +#define __MALLOC_STANDARD__ 1 +#define __MALLOC_GLIBC_COMPAT__ 1 +#define __UCLIBC_DYNAMIC_ATEXIT__ 1 +#undef __COMPAT_ATEXIT__ +#undef __UCLIBC_SUSV3_LEGACY__ +#undef __UCLIBC_SUSV3_LEGACY_MACROS__ +#define __UCLIBC_HAS_SHADOW__ 1 +#undef __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__ +#define __UCLIBC_HAS___PROGNAME__ 1 +#undef __UNIX98PTY_ONLY__ +#define __ASSUME_DEVPTS__ 1 +#define __UCLIBC_HAS_TM_EXTENSIONS__ 1 +#define __UCLIBC_HAS_TZ_CACHING__ 1 +#define __UCLIBC_HAS_TZ_FILE__ 1 +#define __UCLIBC_HAS_TZ_FILE_READ_MANY__ 1 +#define __UCLIBC_TZ_FILE_PATH__ "/etc/TZ" + +/* Advanced Library Settings */ +#define __UCLIBC_PWD_BUFFER_SIZE__ 256 +#define __UCLIBC_GRP_BUFFER_SIZE__ 256 + +/* Networking Support */ +#undef __UCLIBC_HAS_IPV6__ +#define __UCLIBC_HAS_RPC__ 1 +#define __UCLIBC_HAS_FULL_RPC__ 1 +#define __UCLIBC_HAS_REENTRANT_RPC__ 1 +#undef __UCLIBC_USE_NETLINK__ +#undef __UCLIBC_HAS_BSD_RES_CLOSE__ + +/* String and Stdio Support */ +#define __UCLIBC_HAS_STRING_GENERIC_OPT__ 1 +#define __UCLIBC_HAS_STRING_ARCH_OPT__ 1 +#define __UCLIBC_HAS_CTYPE_TABLES__ 1 +#define __UCLIBC_HAS_CTYPE_SIGNED__ 1 +#undef __UCLIBC_HAS_CTYPE_UNSAFE__ +#define __UCLIBC_HAS_CTYPE_CHECKED__ 1 +#undef __UCLIBC_HAS_CTYPE_ENFORCED__ +#undef __UCLIBC_HAS_WCHAR__ +#undef __UCLIBC_HAS_LOCALE__ +#define __UCLIBC_HAS_HEXADECIMAL_FLOATS__ 1 +#define __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__ 1 +#undef __USE_OLD_VFPRINTF__ +#define __UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS__ 9 +#define __UCLIBC_HAS_SCANF_GLIBC_A_FLAG__ 1 +#undef __UCLIBC_HAS_STDIO_BUFSIZ_NONE__ +#undef __UCLIBC_HAS_STDIO_BUFSIZ_256__ +#undef __UCLIBC_HAS_STDIO_BUFSIZ_512__ +#undef __UCLIBC_HAS_STDIO_BUFSIZ_1024__ +#undef __UCLIBC_HAS_STDIO_BUFSIZ_2048__ +#define __UCLIBC_HAS_STDIO_BUFSIZ_4096__ 1 +#undef __UCLIBC_HAS_STDIO_BUFSIZ_8192__ +#define __UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE__ 1 +#undef __UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4__ +#undef __UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8__ +#undef __UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT__ +#define __UCLIBC_HAS_STDIO_GETC_MACRO__ 1 +#define __UCLIBC_HAS_STDIO_PUTC_MACRO__ 1 +#define __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ 1 +#undef __UCLIBC_HAS_FOPEN_LARGEFILE_MODE__ +#define __UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE__ 1 +#define __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ 1 +#define __UCLIBC_HAS_PRINTF_M_SPEC__ 1 +#define __UCLIBC_HAS_ERRNO_MESSAGES__ 1 +#undef __UCLIBC_HAS_SYS_ERRLIST__ +#define __UCLIBC_HAS_SIGNUM_MESSAGES__ 1 +#undef __UCLIBC_HAS_SYS_SIGLIST__ +#define __UCLIBC_HAS_GNU_GETOPT__ 1 +#define __UCLIBC_HAS_GNU_GETSUBOPT__ 1 + +/* Big and Tall */ +#define __UCLIBC_HAS_REGEX__ 1 +#define __UCLIBC_HAS_REGEX_OLD__ 1 +#define __UCLIBC_HAS_FNMATCH__ 1 +#define __UCLIBC_HAS_FNMATCH_OLD__ 1 +#undef __UCLIBC_HAS_WORDEXP__ +#define __UCLIBC_HAS_FTW__ 1 +#define __UCLIBC_HAS_GLOB__ 1 +#define __UCLIBC_HAS_GNU_GLOB__ 1 + +/* Library Installation Options */ +#define __SHARED_LIB_LOADER_PREFIX__ "/lib" +#define __RUNTIME_PREFIX__ "/" +#define __DEVEL_PREFIX__ "/usr/" + +/* Security options */ +#undef __UCLIBC_BUILD_PIE__ +#undef __UCLIBC_HAS_ARC4RANDOM__ +#undef __HAVE_NO_SSP__ +#undef __UCLIBC_HAS_SSP__ +#define __UCLIBC_BUILD_RELRO__ 1 +#define __UCLIBC_BUILD_NOW__ 1 +#undef __UCLIBC_BUILD_NOEXECSTACK__ + +/* uClibc development/debugging options */ +#define __CROSS_COMPILER_PREFIX__ "/opt/scratch3/buildroot/build_arm/staging_dir/usr/bin/arm-linux-uclibcgnueabi-" +#define __UCLIBC_EXTRA_CFLAGS__ "" +#undef __DODEBUG__ +#undef __DODEBUG_PT__ +#define __DOSTRIP__ 1 +#undef __DOASSERTS__ +#undef __SUPPORT_LD_DEBUG__ +#undef __SUPPORT_LD_DEBUG_EARLY__ +#undef __UCLIBC_MALLOC_DEBUGGING__ +#define __WARNINGS__ "-Wall" +#undef __EXTRA_WARNINGS__ +#undef __DOMULTI__ +#undef __UCLIBC_MJN3_ONLY__ diff --git a/conts/posix/libposix/include/posix/bits/uClibc_ctype.h b/conts/posix/libposix/include/posix/bits/uClibc_ctype.h new file mode 100644 index 0000000..dd723c7 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_ctype.h @@ -0,0 +1,279 @@ +/* Copyright (C) 2002 Manuel Novoa III + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * The GNU C Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the GNU C Library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! + * + * Besides uClibc, I'm using this code in my libc for elks, which is + * a 16-bit environment with a fairly limited compiler. It would make + * things much easier for me if this file isn't modified unnecessarily. + * In particular, please put any new or replacement functions somewhere + * else, and modify the makefile to use your version instead. + * Thanks. Manuel + * + * ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */ + +#if !defined(_CTYPE_H) && !defined(_WCTYPE_H) +#error Always include <{w}ctype.h> rather than +#endif + +#ifndef _BITS_CTYPE_H +#define _BITS_CTYPE_H + +#ifdef __UCLIBC_GEN_LOCALE + +/* Taking advantage of the C99 mutual-exclusion guarantees for the various + * (w)ctype classes, including the descriptions of printing and control + * (w)chars, we can place each in one of the following mutually-exlusive + * subsets. Since there are less than 16, we can store the data for + * each (w)chars in a nibble. In contrast, glibc uses an unsigned int + * per (w)char, with one bit flag for each is* type. While this allows + * a simple '&' operation to determine the type vs. a range test and a + * little special handling for the "blank" and "xdigit" types in my + * approach, it also uses 8 times the space for the tables on the typical + * 32-bit archs we supported.*/ +enum { + __CTYPE_unclassified = 0, + __CTYPE_alpha_nonupper_nonlower, + __CTYPE_alpha_lower, + __CTYPE_alpha_upper_lower, + __CTYPE_alpha_upper, + __CTYPE_digit, + __CTYPE_punct, + __CTYPE_graph, + __CTYPE_print_space_nonblank, + __CTYPE_print_space_blank, + __CTYPE_space_nonblank_noncntrl, + __CTYPE_space_blank_noncntrl, + __CTYPE_cntrl_space_nonblank, + __CTYPE_cntrl_space_blank, + __CTYPE_cntrl_nonspace +}; + +/* Some macros that test for various (w)ctype classes when passed one of the + * designator values enumerated above. */ +#define __CTYPE_isalnum(D) ((unsigned int)(D-1) <= (__CTYPE_digit-1)) +#define __CTYPE_isalpha(D) ((unsigned int)(D-1) <= (__CTYPE_alpha_upper-1)) +#define __CTYPE_isblank(D) \ + ((((unsigned int)(D - __CTYPE_print_space_nonblank)) <= 5) && (D & 1)) +#define __CTYPE_iscntrl(D) (((unsigned int)(D - __CTYPE_cntrl_space_nonblank)) <= 2) +#define __CTYPE_isdigit(D) (D == __CTYPE_digit) +#define __CTYPE_isgraph(D) ((unsigned int)(D-1) <= (__CTYPE_graph-1)) +#define __CTYPE_islower(D) (((unsigned int)(D - __CTYPE_alpha_lower)) <= 1) +#define __CTYPE_isprint(D) ((unsigned int)(D-1) <= (__CTYPE_print_space_blank-1)) +#define __CTYPE_ispunct(D) (D == __CTYPE_punct) +#define __CTYPE_isspace(D) (((unsigned int)(D - __CTYPE_print_space_nonblank)) <= 5) +#define __CTYPE_isupper(D) (((unsigned int)(D - __CTYPE_alpha_upper_lower)) <= 1) +/* #define __CTYPE_isxdigit(D) -- isxdigit is untestable this way. + * But that's ok as isxdigit() (and isdigit() too) are locale-invariant. */ + +#else /* __UCLIBC_GEN_LOCALE *****************************************/ + +/* Define some ctype macros valid for the C/POSIX locale. */ + +/* ASCII ords of \t, \f, \n, \r, and \v are 9, 12, 10, 13, 11 respectively. */ +#define __C_isspace(c) \ + ((sizeof(c) == sizeof(char)) \ + ? ((((c) == ' ') || (((unsigned char)((c) - 9)) <= (13 - 9)))) \ + : ((((c) == ' ') || (((unsigned int)((c) - 9)) <= (13 - 9))))) +#define __C_isblank(c) (((c) == ' ') || ((c) == '\t')) +#define __C_isdigit(c) \ + ((sizeof(c) == sizeof(char)) \ + ? (((unsigned char)((c) - '0')) < 10) \ + : (((unsigned int)((c) - '0')) < 10)) +#define __C_isxdigit(c) \ + (__C_isdigit(c) \ + || ((sizeof(c) == sizeof(char)) \ + ? (((unsigned char)((((c)) | 0x20) - 'a')) < 6) \ + : (((unsigned int)((((c)) | 0x20) - 'a')) < 6))) +#define __C_iscntrl(c) \ + ((sizeof(c) == sizeof(char)) \ + ? ((((unsigned char)(c)) < 0x20) || ((c) == 0x7f)) \ + : ((((unsigned int)(c)) < 0x20) || ((c) == 0x7f))) +#define __C_isalpha(c) \ + ((sizeof(c) == sizeof(char)) \ + ? (((unsigned char)(((c) | 0x20) - 'a')) < 26) \ + : (((unsigned int)(((c) | 0x20) - 'a')) < 26)) +#define __C_isalnum(c) (__C_isalpha(c) || __C_isdigit(c)) +#define __C_isprint(c) \ + ((sizeof(c) == sizeof(char)) \ + ? (((unsigned char)((c) - 0x20)) <= (0x7e - 0x20)) \ + : (((unsigned int)((c) - 0x20)) <= (0x7e - 0x20))) +#define __C_islower(c) \ + ((sizeof(c) == sizeof(char)) \ + ? (((unsigned char)((c) - 'a')) < 26) \ + : (((unsigned int)((c) - 'a')) < 26)) +#define __C_isupper(c) \ + ((sizeof(c) == sizeof(char)) \ + ? (((unsigned char)((c) - 'A')) < 26) \ + : (((unsigned int)((c) - 'A')) < 26)) +#define __C_ispunct(c) \ + ((!__C_isalnum(c)) \ + && ((sizeof(c) == sizeof(char)) \ + ? (((unsigned char)((c) - 0x21)) <= (0x7e - 0x21)) \ + : (((unsigned int)((c) - 0x21)) <= (0x7e - 0x21)))) +#define __C_isgraph(c) \ + ((sizeof(c) == sizeof(char)) \ + ? (((unsigned int)((c) - 0x21)) <= (0x7e - 0x21)) \ + : (((unsigned int)((c) - 0x21)) <= (0x7e - 0x21))) + +#define __C_tolower(c) (__C_isupper(c) ? ((c) | 0x20) : (c)) +#define __C_toupper(c) (__C_islower(c) ? ((c) ^ 0x20) : (c)) + +/**********************************************************************/ +__BEGIN_DECLS + +extern int isalnum(int c) __THROW; +extern int isalpha(int c) __THROW; +#ifdef __USE_ISOC99 +extern int isblank(int c) __THROW; +#endif +extern int iscntrl(int c) __THROW; +extern int isdigit(int c) __THROW; +extern int isgraph(int c) __THROW; +extern int islower(int c) __THROW; +extern int isprint(int c) __THROW; +extern int ispunct(int c) __THROW; +extern int isspace(int c) __THROW; +extern int isupper(int c) __THROW; +extern int isxdigit(int c) __THROW; + +extern int tolower(int c) __THROW; +extern int toupper(int c) __THROW; + +#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN +extern int isascii(int c) __THROW; +extern int toascii(int c) __THROW; +#endif + +#if defined _LIBC && (defined NOT_IN_libc || defined IS_IN_libc) +/* isdigit() is really locale-invariant, so provide some small fast macros. + * These are uClibc-specific. */ +#define __isdigit_char(C) (((unsigned char)((C) - '0')) <= 9) +#define __isdigit_int(C) (((unsigned int)((C) - '0')) <= 9) +#endif + +/* Next, some ctype macros which are valid for all supported locales. */ +/* WARNING: isspace and isblank need to be reverified if more 8-bit codesets + * are added!!! But isdigit and isxdigit are always valid. */ + +/* #define __isspace(c) __C_isspace(c) */ +/* #define __isblank(c) __C_isblank(c) */ + +/* #define __isdigit(c) __C_isdigit(c) */ +/* #define __isxdigit(c) __C_isxdigit(c) */ + +/* Now some non-ansi/iso c99 macros. */ + +#define __isascii(c) (((c) & ~0x7f) == 0) +#define __toascii(c) ((c) & 0x7f) +#define _toupper(c) ((c) ^ 0x20) +#define _tolower(c) ((c) | 0x20) + +__END_DECLS + +/**********************************************************************/ +#ifdef __GNUC__ + +#define __isbody_C_macro(f,args) __C_ ## f args + +#define __isbody(f,c) \ + (__extension__ ({ \ + int __res; \ + if (sizeof(c) > sizeof(char)) { \ + int __c = (c); \ + __res = __isbody_C_macro(f,(__c)); \ + } else { \ + unsigned char __c = (c); \ + __res = __isbody_C_macro(f,(__c)); \ + } \ + __res; \ + })) + +#define __body_C_macro(f,args) __C_ ## f args + +#define __body(f,c) \ + (__extension__ ({ \ + int __res; \ + if (sizeof(c) > sizeof(char)) { \ + int __c = (c); \ + __res = __body_C_macro(f,(__c)); \ + } else { \ + unsigned char __c = (c); \ + __res = __body_C_macro(f,(__c)); \ + } \ + __res; \ + })) + +#define __isspace(c) __body(isspace,c) +#define __isblank(c) __body(isblank,c) +#define __isdigit(c) __body(isdigit,c) +#define __isxdigit(c) __body(isxdigit,c) +#define __iscntrl(c) __body(iscntrl,c) +#define __isalpha(c) __body(isalpha,c) +#define __isalnum(c) __body(isalnum,c) +#define __isprint(c) __body(isprint,c) +#define __islower(c) __body(islower,c) +#define __isupper(c) __body(isupper,c) +#define __ispunct(c) __body(ispunct,c) +#define __isgraph(c) __body(isgraph,c) + +#define __tolower(c) __body(tolower,c) +#define __toupper(c) __body(toupper,c) + +#if !defined __NO_CTYPE && !defined __cplusplus + +#define isspace(c) __isspace(c) +#define isblank(c) __isblank(c) +#define isdigit(c) __isdigit(c) +#define isxdigit(c) __isxdigit(c) +#define iscntrl(c) __iscntrl(c) +#define isalpha(c) __isalpha(c) +#define isalnum(c) __isalnum(c) +#define isprint(c) __isprint(c) +#define islower(c) __islower(c) +#define isupper(c) __isupper(c) +#define ispunct(c) __ispunct(c) +#define isgraph(c) __isgraph(c) + +#define tolower(c) __tolower(c) +#define toupper(c) __toupper(c) + + +#endif + +#else /* _GNUC__ ***************************************************/ + +#if !defined __NO_CTYPE && !defined __cplusplus + +/* These macros should be safe from side effects. */ + +#define isdigit(c) __C_isdigit(c) +#define isalpha(c) __C_isalpha(c) +#define isprint(c) __C_isprint(c) +#define islower(c) __C_islower(c) +#define isupper(c) __C_isupper(c) +#define isgraph(c) __C_isgraph(c) + +#endif + +#endif /* __GNUC__ */ +/**********************************************************************/ + +#endif /* __UCLIBC_GEN_LOCALE */ + +#endif /* _BITS_CTYPE_H */ diff --git a/conts/posix/libposix/include/posix/bits/uClibc_errno.h b/conts/posix/libposix/include/posix/bits/uClibc_errno.h new file mode 100644 index 0000000..b16de32 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_errno.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2000-2006 Erik Andersen + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ +#ifndef _BITS_UCLIBC_ERRNO_H +#define _BITS_UCLIBC_ERRNO_H 1 + +#ifdef IS_IN_rtld +# undef errno +# define errno _dl_errno +extern int _dl_errno; // attribute_hidden; +#elif defined __UCLIBC_HAS_THREADS__ +# include +# if defined USE___THREAD && USE___THREAD +# undef errno +# ifndef NOT_IN_libc +# define errno __libc_errno +# else +# define errno errno +# endif +extern __thread int errno __attribute_tls_model_ie; +# endif /* USE___THREAD */ +#endif /* IS_IN_rtld */ + +#define __set_errno(val) (errno = (val)) + +#ifndef __ASSEMBLER__ +extern int *__errno_location (void) __THROW __attribute__ ((__const__)) +# ifdef IS_IN_rtld + attribute_hidden +# endif +; +# if defined __UCLIBC_HAS_THREADS__ +# include +# if defined USE___THREAD && USE___THREAD +libc_hidden_proto(__errno_location) +# endif +# endif + +#endif /* !__ASSEMBLER__ */ + +#endif diff --git a/conts/posix/libposix/include/posix/bits/uClibc_fpmax.h b/conts/posix/libposix/include/posix/bits/uClibc_fpmax.h new file mode 100644 index 0000000..e1721bf --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_fpmax.h @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2003-2006 Manuel Novoa III + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ +/* Define a maximal floating point type, and the associated constants + * that are defined for the floating point types in float.h. + * + * This is to support archs that are missing long double, or even double. + */ + +#ifndef _UCLIBC_FPMAX_H +#define _UCLIBC_FPMAX_H + +#ifndef _ISOC99_SOURCE +#define _ISOC99_SOURCE 1 +#endif + +#include +#include + +#ifdef __UCLIBC_HAS_FLOATS__ + +#if defined(LDBL_MANT_DIG) + +typedef long double __fpmax_t; +#define FPMAX_TYPE 3 + +#define FPMAX_MANT_DIG LDBL_MANT_DIG +#define FPMAX_DIG LDBL_DIG +#define FPMAX_EPSILON LDBL_EPSILON +#define FPMAX_MIN_EXP LDBL_MIN_EXP +#define FPMAX_MIN LDBL_MIN +#define FPMAX_MIN_10_EXP LDBL_MIN_10_EXP +#define FPMAX_MAX_EXP LDBL_MAX_EXP +#define FPMAX_MAX LDBL_MAX +#define FPMAX_MAX_10_EXP LDBL_MAX_10_EXP + +#elif defined(DBL_MANT_DIG) + +typedef double __fpmax_t; +#define FPMAX_TYPE 2 + +#define FPMAX_MANT_DIG DBL_MANT_DIG +#define FPMAX_DIG DBL_DIG +#define FPMAX_EPSILON DBL_EPSILON +#define FPMAX_MIN_EXP DBL_MIN_EXP +#define FPMAX_MIN DBL_MIN +#define FPMAX_MIN_10_EXP DBL_MIN_10_EXP +#define FPMAX_MAX_EXP DBL_MAX_EXP +#define FPMAX_MAX DBL_MAX +#define FPMAX_MAX_10_EXP DBL_MAX_10_EXP + +#elif defined(FLT_MANT_DIG) + +typedef float __fpmax_t; +#define FPMAX_TYPE 1 + +#define FPMAX_MANT_DIG FLT_MANT_DIG +#define FPMAX_DIG FLT_DIG +#define FPMAX_EPSILON FLT_EPSILON +#define FPMAX_MIN_EXP FLT_MIN_EXP +#define FPMAX_MIN FLT_MIN +#define FPMAX_MIN_10_EXP FLT_MIN_10_EXP +#define FPMAX_MAX_EXP FLT_MAX_EXP +#define FPMAX_MAX FLT_MAX +#define FPMAX_MAX_10_EXP FLT_MAX_10_EXP + +#else +#error unable to determine appropriate type for __fpmax_t! +#endif + +#ifndef DECIMAL_DIG + +#ifdef L___strtofpmax +/* Emit warning only once. */ +#warning DECIMAL_DIG is not defined! If you are using gcc, it may not be defining __STDC_VERSION__ as it should. +#endif +#if !defined(FLT_RADIX) || (FLT_RADIX != 2) +#error unable to compensate for missing DECIMAL_DIG! +#endif + +/* ceil (1 + #mantissa * log10 (FLT_RADIX)) */ +#define DECIMAL_DIG (1 + (((FPMAX_MANT_DIG * 100) + 331) / 332)) + +#endif /* DECIMAL_DIG */ + +#if defined _LIBC && defined IS_IN_libc +extern __fpmax_t __strtofpmax(const char *str, char **endptr, int exp_adjust) attribute_hidden; + +#ifdef __UCLIBC_HAS_XLOCALE__ +extern __fpmax_t __strtofpmax_l(const char *str, char **endptr, int exp_adjust, + __locale_t locale_arg) attribute_hidden; +#endif + +#ifdef __UCLIBC_HAS_WCHAR__ +extern __fpmax_t __wcstofpmax(const wchar_t *wcs, wchar_t **endptr, + int exp_adjust) attribute_hidden; + +#ifdef __UCLIBC_HAS_XLOCALE__ +extern __fpmax_t __wcstofpmax_l(const wchar_t *wcs, wchar_t **endptr, + int exp_adjust, __locale_t locale_arg) attribute_hidden; +#endif +#endif /* __UCLIBC_HAS_WCHAR__ */ +#endif /* _LIBC */ + +/* The following checks in an __fpmax_t is either 0 or +/- infinity. + * + * WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! + * + * This only works if __fpmax_t is the actual maximal floating point type used + * in intermediate calculations. Otherwise, excess precision in the + * intermediate values can cause the test to fail. + * + * WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! + */ + +#define __FPMAX_ZERO_OR_INF_CHECK(x) ((x) == ((x)/4) ) + +#endif /* __UCLIBC_HAS_FLOATS__ */ + +#endif /* _UCLIBC_FPMAX_H */ diff --git a/conts/posix/libposix/include/posix/bits/uClibc_local_lim.h b/conts/posix/libposix/include/posix/bits/uClibc_local_lim.h new file mode 100644 index 0000000..6c23f39 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_local_lim.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2000-2006 Erik Andersen + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ +/* + * Never include this file directly; use instead. + */ + +#ifndef _BITS_UCLIBC_LOCAL_LIM_H +#define _BITS_UCLIBC_LOCAL_LIM_H 1 + +/* This file works correctly only if local_lim.h is the NPTL version */ +#if !defined PTHREAD_KEYS_MAX || defined TIMER_MAX +# error local_lim.h was incorrectly updated, use the NPTL version from glibc +#endif + +/* This should really be moved to thread specific directories */ +#if defined __UCLIBC_HAS_THREADS__ +# define PTHREAD_THREADS_MAX 1024 +# define TIMER_MAX 256 +#endif + +#ifndef __UCLIBC_HAS_THREADS__ +# undef _POSIX_THREAD_KEYS_MAX +# undef PTHREAD_KEYS_MAX +# undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS +# undef PTHREAD_DESTRUCTOR_ITERATIONS +# undef PTHREAD_STACK_MIN +# undef DELAYTIMER_MAX +#endif + +#endif /* bits/uClibc_local_lim.h */ diff --git a/conts/posix/libposix/include/posix/bits/uClibc_locale.h b/conts/posix/libposix/include/posix/bits/uClibc_locale.h new file mode 100644 index 0000000..1de735a --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_locale.h @@ -0,0 +1,380 @@ +/* Copyright (C) 2002, 2003 Manuel Novoa III + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * The GNU C Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the GNU C Library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! + * + * Besides uClibc, I'm using this code in my libc for elks, which is + * a 16-bit environment with a fairly limited compiler. It would make + * things much easier for me if this file isn't modified unnecessarily. + * In particular, please put any new or replacement functions somewhere + * else, and modify the makefile to use your version instead. + * Thanks. Manuel + * + * ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */ + +#ifndef _UCLIBC_LOCALE_H +#define _UCLIBC_LOCALE_H + +/**********************************************************************/ +/* uClibc compatibilty stuff */ + +#ifdef __UCLIBC_HAS_LOCALE__ + +#undef __LOCALE_C_ONLY + +#else /* __UCLIBC_HAS_LOCALE__ */ + +#define __LOCALE_C_ONLY + +#define __XL_NPP(N) N +#define __LOCALE_PARAM +#define __LOCALE_ARG + +#endif /* __UCLIBC_HAS_LOCALE__ */ + +/**********************************************************************/ + +#define __NL_ITEM_CATEGORY_SHIFT (8) +#define __NL_ITEM_INDEX_MASK (0xff) + +/* TODO: Make sure these agree with the locale mmap file gererator! */ + +#define __LC_CTYPE 0 +#define __LC_NUMERIC 1 +#define __LC_MONETARY 2 +#define __LC_TIME 3 +#define __LC_COLLATE 4 +#define __LC_MESSAGES 5 +#define __LC_ALL 6 + +/**********************************************************************/ +#ifndef __LOCALE_C_ONLY + +#if defined _LIBC /* && (defined IS_IN_libc || defined NOT_IN_libc) */ +#include +#include +#include + +#ifndef __UCLIBC_GEN_LOCALE +#include +#endif +#endif + +/* extern void _locale_set(const unsigned char *p); */ +/* extern void _locale_init(void); */ + +enum { + __ctype_encoding_7_bit, /* C/POSIX */ + __ctype_encoding_utf8, /* UTF-8 */ + __ctype_encoding_8_bit /* for 8-bit codeset locales */ +}; + +#define LOCALE_STRING_SIZE (2 * __LC_ALL + 2) + + /* + * '#' + 2_per_category + '\0' + * {locale row # : 0 = C|POSIX} + 0x8001 + * encoded in two chars as (((N+1) >> 8) | 0x80) and ((N+1) & 0xff) + * so decode is ((((uint16_t)(*s & 0x7f)) << 8) + s[1]) - 1 + * + * Note: 0s are not used as they are nul-terminators for strings. + * Note: 0xff, 0xff is the encoding for a non-selected locale. + * (see setlocale() below). + * In particular, C/POSIX locale is '#' + "\x80\x01"}*LC_ALL + nul. + */ + +#if defined _LIBC && !defined __UCLIBC_GEN_LOCALE /* && (defined IS_IN_libc || defined NOT_IN_libc) */ +typedef struct { + uint16_t num_weights; + uint16_t num_starters; + uint16_t ii_shift; + uint16_t ti_shift; + uint16_t ii_len; + uint16_t ti_len; + uint16_t max_weight; + uint16_t num_col_base; + uint16_t max_col_index; + uint16_t undefined_idx; + uint16_t range_low; + uint16_t range_count; + uint16_t range_base_weight; + uint16_t range_rule_offset; /* change name to index? */ + + uint16_t ii_mask; + uint16_t ti_mask; + + const uint16_t *index2weight_tbl; + const uint16_t *index2ruleidx_tbl; + const uint16_t *multistart_tbl; + /* uint16_t wcs2colidt_offset_low; */ + /* uint16_t wcs2colidt_offset_hi; */ + const uint16_t *wcs2colidt_tbl; + + /* uint16_t undefined_idx; */ + const uint16_t *overrides_tbl; + /* uint16_t *multistart_tbl; */ + + const uint16_t *weightstr; + const uint16_t *ruletable; + + + uint16_t *index2weight; + uint16_t *index2ruleidx; + + uint16_t MAX_WEIGHTS; +} __collate_t; + + +/* static unsigned char cur_locale[LOCALE_STRING_SIZE]; */ + +typedef struct __uclibc_locale_struct { +#ifdef __UCLIBC_HAS_XLOCALE__ + const __ctype_mask_t *__ctype_b; + const __ctype_touplow_t *__ctype_tolower; + const __ctype_touplow_t *__ctype_toupper; +#endif + + /* For now, just embed this in the structure. */ + __ctype_mask_t __ctype_b_data[256 + __UCLIBC_CTYPE_B_TBL_OFFSET]; + __ctype_touplow_t __ctype_tolower_data[256 + __UCLIBC_CTYPE_TO_TBL_OFFSET]; + __ctype_touplow_t __ctype_toupper_data[256 + __UCLIBC_CTYPE_TO_TBL_OFFSET]; + +/* int tables_loaded; */ +/* unsigned char lctypes[LOCALE_STRING_SIZE]; */ + unsigned char cur_locale[LOCALE_STRING_SIZE]; + + /* NL_LANGINFO stuff. BEWARE ORDERING!!! must agree with NL_* constants! */ + /* Also, numeric must be followed by monetary and the items must be in + * the "struct lconv" order. */ + + uint16_t category_offsets[__LC_ALL]; /* TODO -- fix? */ + unsigned char category_item_count[__LC_ALL]; /* TODO - fix */ + + /* ctype */ + unsigned char encoding; /* C/POSIX, 8-bit, UTF-8 */ + unsigned char mb_cur_max; /* determined by encoding _AND_ translit!!! */ + const unsigned char outdigit_length[10]; + +#ifdef __CTYPE_HAS_8_BIT_LOCALES + const unsigned char *idx8ctype; + const unsigned char *tbl8ctype; + const unsigned char *idx8uplow; + const unsigned char *tbl8uplow; +#ifdef __UCLIBC_HAS_WCHAR__ + const unsigned char *idx8c2wc; + const uint16_t *tbl8c2wc; /* char > 0x7f to wide char */ + const unsigned char *idx8wc2c; + const unsigned char *tbl8wc2c; + /* translit */ +#endif /* __UCLIBC_HAS_WCHAR__ */ +#endif /* __CTYPE_HAS_8_BIT_LOCALES */ +#ifdef __UCLIBC_HAS_WCHAR__ + + const uint16_t *code2flag; + + const unsigned char *tblwctype; + const unsigned char *tblwuplow; +/* const unsigned char *tblwcomb; */ + const int16_t *tblwuplow_diff; /* yes... signed */ + /* width?? */ + + wchar_t decimal_point_wc; + wchar_t thousands_sep_wc; + int decimal_point_len; + int thousands_sep_len; + +#endif /* __UCLIBC_HAS_WCHAR__ */ + + /* ctype */ + const char *outdigit0_mb; + const char *outdigit1_mb; + const char *outdigit2_mb; + const char *outdigit3_mb; + const char *outdigit4_mb; + const char *outdigit5_mb; + const char *outdigit6_mb; + const char *outdigit7_mb; + const char *outdigit8_mb; + const char *outdigit9_mb; + const char *codeset; /* MUST BE LAST!!! */ + + /* numeric */ + const char *decimal_point; + const char *thousands_sep; + const char *grouping; + + /* monetary */ + const char *int_curr_symbol; + const char *currency_symbol; + const char *mon_decimal_point; + const char *mon_thousands_sep; + const char *mon_grouping; + const char *positive_sign; + const char *negative_sign; + const char *int_frac_digits; + const char *frac_digits; + const char *p_cs_precedes; + const char *p_sep_by_space; + const char *n_cs_precedes; + const char *n_sep_by_space; + const char *p_sign_posn; + const char *n_sign_posn; + const char *int_p_cs_precedes; + const char *int_p_sep_by_space; + const char *int_n_cs_precedes; + const char *int_n_sep_by_space; + const char *int_p_sign_posn; + const char *int_n_sign_posn; + + const char *crncystr; /* not returned by localeconv */ + + /* time */ + const char *abday_1; + const char *abday_2; + const char *abday_3; + const char *abday_4; + const char *abday_5; + const char *abday_6; + const char *abday_7; + + const char *day_1; + const char *day_2; + const char *day_3; + const char *day_4; + const char *day_5; + const char *day_6; + const char *day_7; + + const char *abmon_1; + const char *abmon_2; + const char *abmon_3; + const char *abmon_4; + const char *abmon_5; + const char *abmon_6; + const char *abmon_7; + const char *abmon_8; + const char *abmon_9; + const char *abmon_10; + const char *abmon_11; + const char *abmon_12; + + const char *mon_1; + const char *mon_2; + const char *mon_3; + const char *mon_4; + const char *mon_5; + const char *mon_6; + const char *mon_7; + const char *mon_8; + const char *mon_9; + const char *mon_10; + const char *mon_11; + const char *mon_12; + + const char *am_str; + const char *pm_str; + + const char *d_t_fmt; + const char *d_fmt; + const char *t_fmt; + const char *t_fmt_ampm; + const char *era; + + const char *era_year; /* non SUSv3 */ + const char *era_d_fmt; + const char *alt_digits; + const char *era_d_t_fmt; + const char *era_t_fmt; + + /* collate is at the end */ + + /* messages */ + const char *yesexpr; + const char *noexpr; + const char *yesstr; + const char *nostr; + + /* collate is at the end */ + __collate_t collate; + +} __uclibc_locale_t; + +extern __uclibc_locale_t __global_locale_data; +extern struct __uclibc_locale_struct * __global_locale; +#endif /* _LIBC */ + +typedef struct __uclibc_locale_struct *__locale_t; + +/* if we need to leave only _LIBC, then attribute_hidden is not usable */ +#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc) +extern int __locale_mbrtowc_l(wchar_t *__restrict dst, + const char *__restrict src, + __locale_t loc ) attribute_hidden; +#endif + +#ifdef L_setlocale +/* so we only get the warning once... */ +#warning need thread version of CUR_LOCALE! +#endif +/**********************************************************************/ +#ifdef __UCLIBC_HAS_XLOCALE__ + +extern __locale_t __curlocale_var; + +#ifdef __UCLIBC_HAS_THREADS__ + +extern __locale_t __curlocale(void) __THROW __attribute__ ((__const__)); +extern __locale_t __curlocale_set(__locale_t newloc); +#define __UCLIBC_CURLOCALE (__curlocale()) +#define __UCLIBC_CURLOCALE_DATA (*__curlocale()) + +#else /* __UCLIBC_HAS_THREADS__ */ + +#define __UCLIBC_CURLOCALE (__curlocale_var) +#define __UCLIBC_CURLOCALE_DATA (*__curlocale_var) + +#endif /* __UCLIBC_HAS_THREADS__ */ + +#elif defined(__UCLIBC_HAS_LOCALE__) + +#define __UCLIBC_CURLOCALE (__global_locale) +#define __UCLIBC_CURLOCALE_DATA (*__global_locale) + +#endif +/**********************************************************************/ +#if defined(__UCLIBC_HAS_XLOCALE__) && defined(__UCLIBC_DO_XLOCALE) + +#define __XL_NPP(N) N ## _l +#define __LOCALE_PARAM , __locale_t locale_arg +#define __LOCALE_ARG , locale_arg +#define __LOCALE_PTR locale_arg + +#else /* defined(__UCLIBC_HAS_XLOCALE__) && defined(__UCLIBC_DO_XLOCALE) */ + +#define __XL_NPP(N) N +#define __LOCALE_PARAM +#define __LOCALE_ARG +#define __LOCALE_PTR __UCLIBC_CURLOCALE + +#endif /* defined(__UCLIBC_HAS_XLOCALE__) && defined(__UCLIBC_DO_XLOCALE) */ +/**********************************************************************/ + +#endif /* !defined(__LOCALE_C_ONLY) */ +/**********************************************************************/ + +#endif /* _UCLIBC_LOCALE_H */ diff --git a/conts/posix/libposix/include/posix/bits/uClibc_mutex.h b/conts/posix/libposix/include/posix/bits/uClibc_mutex.h new file mode 100644 index 0000000..14aeb9c --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_mutex.h @@ -0,0 +1,88 @@ +/* Copyright (C) 2006 Manuel Novoa III + * + * GNU Library General Public License (LGPL) version 2 or later. + * + * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. + */ + +#ifndef _UCLIBC_MUTEX_H +#define _UCLIBC_MUTEX_H + +#include + +#ifdef __UCLIBC_HAS_THREADS__ + +#include +#include + +#define __UCLIBC_MUTEX_TYPE pthread_mutex_t + +#define __UCLIBC_MUTEX(M) pthread_mutex_t M +#define __UCLIBC_MUTEX_INIT(M,I) pthread_mutex_t M = I +#define __UCLIBC_MUTEX_STATIC(M,I) static pthread_mutex_t M = I +#define __UCLIBC_MUTEX_EXTERN(M) extern pthread_mutex_t M + +#define __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(M) \ + __pthread_mutex_lock(&(M)) + +#define __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE(M) \ + __pthread_mutex_unlock(&(M)) + +#define __UCLIBC_MUTEX_TRYLOCK_CANCEL_UNSAFE(M) \ + __pthread_mutex_trylock(&(M)) + +#define __UCLIBC_MUTEX_CONDITIONAL_LOCK(M,C) \ + do { \ + struct _pthread_cleanup_buffer __infunc_pthread_cleanup_buffer; \ + if (C) { \ + _pthread_cleanup_push_defer(&__infunc_pthread_cleanup_buffer, \ + (void (*) (void *))__pthread_mutex_unlock, \ + &(M)); \ + __pthread_mutex_lock(&(M)); \ + } \ + ((void)0) + +#define __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M,C) \ + if (C) { \ + _pthread_cleanup_pop_restore(&__infunc_pthread_cleanup_buffer,1); \ + } \ + } while (0) + +#define __UCLIBC_MUTEX_AUTO_LOCK_VAR(A) int A + +#define __UCLIBC_MUTEX_AUTO_LOCK(M,A,V) \ + __UCLIBC_MUTEX_CONDITIONAL_LOCK(M,((A=(V)) == 0)) + +#define __UCLIBC_MUTEX_AUTO_UNLOCK(M,A) \ + __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M,(A == 0)) + +#define __UCLIBC_MUTEX_LOCK(M) \ + __UCLIBC_MUTEX_CONDITIONAL_LOCK(M, 1) + +#define __UCLIBC_MUTEX_UNLOCK(M) \ + __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M, 1) + +#else + +#define __UCLIBC_MUTEX(M) void *__UCLIBC_MUTEX_DUMMY_ ## M +#define __UCLIBC_MUTEX_INIT(M,I) extern void *__UCLIBC_MUTEX_DUMMY_ ## M +#define __UCLIBC_MUTEX_STATIC(M,I) extern void *__UCLIBC_MUTEX_DUMMY_ ## M +#define __UCLIBC_MUTEX_EXTERN(M) extern void *__UCLIBC_MUTEX_DUMMY_ ## M + +#define __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE(M) ((void)0) +#define __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE(M) ((void)0) +#define __UCLIBC_MUTEX_TRYLOCK_CANCEL_UNSAFE(M) (0) /* Always succeed? */ + +#define __UCLIBC_MUTEX_CONDITIONAL_LOCK(M,C) ((void)0) +#define __UCLIBC_MUTEX_CONDITIONAL_UNLOCK(M,C) ((void)0) + +#define __UCLIBC_MUTEX_AUTO_LOCK_VAR(A) ((void)0) +#define __UCLIBC_MUTEX_AUTO_LOCK(M,A,V) ((void)0) +#define __UCLIBC_MUTEX_AUTO_UNLOCK(M,A) ((void)0) + +#define __UCLIBC_MUTEX_LOCK(M) ((void)0) +#define __UCLIBC_MUTEX_UNLOCK(M) ((void)0) + +#endif + +#endif /* _UCLIBC_MUTEX_H */ diff --git a/conts/posix/libposix/include/posix/bits/uClibc_page.h b/conts/posix/libposix/include/posix/bits/uClibc_page.h new file mode 100644 index 0000000..1340945 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_page.h @@ -0,0 +1,29 @@ +/* Copyright (C) 2004 Erik Andersen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * The GNU C Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the GNU C Library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +/* Supply an architecture specific value for PAGE_SIZE and friends. */ + +#ifndef _UCLIBC_PAGE_H +#define _UCLIBC_PAGE_H + +/* PAGE_SHIFT determines the page size -- in this case 4096 */ +#define PAGE_SHIFT 12 +#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_MASK (~(PAGE_SIZE-1)) + +#endif /* _UCLIBC_PAGE_H */ diff --git a/conts/posix/libposix/include/posix/bits/uClibc_pthread.h b/conts/posix/libposix/include/posix/bits/uClibc_pthread.h new file mode 100644 index 0000000..1d6209f --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_pthread.h @@ -0,0 +1,50 @@ +/* Copyright (C) 2003 Manuel Novoa III + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * The GNU C Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the GNU C Library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +/* Supply prototypes for the internal thread functions used by the + * uClibc library code. + */ + +#ifndef _UCLIBC_PTHREAD_H +#define _UCLIBC_PTHREAD_H + +#ifndef _PTHREAD_H +# error "Always include rather than " +#endif + +#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc) +/* Threading functions internal to uClibc. Make these thread functions + * weak so that we can elide them from single-threaded processes. */ +extern int weak_function __pthread_mutex_init (pthread_mutex_t *__mutex, + __const pthread_mutexattr_t *__mutex_attr); +extern int weak_function __pthread_mutex_destroy (pthread_mutex_t *__mutex); +extern int weak_function __pthread_mutex_lock (pthread_mutex_t *__mutex); +extern int weak_function __pthread_mutex_unlock (pthread_mutex_t *__mutex); +extern void __uclibc_mutex_unlock (void *) attribute_hidden; +extern int weak_function __pthread_mutex_trylock (pthread_mutex_t *__mutex); +# ifndef __UCLIBC_HAS_THREADS_NATIVE__ +extern void weak_function _pthread_cleanup_push_defer ( + struct _pthread_cleanup_buffer *__buffer, + void (*__routine) (void *), void *__arg); +extern void weak_function _pthread_cleanup_pop_restore ( + struct _pthread_cleanup_buffer *__buffer, + int __execute); +# endif +#endif + +#endif diff --git a/conts/posix/libposix/include/posix/bits/uClibc_stdio.h b/conts/posix/libposix/include/posix/bits/uClibc_stdio.h new file mode 100644 index 0000000..843a2f2 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_stdio.h @@ -0,0 +1,517 @@ +/* Copyright (C) 2002-2004 Manuel Novoa III + * + * GNU Library General Public License (LGPL) version 2 or later. + * + * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. + */ + +#ifndef _STDIO_H +#error Always include rather than +#endif + +/**********************************************************************/ + +#define __STDIO_BUFFERS +/* ANSI/ISO mandate at least 256. */ +#if defined(__UCLIBC_HAS_STDIO_BUFSIZ_NONE__) +/* Fake this because some apps use stdio.h BUFSIZ. */ +#define __STDIO_BUFSIZ 256 +#undef __STDIO_BUFFERS +#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_256__) +#define __STDIO_BUFSIZ 256 +#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_512__) +#define __STDIO_BUFSIZ 512 +#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_1024__) +#define __STDIO_BUFSIZ 1024 +#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_2048__) +#define __STDIO_BUFSIZ 2048 +#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_4096__) +#define __STDIO_BUFSIZ 4096 +#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_8192__) +#define __STDIO_BUFSIZ 8192 +#else +#error config seems to be out of sync regarding bufsiz options +#endif + +#ifdef __UCLIBC_HAS_STDIO_BUFSIZ_NONE__ +#define __STDIO_BUILTIN_BUF_SIZE 0 +#else /* __UCLIBC_HAS_STDIO_BUFSIZ_NONE__ */ +#if defined(__UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE__) +#define __STDIO_BUILTIN_BUF_SIZE 0 +#elif defined(__UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4__) +#define __STDIO_BUILTIN_BUF_SIZE 4 +#elif defined(__UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8__) +#define __STDIO_BUILTIN_BUF_SIZE 8 +#else +#error config seems to be out of sync regarding builtin buffer size +#endif +#endif + +#if defined(__STDIO_BUFFERS) || defined(__UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__) || defined(__UCLIBC_HAS_THREADS__) +#define __STDIO_HAS_OPENLIST 1 +#else +#undef __STDIO_HAS_OPENLIST +#endif + +/**********************************************************************/ +/* Make sure defines related to large files are consistent. */ +#ifdef _LIBC + +#ifdef __UCLIBC_HAS_LFS__ +#undef __USE_LARGEFILE +#undef __USE_LARGEFILE64 +#undef __USE_FILE_OFFSET64 +/* If we're actually building uClibc with large file support, only define... */ +#define __USE_LARGEFILE64 1 +#endif /* __UCLIBC_HAS_LFS__ */ + +#else /* not _LIBC */ + +#ifndef __UCLIBC_HAS_LFS__ +#if defined(__LARGEFILE64_SOURCE) || defined(__USE_LARGEFILE64) || defined(__USE_FILE_OFFSET64) +#error Sorry... uClibc was built without large file support! +#endif +#endif /* __UCLIBC_HAS_LFS__ */ + +#endif /* _LIBC */ +/**********************************************************************/ +#ifdef __UCLIBC_HAS_WCHAR__ + +#define __need_wchar_t +#include + +/* Note: we don't really need mbstate for 8-bit locales. We do for UTF-8. + * For now, always use it. */ +#define __STDIO_MBSTATE +#define __need_mbstate_t +#include + +#endif +/**********************************************************************/ +/* Currently unimplemented/untested */ +/* #define __STDIO_FLEXIBLE_SETVBUF */ + +#ifdef __UCLIBC_HAS_STDIO_GETC_MACRO__ +#define __STDIO_GETC_MACRO +#endif + +#ifdef __UCLIBC_HAS_STDIO_PUTC_MACRO__ +#define __STDIO_PUTC_MACRO +#endif + + +/* These are consistency checks on the different options */ + +#ifndef __STDIO_BUFFERS +#undef __STDIO_GETC_MACRO +#undef __STDIO_PUTC_MACRO +#endif + +#ifdef __BCC__ +#undef __UCLIBC_HAS_LFS__ +#endif + +#ifndef __UCLIBC_HAS_LFS__ +#undef __UCLIBC_HAS_FOPEN_LARGEFILE_MODE__ +#endif + +/**********************************************************************/ +#include + +/* user_locking + * 0 : do auto locking/unlocking + * 1 : user does locking/unlocking + * 2 : initial state prior to thread initialization + * with no auto locking/unlocking + * + * When threading is initialized, walk the stdio open stream list + * and do "if (user_locking == 2) user_locking = 0;". + * + * This way, we avoid calling the weak lock/unlock functions. + */ + +#define __STDIO_AUTO_THREADLOCK_VAR \ + __UCLIBC_MUTEX_AUTO_LOCK_VAR(__infunc_user_locking) + +#define __STDIO_AUTO_THREADLOCK(__stream) \ + __UCLIBC_MUTEX_AUTO_LOCK((__stream)->__lock, __infunc_user_locking, \ + (__stream)->__user_locking) + +#define __STDIO_AUTO_THREADUNLOCK(__stream) \ + __UCLIBC_MUTEX_AUTO_UNLOCK((__stream)->__lock, __infunc_user_locking) + +#define __STDIO_ALWAYS_THREADLOCK(__stream) \ + __UCLIBC_MUTEX_LOCK((__stream)->__lock) + +#define __STDIO_ALWAYS_THREADUNLOCK(__stream) \ + __UCLIBC_MUTEX_UNLOCK((__stream)->__lock) + +#define __STDIO_ALWAYS_THREADLOCK_CANCEL_UNSAFE(__stream) \ + __UCLIBC_MUTEX_LOCK_CANCEL_UNSAFE((__stream)->__lock) + +#define __STDIO_ALWAYS_THREADTRYLOCK_CANCEL_UNSAFE(__stream) \ + __UCLIBC_MUTEX_TRYLOCK_CANCEL_UNSAFE((__stream)->__lock) + +#define __STDIO_ALWAYS_THREADUNLOCK_CANCEL_UNSAFE(__stream) \ + __UCLIBC_MUTEX_UNLOCK_CANCEL_UNSAFE((__stream)->__lock) + +#ifdef __UCLIBC_HAS_THREADS__ +#define __STDIO_SET_USER_LOCKING(__stream) ((__stream)->__user_locking = 1) +#else +#define __STDIO_SET_USER_LOCKING(__stream) ((void)0) +#endif + +/**********************************************************************/ + +#define __STDIO_IOFBF 0 /* Fully buffered. */ +#define __STDIO_IOLBF 1 /* Line buffered. */ +#define __STDIO_IONBF 2 /* No buffering. */ + +typedef struct { + __off_t __pos; +#ifdef __STDIO_MBSTATE + __mbstate_t __mbstate; +#endif +#ifdef __UCLIBC_HAS_WCHAR__ + int __mblen_pending; +#endif +} __STDIO_fpos_t; + +#ifdef __UCLIBC_HAS_LFS__ +typedef struct { + __off64_t __pos; +#ifdef __STDIO_MBSTATE + __mbstate_t __mbstate; +#endif +#ifdef __UCLIBC_HAS_WCHAR__ + int __mblen_pending; +#endif +} __STDIO_fpos64_t; +#endif + +/**********************************************************************/ +#ifdef __UCLIBC_HAS_LFS__ +typedef __off64_t __offmax_t; /* TODO -- rename this? */ +#else +typedef __off_t __offmax_t; /* TODO -- rename this? */ +#endif + +/**********************************************************************/ +#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ + +typedef __ssize_t __io_read_fn(void *__cookie, char *__buf, size_t __bufsize); +typedef __ssize_t __io_write_fn(void *__cookie, + __const char *__buf, size_t __bufsize); +/* NOTE: GLIBC difference!!! -- fopencookie seek function + * For glibc, the type of pos is always (__off64_t *) but in our case + * it is type (__off_t *) when the lib is built without large file support. + */ +typedef int __io_seek_fn(void *__cookie, __offmax_t *__pos, int __whence); +typedef int __io_close_fn(void *__cookie); + +typedef struct { + __io_read_fn *read; + __io_write_fn *write; + __io_seek_fn *seek; + __io_close_fn *close; +} _IO_cookie_io_functions_t; + +#if defined(_LIBC) || defined(_GNU_SOURCE) + +typedef __io_read_fn cookie_read_function_t; +typedef __io_write_fn cookie_write_function_t; +typedef __io_seek_fn cookie_seek_function_t; +typedef __io_close_fn cookie_close_function_t; + +typedef _IO_cookie_io_functions_t cookie_io_functions_t; + +#endif + +#endif +/**********************************************************************/ + +struct __STDIO_FILE_STRUCT { + unsigned short __modeflags; + /* There could be a hole here, but modeflags is used most.*/ +#ifdef __UCLIBC_HAS_WCHAR__ + unsigned char __ungot_width[2]; /* 0: current (building) char; 1: scanf */ + /* Move the following futher down to avoid problems with getc/putc + * macros breaking shared apps when wchar config support is changed. */ + /* wchar_t ungot[2]; */ +#else /* __UCLIBC_HAS_WCHAR__ */ + unsigned char __ungot[2]; +#endif /* __UCLIBC_HAS_WCHAR__ */ + int __filedes; +#ifdef __STDIO_BUFFERS + unsigned char *__bufstart; /* pointer to buffer */ + unsigned char *__bufend; /* pointer to 1 past end of buffer */ + unsigned char *__bufpos; + unsigned char *__bufread; /* pointer to 1 past last buffered read char */ + +#ifdef __STDIO_GETC_MACRO + unsigned char *__bufgetc_u; /* 1 past last readable by getc_unlocked */ +#endif /* __STDIO_GETC_MACRO */ +#ifdef __STDIO_PUTC_MACRO + unsigned char *__bufputc_u; /* 1 past last writeable by putc_unlocked */ +#endif /* __STDIO_PUTC_MACRO */ + +#endif /* __STDIO_BUFFERS */ + +#ifdef __STDIO_HAS_OPENLIST + struct __STDIO_FILE_STRUCT *__nextopen; +#endif +#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ + void *__cookie; + _IO_cookie_io_functions_t __gcs; +#endif +#ifdef __UCLIBC_HAS_WCHAR__ + wchar_t __ungot[2]; +#endif +#ifdef __STDIO_MBSTATE + __mbstate_t __state; +#endif +#ifdef __UCLIBC_HAS_XLOCALE__ + void *__unused; /* Placeholder for codeset binding. */ +#endif +#ifdef __UCLIBC_HAS_THREADS__ + int __user_locking; + __UCLIBC_MUTEX(__lock); +#endif +/* Everything after this is unimplemented... and may be trashed. */ +#if __STDIO_BUILTIN_BUF_SIZE > 0 + unsigned char __builtinbuf[__STDIO_BUILTIN_BUF_SIZE]; +#endif /* __STDIO_BUILTIN_BUF_SIZE > 0 */ +}; + + +/***********************************************************************/ +/* Having ungotten characters implies the stream is reading. + * The scheme used here treats the least significant 2 bits of + * the stream's modeflags member as follows: + * 0 0 Not currently reading. + * 0 1 Reading, but no ungetc() or scanf() push back chars. + * 1 0 Reading with one ungetc() char (ungot[1] is 1) + * or one scanf() pushed back char (ungot[1] is 0). + * 1 1 Reading with both an ungetc() char and a scanf() + * pushed back char. Note that this must be the result + * of a scanf() push back (in ungot[0]) _followed_ by + * an ungetc() call (in ungot[1]). + * + * Notes: + * scanf() can NOT use ungetc() to push back characters. + * (See section 7.19.6.2 of the C9X rationale -- WG14/N897.) + */ + +#define __MASK_READING 0x0003U /* (0x0001 | 0x0002) */ +#define __FLAG_READING 0x0001U +#define __FLAG_UNGOT 0x0002U +#define __FLAG_EOF 0x0004U +#define __FLAG_ERROR 0x0008U +#define __FLAG_WRITEONLY 0x0010U +#define __FLAG_READONLY 0x0020U /* (__FLAG_WRITEONLY << 1) */ +#define __FLAG_WRITING 0x0040U +#define __FLAG_NARROW 0x0080U + +#define __FLAG_FBF 0x0000U /* must be 0 */ +#define __FLAG_LBF 0x0100U +#define __FLAG_NBF 0x0200U /* (__FLAG_LBF << 1) */ +#define __MASK_BUFMODE 0x0300U /* (__FLAG_LBF|__FLAG_NBF) */ +#define __FLAG_APPEND 0x0400U /* fixed! == O_APPEND for linux */ +#define __FLAG_WIDE 0x0800U +/* available slot 0x1000U */ +#define __FLAG_FREEFILE 0x2000U +#define __FLAG_FREEBUF 0x4000U +#define __FLAG_LARGEFILE 0x8000U /* fixed! == 0_LARGEFILE for linux */ +#define __FLAG_FAILED_FREOPEN __FLAG_LARGEFILE + +/* Note: In no-buffer mode, it would be possible to pack the necessary + * flags into one byte. Since we wouldn't be buffering and there would + * be no support for wchar, the only flags we would need would be: + * 2 bits : ungot count + * 2 bits : eof + error + * 2 bits : readonly + writeonly + * 1 bit : freefile + * 1 bit : appending + * So, for a very small system (< 128 files) we might have a + * 4-byte FILE struct of: + * unsigned char flags; + * signed char filedes; + * unsigned char ungot[2]; + */ +/********************************************************************** + * PROTOTYPES OF INTERNAL FUNCTIONS + **********************************************************************/ +#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc) + +extern void _stdio_init(void) attribute_hidden; +extern void _stdio_term(void) attribute_hidden; + +#ifdef __STDIO_HAS_OPENLIST + +extern struct __STDIO_FILE_STRUCT *_stdio_openlist; + +#ifdef __UCLIBC_HAS_THREADS__ +__UCLIBC_MUTEX_EXTERN(_stdio_openlist_add_lock); +#ifdef __STDIO_BUFFERS +__UCLIBC_MUTEX_EXTERN(_stdio_openlist_del_lock); +extern volatile int _stdio_openlist_use_count; /* _stdio_openlist_del_lock */ +extern int _stdio_openlist_del_count; /* _stdio_openlist_del_lock */ +#endif +extern int _stdio_user_locking; +extern void __stdio_init_mutex(__UCLIBC_MUTEX_TYPE *m) attribute_hidden; +#endif + +#endif + +#endif +/**********************************************************************/ + +#define __CLEARERR_UNLOCKED(__stream) \ + ((void)((__stream)->__modeflags &= ~(__FLAG_EOF|__FLAG_ERROR))) +#define __FEOF_UNLOCKED(__stream) ((__stream)->__modeflags & __FLAG_EOF) +#define __FERROR_UNLOCKED(__stream) ((__stream)->__modeflags & __FLAG_ERROR) + +#ifdef __UCLIBC_HAS_THREADS__ +# define __CLEARERR(__stream) (clearerr)(__stream) +# define __FERROR(__stream) (ferror)(__stream) +# define __FEOF(__stream) (feof)(__stream) +#else +# define __CLEARERR(__stream) __CLEARERR_UNLOCKED(__stream) +# define __FERROR(__stream) __FERROR_UNLOCKED(__stream) +# define __FEOF(__stream) __FEOF_UNLOCKED(__stream) +#endif + +extern int __fgetc_unlocked(FILE *__stream); +extern int __fputc_unlocked(int __c, FILE *__stream); + +/* First define the default definitions. + They are overridden below as necessary. */ +#define __FGETC_UNLOCKED(__stream) (__fgetc_unlocked)((__stream)) +#define __FGETC(__stream) (fgetc)((__stream)) +#define __GETC_UNLOCKED_MACRO(__stream) (__fgetc_unlocked)((__stream)) +#define __GETC_UNLOCKED(__stream) (__fgetc_unlocked)((__stream)) +#define __GETC(__stream) (fgetc)((__stream)) + +#define __FPUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream)) +#define __FPUTC(__c, __stream) (fputc)((__c),(__stream)) +#define __PUTC_UNLOCKED_MACRO(__c, __stream) (__fputc_unlocked)((__c),(__stream)) +#define __PUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream)) +#define __PUTC(__c, __stream) (fputc)((__c),(__stream)) + + +#ifdef __STDIO_GETC_MACRO + +extern FILE *__stdin; /* For getchar() macro. */ + +# undef __GETC_UNLOCKED_MACRO +# define __GETC_UNLOCKED_MACRO(__stream) \ + ( ((__stream)->__bufpos < (__stream)->__bufgetc_u) \ + ? (*(__stream)->__bufpos++) \ + : __fgetc_unlocked(__stream) ) + +# if 0 + /* Classic macro approach. getc{_unlocked} can have side effects. */ +# undef __GETC_UNLOCKED +# define __GETC_UNLOCKED(__stream) __GETC_UNLOCKED_MACRO((__stream)) +# ifndef __UCLIBC_HAS_THREADS__ +# undef __GETC +# define __GETC(__stream) __GETC_UNLOCKED_MACRO((__stream)) +# endif + +# else + /* Using gcc extension for safety and additional inlining. */ +# undef __FGETC_UNLOCKED +# define __FGETC_UNLOCKED(__stream) \ + (__extension__ ({ \ + FILE *__S = (__stream); \ + __GETC_UNLOCKED_MACRO(__S); \ + }) ) + +# undef __GETC_UNLOCKED +# define __GETC_UNLOCKED(__stream) __FGETC_UNLOCKED((__stream)) + +# ifdef __UCLIBC_HAS_THREADS__ +# undef __FGETC +# define __FGETC(__stream) \ + (__extension__ ({ \ + FILE *__S = (__stream); \ + ((__S->__user_locking ) \ + ? __GETC_UNLOCKED_MACRO(__S) \ + : (fgetc)(__S)); \ + }) ) + +# undef __GETC +# define __GETC(__stream) __FGETC((__stream)) + +# else + +# undef __FGETC +# define __FGETC(__stream) __FGETC_UNLOCKED((__stream)) +# undef __GETC +# define __GETC(__stream) __FGETC_UNLOCKED((__stream)) + +# endif +# endif + +#else + +#endif /* __STDIO_GETC_MACRO */ + + +#ifdef __STDIO_PUTC_MACRO + +extern FILE *__stdout; /* For putchar() macro. */ + +# undef __PUTC_UNLOCKED_MACRO +# define __PUTC_UNLOCKED_MACRO(__c, __stream) \ + ( ((__stream)->__bufpos < (__stream)->__bufputc_u) \ + ? (*(__stream)->__bufpos++) = (__c) \ + : __fputc_unlocked((__c),(__stream)) ) + +# if 0 + /* Classic macro approach. putc{_unlocked} can have side effects.*/ +# undef __PUTC_UNLOCKED +# define __PUTC_UNLOCKED(__c, __stream) \ + __PUTC_UNLOCKED_MACRO((__c), (__stream)) +# ifndef __UCLIBC_HAS_THREADS__ +# undef __PUTC +# define __PUTC(__c, __stream) __PUTC_UNLOCKED_MACRO((__c), (__stream)) +# endif + +# else + /* Using gcc extension for safety and additional inlining. */ + +# undef __FPUTC_UNLOCKED +# define __FPUTC_UNLOCKED(__c, __stream) \ + (__extension__ ({ \ + FILE *__S = (__stream); \ + __PUTC_UNLOCKED_MACRO((__c),__S); \ + }) ) + +# undef __PUTC_UNLOCKED +# define __PUTC_UNLOCKED(__c, __stream) __FPUTC_UNLOCKED((__c), (__stream)) + +# ifdef __UCLIBC_HAS_THREADS__ +# undef __FPUTC +# define __FPUTC(__c, __stream) \ + (__extension__ ({ \ + FILE *__S = (__stream); \ + ((__S->__user_locking) \ + ? __PUTC_UNLOCKED_MACRO((__c),__S) \ + : (fputc)((__c),__S)); \ + }) ) + +# undef __PUTC +# define __PUTC(__c, __stream) __FPUTC((__c), (__stream)) + +# else + +# undef __FPUTC +# define __FPUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream)) +# undef __PUTC +# define __PUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream)) + +# endif +# endif + +#endif /* __STDIO_PUTC_MACRO */ diff --git a/conts/posix/libposix/include/posix/bits/uClibc_touplow.h b/conts/posix/libposix/include/posix/bits/uClibc_touplow.h new file mode 100644 index 0000000..28d4e2f --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_touplow.h @@ -0,0 +1,55 @@ +/* Copyright (C) 2003 Manuel Novoa III + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * The GNU C Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the GNU C Library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! + * + * Besides uClibc, I'm using this code in my libc for elks, which is + * a 16-bit environment with a fairly limited compiler. It would make + * things much easier for me if this file isn't modified unnecessarily. + * In particular, please put any new or replacement functions somewhere + * else, and modify the makefile to use your version instead. + * Thanks. Manuel + * + * ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */ + +#ifndef _UCLIBC_TOUPLOW_H +#define _UCLIBC_TOUPLOW_H + +#include +#include + +/* glibc uses the equivalent of - typedef __int32_t __ctype_touplow_t; */ + +typedef __uint16_t __ctype_mask_t; + +#ifdef __UCLIBC_HAS_CTYPE_SIGNED__ + +typedef __int16_t __ctype_touplow_t; +#define __UCLIBC_CTYPE_B_TBL_OFFSET 128 +#define __UCLIBC_CTYPE_TO_TBL_OFFSET 128 + +#else /* __UCLIBC_HAS_CTYPE_SIGNED__ */ + +typedef unsigned char __ctype_touplow_t; +#define __UCLIBC_CTYPE_B_TBL_OFFSET 1 +#define __UCLIBC_CTYPE_TO_TBL_OFFSET 0 + +#endif /* __UCLIBC_HAS_CTYPE_SIGNED__ */ + +#endif /* _UCLIBC_TOUPLOW_H */ + diff --git a/conts/posix/libposix/include/posix/bits/uClibc_uintmaxtostr.h b/conts/posix/libposix/include/posix/bits/uClibc_uintmaxtostr.h new file mode 100644 index 0000000..92633ff --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_uintmaxtostr.h @@ -0,0 +1,116 @@ +/* Copyright (C) 2003 Manuel Novoa III + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * The GNU C Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the GNU C Library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! + * + * This code is currently under development. Also, I plan to port + * it to elks which is a 16-bit environment with a fairly limited + * compiler. Therefore, please refrain from modifying this code + * and, instead, pass any bug-fixes, etc. to me. Thanks. Manuel + * + * ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */ + +#ifndef _UINTMAXTOSTR_H +#define _UINTMAXTOSTR_H 1 + +#ifdef _FEATURES_H +# ifndef __USE_ISOC99 +# error features was included without defining _ISOC99_SOURCE! +# endif +#else +# ifndef _ISOC99_SOURCE +# define _ISOC99_SOURCE +# endif +#endif + +#include +#include +#include + +#if INTMAX_MAX <= 2147483647L +#define __UIM_BUFLEN 12 /* 10 digits + 1 nul + 1 sign */ +#elif INTMAX_MAX <= 9223372036854775807LL +#define __UIM_BUFLEN 22 /* 20 digits + 1 nul + 1 sign */ +#else +#error unknown number of digits for intmax_t! +#endif + +#ifdef LLONG_MAX /* --------------- */ +#if LLONG_MAX <= 2147483647L +#define __UIM_BUFLEN_LLONG 12 /* 10 digits + 1 nul + 1 sign */ +#elif LLONG_MAX <= 9223372036854775807LL +#define __UIM_BUFLEN_LLONG 22 /* 20 digits + 1 nul + 1 sign */ +#else +#error unknown number of digits for long long! +#endif +#endif /* ULLONG_MAX ----------------------------- */ + +#if LONG_MAX <= 2147483647L +#define __UIM_BUFLEN_LONG 12 /* 10 digits + 1 nul + 1 sign */ +#elif LONG_MAX <= 9223372036854775807LL +#define __UIM_BUFLEN_LONG 22 /* 20 digits + 1 nul + 1 sign */ +#else +#error unknown number of digits for long! +#endif + +#if INT_MAX <= 32767 +#define __UIM_BUFLEN_INT 7 /* 10 digits + 1 nul + 1 sign */ +#elif INT_MAX <= 2147483647L +#define __UIM_BUFLEN_INT 12 /* 10 digits + 1 nul + 1 sign */ +#else +#error unknown number of digits for int! +#endif + +typedef enum { + __UIM_DECIMAL = 0, + __UIM_GROUP = ',', /* Base 10 locale-dependent grouping. */ + __UIM_LOWER = 'a' - 10, + __UIM_UPPER = 'A' - 10, +} __UIM_CASE; + +/* Convert the int val to a string in base abs(base). val is treated as + * an unsigned ??? int type if base > 0, and signed if base < 0. This + * is an internal function with _no_ error checking done unless assert()s + * are enabled. + * + * Note: bufend is a pointer to the END of the buffer passed. + * Call like this: + * char buf[SIZE], *p; + * p = _xltostr(buf + sizeof(buf) - 1, {unsigned int}, 10, __UIM_DECIMAL) + * p = _xltostr(buf + sizeof(buf) - 1, {int}, -10, __UIM_DECIMAL) + * + * WARNING: If base > 10, case _must_be_ either __UIM_LOWER or __UIM_UPPER + * for lower and upper case alphas respectively. + * WARNING: If val is really a signed type, make sure base is negative! + * Otherwise, you could overflow your buffer. + */ +extern char *_uintmaxtostr(char * __restrict bufend, uintmax_t uval, + int base, __UIM_CASE alphacase) attribute_hidden; + +/* TODO -- make this either a (possibly inline) function? */ +#ifndef __BCC__ +#define _int10tostr(bufend, intval) \ + _uintmaxtostr((bufend), (intval), -10, __UIM_DECIMAL) +#else /* bcc doesn't do prototypes, we need to explicitly cast */ +#define _int10tostr(bufend, intval) \ + _uintmaxtostr((bufend), (uintmax_t)(intval), -10, __UIM_DECIMAL) +#endif + +#define __BUFLEN_INT10TOSTR __UIM_BUFLEN_INT + +#endif /* _UINTMAXTOSTR_H */ diff --git a/conts/posix/libposix/include/posix/bits/uClibc_uwchar.h b/conts/posix/libposix/include/posix/bits/uClibc_uwchar.h new file mode 100644 index 0000000..ba2c42d --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_uwchar.h @@ -0,0 +1,57 @@ +/* Copyright (C) 2003 Manuel Novoa III + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * The GNU C Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the GNU C Library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! + * + * Besides uClibc, I'm using this code in my libc for elks, which is + * a 16-bit environment with a fairly limited compiler. It would make + * things much easier for me if this file isn't modified unnecessarily. + * In particular, please put any new or replacement functions somewhere + * else, and modify the makefile to use your version instead. + * Thanks. Manuel + * + * ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */ + + +/* Define an internal unsigned int type __uwchar_t just large enough + * to hold a wchar_t. + */ + +#ifndef _UCLIBC_UWCHAR_H +#define _UCLIBC_UWCHAR_H + +#include +#include + +#if WCHAR_MIN == 0 +typedef wchar_t __uwchar_t; +#elif WCHAR_MAX <= USHRT_MAX +typedef unsigned short __uwchar_t; +#elif WCHAR_MAX <= UINT_MAX +typedef unsigned int __uwchar_t; +#elif WCHAR_MAX <= ULONG_MAX +typedef unsigned long __uwchar_t; +#elif defined(ULLONG_MAX) && (WCHAR_MAX <= ULLONG_MAX) +typedef unsigned long long __uwchar_t; +#elif WCHAR_MAX <= UINTMAX_MAX +typedef uintmax_t __uwchar_t; +#else +#error Can not determine an appropriate type for __uwchar_t! +#endif + +#endif /* _UCLIBC_UWCHAR_H */ diff --git a/conts/posix/libposix/include/posix/bits/uClibc_va_copy.h b/conts/posix/libposix/include/posix/bits/uClibc_va_copy.h new file mode 100644 index 0000000..98663fc --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uClibc_va_copy.h @@ -0,0 +1,40 @@ +/* Copyright (C) 2005 Manuel Novoa III + * + * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * The GNU C Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the GNU C Library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + */ + +#ifndef _UCLIBC_VA_COPY_H +#define _UCLIBC_VA_COPY_H 1 + +#include + +/* Deal with pre-C99 compilers. */ +#ifndef va_copy + +#ifdef __va_copy +#define va_copy(A,B) __va_copy(A,B) +#else +#warning Neither va_copy (C99/SUSv3) or __va_copy is defined. Using a simple copy instead. But you should really check that this is appropriate and supply an arch-specific override if necessary. + /* the glibc manual suggests that this will usually suffice when + __va_copy doesn't exist. */ +#define va_copy(A,B) A = B +#endif + +#endif /* va_copy */ + +#endif /* _UCLIBC_VA_COPY_H */ diff --git a/conts/posix/libposix/include/posix/bits/uio.h b/conts/posix/libposix/include/posix/bits/uio.h new file mode 100644 index 0000000..6a283ed --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/uio.h @@ -0,0 +1,50 @@ +/* Copyright (C) 1996, 1997, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#if !defined _SYS_UIO_H && !defined _FCNTL_H +# error "Never include directly; use instead." +#endif + +#ifndef _BITS_UIO_H +#define _BITS_UIO_H 1 + +#include + + +/* We should normally use the Linux kernel header file to define this + type and macros but this calls for trouble because of the header + includes other kernel headers. */ + +/* Size of object which can be written atomically. + + This macro has different values in different kernel versions. The + latest versions of the kernel use 1024 and this is good choice. Since + the C library implementation of readv/writev is able to emulate the + functionality even if the currently running kernel does not support + this large value the readv/writev call will not fail because of this. */ +#define UIO_MAXIOV 1024 + + +/* Structure for scatter/gather I/O. */ +struct iovec + { + void *iov_base; /* Pointer to data. */ + size_t iov_len; /* Length of data. */ + }; + +#endif diff --git a/conts/posix/libposix/include/posix/bits/ustat.h b/conts/posix/libposix/include/posix/bits/ustat.h new file mode 100644 index 0000000..69c6b72 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/ustat.h @@ -0,0 +1,31 @@ +/* Copyright (C) 1997, 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_USTAT_H +# error "Never include directly; use instead." +#endif + +#include + +struct ustat + { + __daddr_t f_tfree; /* Number of free blocks. */ + __ino_t f_tinode; /* Number of free inodes. */ + char f_fname[6]; + char f_fpack[6]; + }; diff --git a/conts/posix/libposix/include/posix/bits/utmp.h b/conts/posix/libposix/include/posix/bits/utmp.h new file mode 100644 index 0000000..e855ad7 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/utmp.h @@ -0,0 +1,125 @@ +/* The `struct utmp' type, describing entries in the utmp file. GNU version. + Copyright (C) 1993, 1996, 1997, 1998, 1999, 2002 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _UTMP_H +# error "Never include directly; use instead." +#endif + +#include +#include +#include +#include + + +#define UT_LINESIZE 32 +#define UT_NAMESIZE 32 +#define UT_HOSTSIZE 256 + + +/* The structure describing an entry in the database of + previous logins. */ +struct lastlog + { +#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32 + int32_t ll_time; +#else + __time_t ll_time; +#endif + char ll_line[UT_LINESIZE]; + char ll_host[UT_HOSTSIZE]; + }; + + +/* The structure describing the status of a terminated process. This + type is used in `struct utmp' below. */ +struct exit_status + { + short int e_termination; /* Process termination status. */ + short int e_exit; /* Process exit status. */ + }; + + +/* The structure describing an entry in the user accounting database. */ +struct utmp +{ + short int ut_type; /* Type of login. */ + pid_t ut_pid; /* Process ID of login process. */ + char ut_line[UT_LINESIZE]; /* Devicename. */ + char ut_id[4]; /* Inittab ID. */ + char ut_user[UT_NAMESIZE]; /* Username. */ + char ut_host[UT_HOSTSIZE]; /* Hostname for remote login. */ + struct exit_status ut_exit; /* Exit status of a process marked + as DEAD_PROCESS. */ +/* The ut_session and ut_tv fields must be the same size when compiled + 32- and 64-bit. This allows data files and shared memory to be + shared between 32- and 64-bit applications. */ +#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32 + int32_t ut_session; /* Session ID, used for windowing. */ + struct + { + int32_t tv_sec; /* Seconds. */ + int32_t tv_usec; /* Microseconds. */ + } ut_tv; /* Time entry was made. */ +#else + long int ut_session; /* Session ID, used for windowing. */ + struct timeval ut_tv; /* Time entry was made. */ +#endif + + int32_t ut_addr_v6[4]; /* Internet address of remote host. */ + char __unused[20]; /* Reserved for future use. */ +}; + +/* Backwards compatibility hacks. */ +#define ut_name ut_user +#ifndef _NO_UT_TIME +/* We have a problem here: `ut_time' is also used otherwise. Define + _NO_UT_TIME if the compiler complains. */ +# define ut_time ut_tv.tv_sec +#endif +#define ut_xtime ut_tv.tv_sec +#define ut_addr ut_addr_v6[0] + + +/* Values for the `ut_type' field of a `struct utmp'. */ +#define EMPTY 0 /* No valid user accounting information. */ + +#define RUN_LVL 1 /* The system's runlevel. */ +#define BOOT_TIME 2 /* Time of system boot. */ +#define NEW_TIME 3 /* Time after system clock changed. */ +#define OLD_TIME 4 /* Time when system clock changed. */ + +#define INIT_PROCESS 5 /* Process spawned by the init process. */ +#define LOGIN_PROCESS 6 /* Session leader of a logged in user. */ +#define USER_PROCESS 7 /* Normal process. */ +#define DEAD_PROCESS 8 /* Terminated process. */ + +#define ACCOUNTING 9 + +/* Old Linux name for the EMPTY type. */ +#define UT_UNKNOWN EMPTY + + +/* Tell the user that we have a modern system with UT_HOST, UT_PID, + UT_TYPE, UT_ID and UT_TV fields. */ +#define _HAVE_UT_TYPE 1 +#define _HAVE_UT_PID 1 +#define _HAVE_UT_ID 1 +#define _HAVE_UT_TV 1 +#define _HAVE_UT_HOST 1 diff --git a/conts/posix/libposix/include/posix/bits/utmpx.h b/conts/posix/libposix/include/posix/bits/utmpx.h new file mode 100644 index 0000000..c84cda6 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/utmpx.h @@ -0,0 +1,103 @@ +/* Structures and definitions for the user accounting database. GNU version. + Copyright (C) 1997, 1998, 2000, 2001, 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _UTMPX_H +# error "Never include directly; use instead." +#endif + +#include +#include +#include + + +#ifdef __USE_GNU +# include +# define _PATH_UTMPX _PATH_UTMP +# define _PATH_WTMPX _PATH_WTMP +#endif + + +#define __UT_LINESIZE 32 +#define __UT_NAMESIZE 32 +#define __UT_HOSTSIZE 256 + + +/* The structure describing the status of a terminated process. This + type is used in `struct utmpx' below. */ +struct __exit_status + { +#ifdef __USE_GNU + short int e_termination; /* Process termination status. */ + short int e_exit; /* Process exit status. */ +#else + short int __e_termination; /* Process termination status. */ + short int __e_exit; /* Process exit status. */ +#endif + }; + + +/* The structure describing an entry in the user accounting database. */ +struct utmpx +{ + short int ut_type; /* Type of login. */ + __pid_t ut_pid; /* Process ID of login process. */ + char ut_line[__UT_LINESIZE]; /* Devicename. */ + char ut_id[4]; /* Inittab ID. */ + char ut_user[__UT_NAMESIZE]; /* Username. */ + char ut_host[__UT_HOSTSIZE]; /* Hostname for remote login. */ + struct __exit_status ut_exit; /* Exit status of a process marked + as DEAD_PROCESS. */ + +/* The fields ut_session and ut_tv must be the same size when compiled + 32- and 64-bit. This allows files and shared memory to be shared + between 32- and 64-bit applications. */ +#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32 + __int32_t ut_session; /* Session ID, used for windowing. */ + struct + { + __int32_t tv_sec; /* Seconds. */ + __int32_t tv_usec; /* Microseconds. */ + } ut_tv; /* Time entry was made. */ +#else + long int ut_session; /* Session ID, used for windowing. */ + struct timeval ut_tv; /* Time entry was made. */ +#endif + __int32_t ut_addr_v6[4]; /* Internet address of remote host. */ + char __unused[20]; /* Reserved for future use. */ +}; + + +/* Values for the `ut_type' field of a `struct utmpx'. */ +#define EMPTY 0 /* No valid user accounting information. */ + +#ifdef __USE_GNU +# define RUN_LVL 1 /* The system's runlevel. */ +#endif +#define BOOT_TIME 2 /* Time of system boot. */ +#define NEW_TIME 3 /* Time after system clock changed. */ +#define OLD_TIME 4 /* Time when system clock changed. */ + +#define INIT_PROCESS 5 /* Process spawned by the init process. */ +#define LOGIN_PROCESS 6 /* Session leader of a logged in user. */ +#define USER_PROCESS 7 /* Normal process. */ +#define DEAD_PROCESS 8 /* Terminated process. */ + +#ifdef __USE_GNU +# define ACCOUNTING 9 /* System accounting. */ +#endif diff --git a/conts/posix/libposix/include/posix/bits/utsname.h b/conts/posix/libposix/include/posix/bits/utsname.h new file mode 100644 index 0000000..35e71e3 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/utsname.h @@ -0,0 +1,29 @@ +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_UTSNAME_H +# error "Never include directly; use instead." +#endif + +/* Length of the entries in `struct utsname' is 65. */ +#define _UTSNAME_LENGTH 65 + +/* Linux provides as additional information in the `struct utsname' + the name of the current domain. Define _UTSNAME_DOMAIN_LENGTH + to a value != 0 to activate this entry. */ +#define _UTSNAME_DOMAIN_LENGTH _UTSNAME_LENGTH diff --git a/conts/posix/libposix/include/posix/bits/waitflags.h b/conts/posix/libposix/include/posix/bits/waitflags.h new file mode 100644 index 0000000..464cedb --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/waitflags.h @@ -0,0 +1,38 @@ +/* Definitions of flag bits for `waitpid' et al. + Copyright (C) 1992,1996,1997,2000,2004,2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#if !defined _SYS_WAIT_H && !defined _STDLIB_H +# error "Never include directly; use instead." +#endif + + +/* Bits in the third argument to `waitpid'. */ +#define WNOHANG 1 /* Don't block waiting. */ +#define WUNTRACED 2 /* Report status of stopped children. */ + +/* Bits in the fourth argument to `waitid'. */ +#define WSTOPPED 2 /* Report stopped child (same as WUNTRACED). */ +#define WEXITED 4 /* Report dead child. */ +#define WCONTINUED 8 /* Report continued child. */ +#define WNOWAIT 0x01000000 /* Don't reap, just poll status. */ + +#define __WNOTHREAD 0x20000000 /* Don't wait on children of other threads + in this group */ +#define __WALL 0x40000000 /* Wait for any child. */ +#define __WCLONE 0x80000000 /* Wait for cloned process. */ diff --git a/conts/posix/libposix/include/posix/bits/waitstatus.h b/conts/posix/libposix/include/posix/bits/waitstatus.h new file mode 100644 index 0000000..699c224 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/waitstatus.h @@ -0,0 +1,106 @@ +/* Definitions of status bits for `wait' et al. + Copyright (C) 1992,1994,1996,1997,2000,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#if !defined _SYS_WAIT_H && !defined _STDLIB_H +# error "Never include directly; use instead." +#endif + + +/* Everything extant so far uses these same bits. */ + + +/* If WIFEXITED(STATUS), the low-order 8 bits of the status. */ +#define __WEXITSTATUS(status) (((status) & 0xff00) >> 8) + +/* If WIFSIGNALED(STATUS), the terminating signal. */ +#define __WTERMSIG(status) ((status) & 0x7f) + +/* If WIFSTOPPED(STATUS), the signal that stopped the child. */ +#define __WSTOPSIG(status) __WEXITSTATUS(status) + +/* Nonzero if STATUS indicates normal termination. */ +#define __WIFEXITED(status) (__WTERMSIG(status) == 0) + +/* Nonzero if STATUS indicates termination by a signal. */ +#define __WIFSIGNALED(status) \ + (((signed char) (((status) & 0x7f) + 1) >> 1) > 0) + +/* Nonzero if STATUS indicates the child is stopped. */ +#define __WIFSTOPPED(status) (((status) & 0xff) == 0x7f) + +/* Nonzero if STATUS indicates the child continued after a stop. We only + define this if provides the WCONTINUED flag bit. */ +#ifdef WCONTINUED +# define __WIFCONTINUED(status) ((status) == __W_CONTINUED) +#endif + +/* Nonzero if STATUS indicates the child dumped core. */ +#define __WCOREDUMP(status) ((status) & __WCOREFLAG) + +/* Macros for constructing status values. */ +#define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig)) +#define __W_STOPCODE(sig) ((sig) << 8 | 0x7f) +#define __W_CONTINUED 0xffff +#define __WCOREFLAG 0x80 + + +#ifdef __USE_BSD + +# include + +union wait + { + int w_status; + struct + { +# if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int __w_termsig:7; /* Terminating signal. */ + unsigned int __w_coredump:1; /* Set if dumped core. */ + unsigned int __w_retcode:8; /* Return code if exited normally. */ + unsigned int:16; +# endif /* Little endian. */ +# if __BYTE_ORDER == __BIG_ENDIAN + unsigned int:16; + unsigned int __w_retcode:8; + unsigned int __w_coredump:1; + unsigned int __w_termsig:7; +# endif /* Big endian. */ + } __wait_terminated; + struct + { +# if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int __w_stopval:8; /* W_STOPPED if stopped. */ + unsigned int __w_stopsig:8; /* Stopping signal. */ + unsigned int:16; +# endif /* Little endian. */ +# if __BYTE_ORDER == __BIG_ENDIAN + unsigned int:16; + unsigned int __w_stopsig:8; /* Stopping signal. */ + unsigned int __w_stopval:8; /* W_STOPPED if stopped. */ +# endif /* Big endian. */ + } __wait_stopped; + }; + +# define w_termsig __wait_terminated.__w_termsig +# define w_coredump __wait_terminated.__w_coredump +# define w_retcode __wait_terminated.__w_retcode +# define w_stopsig __wait_stopped.__w_stopsig +# define w_stopval __wait_stopped.__w_stopval + +#endif /* Use BSD. */ diff --git a/conts/posix/libposix/include/posix/bits/wchar.h b/conts/posix/libposix/include/posix/bits/wchar.h new file mode 100644 index 0000000..ef1f563 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/wchar.h @@ -0,0 +1,26 @@ +/* wchar_t type related definitions. + Copyright (C) 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _BITS_WCHAR_H +#define _BITS_WCHAR_H 1 + +#define __WCHAR_MIN (-2147483647 - 1) +#define __WCHAR_MAX (2147483647) + +#endif /* bits/wchar.h */ diff --git a/conts/posix/libposix/include/posix/bits/wordsize.h b/conts/posix/libposix/include/posix/bits/wordsize.h new file mode 100644 index 0000000..ba643b6 --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/wordsize.h @@ -0,0 +1,19 @@ +/* Copyright (C) 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#define __WORDSIZE 32 diff --git a/conts/posix/libposix/include/posix/bits/xopen_lim.h b/conts/posix/libposix/include/posix/bits/xopen_lim.h new file mode 100644 index 0000000..c2363ab --- /dev/null +++ b/conts/posix/libposix/include/posix/bits/xopen_lim.h @@ -0,0 +1,150 @@ +/* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * Never include this file directly; use instead. + */ + +/* Additional definitions from X/Open Portability Guide, Issue 4, Version 2 + System Interfaces and Headers, 4.16 + + Please note only the values which are not greater than the minimum + stated in the standard document are listed. The `sysconf' functions + should be used to obtain the actual value. */ + +#ifndef _XOPEN_LIM_H +#define _XOPEN_LIM_H 1 + +#define __need_IOV_MAX +#include + +/* We do not provide fixed values for + + ARG_MAX Maximum length of argument to the `exec' function + including environment data. + + ATEXIT_MAX Maximum number of functions that may be registered + with `atexit'. + + CHILD_MAX Maximum number of simultaneous processes per real + user ID. + + OPEN_MAX Maximum number of files that one process can have open + at anyone time. + + PAGESIZE + PAGE_SIZE Size of bytes of a page. + + PASS_MAX Maximum number of significant bytes in a password. + + We only provide a fixed limit for + + IOV_MAX Maximum number of `iovec' structures that one process has + available for use with `readv' or writev'. + + if this is indeed fixed by the underlying system. +*/ + + +/* Maximum number of `iovec' structures that one process has available + for use with `readv' or writev'. */ +#define _XOPEN_IOV_MAX _POSIX_UIO_MAXIOV + + +/* Maximum value of `digit' in calls to the `printf' and `scanf' + functions. Posix dictates this should be a minimum of 9 */ +#if !defined(__UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS__) || (__UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS__ <= 1) +#undef NL_ARGMAX +#elif __UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS__ < 9 +#define NL_ARGMAX 9 +#else +#define NL_ARGMAX __UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS__ +#endif + +/* Maximum number of bytes in a `LANG' name. We have no limit. */ +#define NL_LANGMAX _POSIX2_LINE_MAX + +/* Maximum message number. We have no limit. */ +#define NL_MSGMAX INT_MAX + +/* Maximum number of bytes in N-to-1 collation mapping. We have no + limit. */ +#define NL_NMAX INT_MAX + +/* Maximum set number. We have no limit. */ +#define NL_SETMAX INT_MAX + +/* Maximum number of bytes in a message. We have no limit. */ +#define NL_TEXTMAX INT_MAX + +/* Default process priority. */ +#define NZERO 20 + + +/* Number of bits in a word of type `int'. */ +#ifdef INT_MAX +# if INT_MAX == 32767 +# define WORD_BIT 16 +# else +# if INT_MAX == 2147483647 +# define WORD_BIT 32 +# else +/* Safe assumption. */ +# define WORD_BIT 64 +# endif +# endif +#elif defined __INT_MAX__ +# if __INT_MAX__ == 32767 +# define WORD_BIT 16 +# else +# if __INT_MAX__ == 2147483647 +# define WORD_BIT 32 +# else +/* Safe assumption. */ +# define WORD_BIT 64 +# endif +# endif +#else +# define WORD_BIT 32 +#endif + +/* Number of bits in a word of type `long int'. */ +#ifdef LONG_MAX +# if LONG_MAX == 2147483647 +# define LONG_BIT 32 +# else +/* Safe assumption. */ +# define LONG_BIT 64 +# endif +#elif defined __LONG_MAX__ +# if __LONG_MAX__ == 2147483647 +# define LONG_BIT 32 +# else +/* Safe assumption. */ +# define LONG_BIT 64 +# endif +#else +# include +# if __WORDSIZE == 64 +# define LONG_BIT 64 +# else +# define LONG_BIT 32 +# endif +#endif + +#endif /* bits/xopen_lim.h */ diff --git a/conts/posix/libposix/include/posix/byteswap.h b/conts/posix/libposix/include/posix/byteswap.h new file mode 100644 index 0000000..b61d4dd --- /dev/null +++ b/conts/posix/libposix/include/posix/byteswap.h @@ -0,0 +1,40 @@ +/* Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _BYTESWAP_H +#define _BYTESWAP_H 1 + +/* Get the machine specific, optimized definitions. */ +#include + + +/* The following definitions must all be macros since otherwise some + of the possible optimizations are not possible. */ + +/* Return a value with all bytes in the 16 bit argument swapped. */ +#define bswap_16(x) __bswap_16 (x) + +/* Return a value with all bytes in the 32 bit argument swapped. */ +#define bswap_32(x) __bswap_32 (x) + +#if defined __GNUC__ && __GNUC__ >= 2 +/* Return a value with all bytes in the 64 bit argument swapped. */ +# define bswap_64(x) __bswap_64 (x) +#endif + +#endif /* byteswap.h */ diff --git a/conts/posix/libposix/include/posix/complex.h b/conts/posix/libposix/include/posix/complex.h new file mode 100644 index 0000000..c16fcfa --- /dev/null +++ b/conts/posix/libposix/include/posix/complex.h @@ -0,0 +1,107 @@ +/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99: 7.3 Complex arithmetic + */ + +#ifndef _COMPLEX_H +#define _COMPLEX_H 1 + +#include + +/* Get general and ISO C99 specific information. */ +#include + +__BEGIN_DECLS + +/* We might need to add support for more compilers here. But since ISO + C99 is out hopefully all maintained compilers will soon provide the data + types `float complex' and `double complex'. */ +#if __GNUC_PREREQ(2, 7) && !__GNUC_PREREQ(2, 97) +# define _Complex __complex__ +#endif + +#define complex _Complex + +/* Narrowest imaginary unit. This depends on the floating-point + evaluation method. + XXX This probably has to go into a gcc related file. */ +#define _Complex_I (__extension__ 1.0iF) + +/* Another more descriptive name is `I'. + XXX Once we have the imaginary support switch this to _Imaginary_I. */ +#undef I +#define I _Complex_I + +/* The file contains the prototypes for all the + actual math functions. These macros are used for those prototypes, + so we can easily declare each function as both `name' and `__name', + and can declare the float versions `namef' and `__namef'. */ + +#define __MATHCALL(function, args) \ + __MATHDECL (_Mdouble_complex_,function, args) +#define __MATHDECL(type, function, args) \ + __MATHDECL_1(type, function, args); \ + __MATHDECL_1(type, __CONCAT(__,function), args) +#define __MATHDECL_1(type, function, args) \ + extern type __MATH_PRECNAME(function) args __THROW + +#define _Mdouble_ double +#define __MATH_PRECNAME(name) name +#include +#undef _Mdouble_ +#undef __MATH_PRECNAME + +/* Now the float versions. */ +#ifndef _Mfloat_ +# define _Mfloat_ float +#endif +#define _Mdouble_ _Mfloat_ +#ifdef __STDC__ +# define __MATH_PRECNAME(name) name##f +#else +# define __MATH_PRECNAME(name) name/**/f +#endif +#include +#undef _Mdouble_ +#undef __MATH_PRECNAME + +/* And the long double versions. It is non-critical to define them + here unconditionally since `long double' is required in ISO C99. */ +#if __STDC__ - 0 || __GNUC__ - 0 && !defined __NO_LONG_DOUBLE_MATH +# ifndef _Mlong_double_ +# define _Mlong_double_ long double +# endif +# define _Mdouble_ _Mlong_double_ +# ifdef __STDC__ +# define __MATH_PRECNAME(name) name##l +# else +# define __MATH_PRECNAME(name) name/**/l +# endif +# include +#endif +#undef _Mdouble_ +#undef __MATH_PRECNAME +#undef __MATHDECL_1 +#undef __MATHDECL +#undef __MATHCALL + +__END_DECLS + +#endif /* complex.h */ diff --git a/conts/posix/libposix/include/posix/cpio.h b/conts/posix/libposix/include/posix/cpio.h new file mode 100644 index 0000000..fae3275 --- /dev/null +++ b/conts/posix/libposix/include/posix/cpio.h @@ -0,0 +1,74 @@ +/* Extended cpio format from POSIX.1. + This file is part of the GNU C Library. + Copyright (C) 1992, 1998 Free Software Foundation, Inc. + NOTE: The canonical source of this file is maintained with the GNU cpio. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _CPIO_H +#define _CPIO_H 1 + +/* A cpio archive consists of a sequence of files. + Each file has a 76 byte header, + a variable length, NUL terminated filename, + and variable length file data. + A header for a filename "TRAILER!!!" indicates the end of the archive. */ + +/* All the fields in the header are ISO 646 (approximately ASCII) strings + of octal numbers, left padded, not NUL terminated. + + Field Name Length in Bytes Notes + c_magic 6 must be "070707" + c_dev 6 + c_ino 6 + c_mode 6 see below for value + c_uid 6 + c_gid 6 + c_nlink 6 + c_rdev 6 only valid for chr and blk special files + c_mtime 11 + c_namesize 6 count includes terminating NUL in pathname + c_filesize 11 must be 0 for FIFOs and directories */ + +/* Value for the field `c_magic'. */ +#define MAGIC "070707" + +/* Values for c_mode, OR'd together: */ + +#define C_IRUSR 000400 +#define C_IWUSR 000200 +#define C_IXUSR 000100 +#define C_IRGRP 000040 +#define C_IWGRP 000020 +#define C_IXGRP 000010 +#define C_IROTH 000004 +#define C_IWOTH 000002 +#define C_IXOTH 000001 + +#define C_ISUID 004000 +#define C_ISGID 002000 +#define C_ISVTX 001000 + +#define C_ISBLK 060000 +#define C_ISCHR 020000 +#define C_ISDIR 040000 +#define C_ISFIFO 010000 +#define C_ISSOCK 0140000 +#define C_ISLNK 0120000 +#define C_ISCTG 0110000 +#define C_ISREG 0100000 + +#endif /* cpio.h */ diff --git a/conts/posix/libposix/include/posix/crypt.h b/conts/posix/libposix/include/posix/crypt.h new file mode 100644 index 0000000..f3fed7c --- /dev/null +++ b/conts/posix/libposix/include/posix/crypt.h @@ -0,0 +1,41 @@ +/* + * crypt(3) implementation for uClibc + * + * The uClibc Library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * The GNU C Library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the GNU C Library; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA. + * + */ + +#ifndef _CRYPT_H +#define _CRYPT_H 1 + +#include + +__BEGIN_DECLS + +/* Encrypt characters from KEY using salt to perturb the encryption method. + * If salt begins with "$1$", MD5 hashing is used instead of DES. */ +extern char *crypt (const char *__key, const char *__salt); + +/* Setup DES tables according KEY. */ +extern void setkey (const char *__key); + +/* Encrypt data in BLOCK in place if EDFLAG is zero; otherwise decrypt + block in place. */ +extern void encrypt (char *__block, int __edflag); + +__END_DECLS + +#endif /* crypt.h */ diff --git a/conts/posix/libposix/include/posix/ctype.h b/conts/posix/libposix/include/posix/ctype.h new file mode 100644 index 0000000..78cff7d --- /dev/null +++ b/conts/posix/libposix/include/posix/ctype.h @@ -0,0 +1,383 @@ +/* Copyright (C) 1991,92,93,95,96,97,98,99,2001,02 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard 7.4: Character handling + */ + +#ifndef _CTYPE_H +#define _CTYPE_H 1 + +#include +#include + +#ifdef __UCLIBC_HAS_CTYPE_TABLES__ + +__BEGIN_DECLS + +#ifndef _ISbit +/* These are all the characteristics of characters. + If there get to be more than 16 distinct characteristics, + __ctype_mask_t will need to be adjusted. */ + +# define _ISbit(bit) (1 << (bit)) + +enum +{ + _ISupper = _ISbit (0), /* UPPERCASE. */ + _ISlower = _ISbit (1), /* lowercase. */ + _ISalpha = _ISbit (2), /* Alphabetic. */ + _ISdigit = _ISbit (3), /* Numeric. */ + _ISxdigit = _ISbit (4), /* Hexadecimal numeric. */ + _ISspace = _ISbit (5), /* Whitespace. */ + _ISprint = _ISbit (6), /* Printing. */ + _ISgraph = _ISbit (7), /* Graphical. */ + _ISblank = _ISbit (8), /* Blank (usually SPC and TAB). */ + _IScntrl = _ISbit (9), /* Control character. */ + _ISpunct = _ISbit (10), /* Punctuation. */ + _ISalnum = _ISbit (11) /* Alphanumeric. */ +}; +#else +#error _ISbit already defined! +#endif /* ! _ISbit */ + +#include + +#ifdef __UCLIBC_HAS_CTYPE_SIGNED__ +# define __UCLIBC_CTYPE_IN_TO_DOMAIN(c) (((unsigned int)((c) + 128)) < 384) + +#else /* __UCLIBC_HAS_CTYPE_SIGNED__ */ +# define __UCLIBC_CTYPE_IN_TO_DOMAIN(c) (((unsigned int)(c)) < 256) + +#endif /* __UCLIBC_HAS_CTYPE_SIGNED__ */ + +/* In the thread-specific locale model (see `uselocale' in ) + we cannot use global variables for these as was done in the past. + Instead, the following accessor functions return the address of + each variable, which is local to the current thread if multithreaded. + + These point into arrays of 384, so they can be indexed by any `unsigned + char' value [0,255]; by EOF (-1); or by any `signed char' value + [-128,-1). ISO C requires that the ctype functions work for `unsigned + char' values and for EOF; we also support negative `signed char' values + for broken old programs. The case conversion arrays are of `int's + rather than `unsigned char's because tolower (EOF) must be EOF, which + doesn't fit into an `unsigned char'. But today more important is that + the arrays are also used for multi-byte character sets. */ + +/* uClibc differences: + * + * When __UCLIBC_HAS_CTYPE_SIGNED is defined, + * + * The upper and lower mapping arrays are type int16_t, so that + * they may store all char values plus EOF. The glibc reasoning + * given above for these being type int is questionable, as the + * ctype mapping functions map from the set of (unsigned) char + * and EOF back into the set. They have no awareness of multi-byte + * or wide characters. + * + * Otherwise, + * + * The ctype array is defined for -1..255. + * The upper and lower mapping arrays are defined for 0..255. + * The upper and lower mapping arrays are type unsigned char. + */ + +/* Pointers to the default C-locale data. */ +extern const __ctype_mask_t *__C_ctype_b; +extern const __ctype_touplow_t *__C_ctype_toupper; +extern const __ctype_touplow_t *__C_ctype_tolower; + +#ifdef __UCLIBC_HAS_XLOCALE__ + +extern __const __ctype_mask_t **__ctype_b_loc (void) + __attribute__ ((__const)); +extern __const __ctype_touplow_t **__ctype_tolower_loc (void) + __attribute__ ((__const)); +extern __const __ctype_touplow_t **__ctype_toupper_loc (void) + __attribute__ ((__const)); + +#define __UCLIBC_CTYPE_B (*__ctype_b_loc()) +#define __UCLIBC_CTYPE_TOLOWER (*__ctype_tolower_loc()) +#define __UCLIBC_CTYPE_TOUPPER (*__ctype_toupper_loc()) + +#else /* __UCLIBC_HAS_XLOCALE__ */ + +/* Pointers to the current global locale data in use. */ +extern const __ctype_mask_t *__ctype_b; +extern const __ctype_touplow_t *__ctype_toupper; +extern const __ctype_touplow_t *__ctype_tolower; + +#define __UCLIBC_CTYPE_B (__ctype_b) +#define __UCLIBC_CTYPE_TOLOWER (__ctype_tolower) +#define __UCLIBC_CTYPE_TOUPPER (__ctype_toupper) + +#endif /* __UCLIBC_HAS_XLOCALE__ */ + +#define __isctype(c, type) \ + ((__UCLIBC_CTYPE_B)[(int) (c)] & (__ctype_mask_t) type) + +#define __isascii(c) (((c) & ~0x7f) == 0) /* If C is a 7 bit value. */ +#define __toascii(c) ((c) & 0x7f) /* Mask off high bits. */ + +#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc) +/* isdigit() is really locale-invariant, so provide some small fast macros. + * These are uClibc-specific. */ +#define __isdigit_char(C) (((unsigned char)((C) - '0')) <= 9) +#define __isdigit_int(C) (((unsigned int)((C) - '0')) <= 9) +#endif + +#define __exctype(name) extern int name (int) __THROW + +__BEGIN_NAMESPACE_STD + +/* The following names are all functions: + int isCHARACTERISTIC(int c); + which return nonzero iff C has CHARACTERISTIC. + For the meaning of the characteristic names, see the `enum' above. */ +__exctype (isalnum); +__exctype (isalpha); +__exctype (iscntrl); +__exctype (isdigit); +__exctype (islower); +__exctype (isgraph); +__exctype (isprint); +__exctype (ispunct); +__exctype (isspace); +__exctype (isupper); +__exctype (isxdigit); + + +/* Return the lowercase version of C. */ +extern int tolower (int __c) __THROW; + +/* Return the uppercase version of C. */ +extern int toupper (int __c) __THROW; + +__END_NAMESPACE_STD + + +/* ISO C99 introduced one new function. */ +#ifdef __USE_ISOC99 +__BEGIN_NAMESPACE_C99 + +__exctype (isblank); + +__END_NAMESPACE_C99 +#endif + +#ifdef __USE_GNU +/* Test C for a set of character classes according to MASK. */ +extern int isctype (int __c, int __mask) __THROW; +#endif + +#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN + +/* Return nonzero iff C is in the ASCII set + (i.e., is no more than 7 bits wide). */ +extern int isascii (int __c) __THROW; + +/* Return the part of C that is in the ASCII set + (i.e., the low-order 7 bits of C). */ +extern int toascii (int __c) __THROW; + +/* These are the same as `toupper' and `tolower' except that they do not + check the argument for being in the range of a `char'. */ +__exctype (_toupper); +__exctype (_tolower); +#endif /* Use SVID or use misc. */ + +/* This code is needed for the optimized mapping functions. */ +#define __tobody(c, f, a, args) \ + (__extension__ \ + ({ int __res; \ + if (sizeof (c) > 1) \ + { \ + if (__builtin_constant_p (c)) \ + { \ + int __c = (c); \ + __res = __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (a)[__c] : __c; \ + } \ + else \ + __res = f args; \ + } \ + else \ + __res = (a)[(int) (c)]; \ + __res; })) + +#if !defined __NO_CTYPE && !defined __cplusplus +# define isalnum(c) __isctype((c), _ISalnum) +# define isalpha(c) __isctype((c), _ISalpha) +# define iscntrl(c) __isctype((c), _IScntrl) +# define isdigit(c) __isctype((c), _ISdigit) +# define islower(c) __isctype((c), _ISlower) +# define isgraph(c) __isctype((c), _ISgraph) +# define isprint(c) __isctype((c), _ISprint) +# define ispunct(c) __isctype((c), _ISpunct) +# define isspace(c) __isctype((c), _ISspace) +# define isupper(c) __isctype((c), _ISupper) +# define isxdigit(c) __isctype((c), _ISxdigit) + +# ifdef __USE_ISOC99 +# define isblank(c) __isctype((c), _ISblank) +# endif + +# ifdef __USE_EXTERN_INLINES +extern __inline int +__NTH (tolower (int __c)) +{ + return __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (__UCLIBC_CTYPE_TOLOWER)[__c] : __c; +} + +extern __inline int +__NTH (toupper (int __c)) +{ + return __UCLIBC_CTYPE_IN_TO_DOMAIN(__c) ? (__UCLIBC_CTYPE_TOUPPER)[__c] : __c; +} +# endif + +# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus +# define tolower(c) __tobody (c, tolower, __UCLIBC_CTYPE_TOLOWER, (c)) +# define toupper(c) __tobody (c, toupper, __UCLIBC_CTYPE_TOUPPER, (c)) +# endif /* Optimizing gcc */ + +# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN +# define isascii(c) __isascii (c) +# define toascii(c) __toascii (c) + +# define _tolower(c) ((int) (__UCLIBC_CTYPE_TOLOWER)[(int) (c)]) +# define _toupper(c) ((int) (__UCLIBC_CTYPE_TOUPPER)[(int) (c)]) +# endif + +#endif /* Not __NO_CTYPE. */ + + +#if defined(__USE_GNU) && defined(__UCLIBC_HAS_XLOCALE__) +/* The concept of one static locale per category is not very well + thought out. Many applications will need to process its data using + information from several different locales. Another application is + the implementation of the internationalization handling in the + upcoming ISO C++ standard library. To support this another set of + the functions using locale data exist which have an additional + argument. + + Attention: all these functions are *not* standardized in any form. + This is a proof-of-concept implementation. */ + +/* Structure for reentrant locale using functions. This is an + (almost) opaque type for the user level programs. */ +# include + +/* These definitions are similar to the ones above but all functions + take as an argument a handle for the locale which shall be used. */ +# define __isctype_l(c, type, locale) \ + ((locale)->__ctype_b[(int) (c)] & (__ctype_mask_t) type) + +# define __exctype_l(name) \ + extern int name (int, __locale_t) __THROW + +/* The following names are all functions: + int isCHARACTERISTIC(int c, locale_t *locale); + which return nonzero iff C has CHARACTERISTIC. + For the meaning of the characteristic names, see the `enum' above. */ +__exctype_l (isalnum_l); +__exctype_l (isalpha_l); +__exctype_l (iscntrl_l); +__exctype_l (isdigit_l); +__exctype_l (islower_l); +__exctype_l (isgraph_l); +__exctype_l (isprint_l); +__exctype_l (ispunct_l); +__exctype_l (isspace_l); +__exctype_l (isupper_l); +__exctype_l (isxdigit_l); + +__exctype_l (isblank_l); + + +/* Return the lowercase version of C in locale L. */ +extern int __tolower_l (int __c, __locale_t __l) __THROW; +extern int tolower_l (int __c, __locale_t __l) __THROW; + +/* Return the uppercase version of C. */ +extern int __toupper_l (int __c, __locale_t __l) __THROW; +extern int toupper_l (int __c, __locale_t __l) __THROW; + +# if __GNUC__ >= 2 && defined __OPTIMIZE__ && !defined __cplusplus +# define __tolower_l(c, locale) \ + __tobody (c, __tolower_l, (locale)->__ctype_tolower, (c, locale)) +# define __toupper_l(c, locale) \ + __tobody (c, __toupper_l, (locale)->__ctype_toupper, (c, locale)) +# define tolower_l(c, locale) __tolower_l ((c), (locale)) +# define toupper_l(c, locale) __toupper_l ((c), (locale)) +# endif /* Optimizing gcc */ + + +# ifndef __NO_CTYPE +# define __isalnum_l(c,l) __isctype_l((c), _ISalnum, (l)) +# define __isalpha_l(c,l) __isctype_l((c), _ISalpha, (l)) +# define __iscntrl_l(c,l) __isctype_l((c), _IScntrl, (l)) +# define __isdigit_l(c,l) __isctype_l((c), _ISdigit, (l)) +# define __islower_l(c,l) __isctype_l((c), _ISlower, (l)) +# define __isgraph_l(c,l) __isctype_l((c), _ISgraph, (l)) +# define __isprint_l(c,l) __isctype_l((c), _ISprint, (l)) +# define __ispunct_l(c,l) __isctype_l((c), _ISpunct, (l)) +# define __isspace_l(c,l) __isctype_l((c), _ISspace, (l)) +# define __isupper_l(c,l) __isctype_l((c), _ISupper, (l)) +# define __isxdigit_l(c,l) __isctype_l((c), _ISxdigit, (l)) + +# define __isblank_l(c,l) __isctype_l((c), _ISblank, (l)) + +# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN +# define __isascii_l(c,l) ((l), __isascii (c)) +# define __toascii_l(c,l) ((l), __toascii (c)) +# endif + +# define isalnum_l(c,l) __isalnum_l ((c), (l)) +# define isalpha_l(c,l) __isalpha_l ((c), (l)) +# define iscntrl_l(c,l) __iscntrl_l ((c), (l)) +# define isdigit_l(c,l) __isdigit_l ((c), (l)) +# define islower_l(c,l) __islower_l ((c), (l)) +# define isgraph_l(c,l) __isgraph_l ((c), (l)) +# define isprint_l(c,l) __isprint_l ((c), (l)) +# define ispunct_l(c,l) __ispunct_l ((c), (l)) +# define isspace_l(c,l) __isspace_l ((c), (l)) +# define isupper_l(c,l) __isupper_l ((c), (l)) +# define isxdigit_l(c,l) __isxdigit_l ((c), (l)) + +# define isblank_l(c,l) __isblank_l ((c), (l)) + +# if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN +# define isascii_l(c,l) __isascii_l ((c), (l)) +# define toascii_l(c,l) __toascii_l ((c), (l)) +# endif + +# endif /* Not __NO_CTYPE. */ + +#endif /* Use GNU. */ + +__END_DECLS + +#else /* __UCLIBC_HAS_CTYPE_TABLES__ */ + +#include + +#endif + +#endif /* ctype.h */ diff --git a/conts/posix/libposix/include/posix/dirent.h b/conts/posix/libposix/include/posix/dirent.h new file mode 100644 index 0000000..565a94d --- /dev/null +++ b/conts/posix/libposix/include/posix/dirent.h @@ -0,0 +1,293 @@ +/* Copyright (C) 1991-2000, 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * POSIX Standard: 5.1.2 Directory Operations + */ + +#ifndef _DIRENT_H +#define _DIRENT_H 1 + +#include + +__BEGIN_DECLS + +#include + +#ifdef __USE_XOPEN +# ifndef __ino_t_defined +# ifndef __USE_FILE_OFFSET64 +typedef __ino_t ino_t; +# else +typedef __ino64_t ino_t; +# endif +# define __ino_t_defined +# endif +# if defined __USE_LARGEFILE64 && !defined __ino64_t_defined +typedef __ino64_t ino64_t; +# define __ino64_t_defined +# endif +#endif + +/* This file defines `struct dirent'. + + It defines the macro `_DIRENT_HAVE_D_NAMLEN' iff there is a `d_namlen' + member that gives the length of `d_name'. + + It defines the macro `_DIRENT_HAVE_D_RECLEN' iff there is a `d_reclen' + member that gives the size of the entire directory entry. + + It defines the macro `_DIRENT_HAVE_D_OFF' iff there is a `d_off' + member that gives the file offset of the next directory entry. + + It defines the macro `_DIRENT_HAVE_D_TYPE' iff there is a `d_type' + member that gives the type of the file. + */ + +#include + +#if (defined __USE_BSD || defined __USE_MISC) && !defined d_fileno +# define d_ino d_fileno /* Backward compatibility. */ +#endif + +/* These macros extract size information from a `struct dirent *'. + They may evaluate their argument multiple times, so it must not + have side effects. Each of these may involve a relatively costly + call to `strlen' on some systems, so these values should be cached. + + _D_EXACT_NAMLEN (DP) returns the length of DP->d_name, not including + its terminating null character. + + _D_ALLOC_NAMLEN (DP) returns a size at least (_D_EXACT_NAMLEN (DP) + 1); + that is, the allocation size needed to hold the DP->d_name string. + Use this macro when you don't need the exact length, just an upper bound. + This macro is less likely to require calling `strlen' than _D_EXACT_NAMLEN. + */ + +#ifdef _DIRENT_HAVE_D_NAMLEN +# define _D_EXACT_NAMLEN(d) ((d)->d_namlen) +# define _D_ALLOC_NAMLEN(d) (_D_EXACT_NAMLEN (d) + 1) +#else +# define _D_EXACT_NAMLEN(d) (strlen ((d)->d_name)) +# ifdef _DIRENT_HAVE_D_RECLEN +# define _D_ALLOC_NAMLEN(d) (((char *) (d) + (d)->d_reclen) - &(d)->d_name[0]) +# else +# define _D_ALLOC_NAMLEN(d) (sizeof (d)->d_name > 1 ? sizeof (d)->d_name : \ + _D_EXACT_NAMLEN (d) + 1) +# endif +#endif + + +#ifdef __USE_BSD +/* File types for `d_type'. */ +enum + { + DT_UNKNOWN = 0, +# define DT_UNKNOWN DT_UNKNOWN + DT_FIFO = 1, +# define DT_FIFO DT_FIFO + DT_CHR = 2, +# define DT_CHR DT_CHR + DT_DIR = 4, +# define DT_DIR DT_DIR + DT_BLK = 6, +# define DT_BLK DT_BLK + DT_REG = 8, +# define DT_REG DT_REG + DT_LNK = 10, +# define DT_LNK DT_LNK + DT_SOCK = 12, +# define DT_SOCK DT_SOCK + DT_WHT = 14 +# define DT_WHT DT_WHT + }; + +/* Convert between stat structure types and directory types. */ +# define IFTODT(mode) (((mode) & 0170000) >> 12) +# define DTTOIF(dirtype) ((dirtype) << 12) +#endif + + +/* This is the data type of directory stream objects. + The actual structure is opaque to users. */ +typedef struct __dirstream DIR; + +/* Open a directory stream on NAME. + Return a DIR stream on the directory, or NULL if it could not be opened. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern DIR *opendir (__const char *__name) __nonnull ((1)); + +/* Close the directory stream DIRP. + Return 0 if successful, -1 if not. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int closedir (DIR *__dirp) __nonnull ((1)); + +/* Read a directory entry from DIRP. Return a pointer to a `struct + dirent' describing the entry, or NULL for EOF or error. The + storage returned may be overwritten by a later readdir call on the + same DIR stream. + + If the Large File Support API is selected we have to use the + appropriate interface. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +#ifndef __USE_FILE_OFFSET64 +extern struct dirent *readdir (DIR *__dirp) __nonnull ((1)); +#else +# ifdef __REDIRECT +extern struct dirent *__REDIRECT (readdir, (DIR *__dirp), readdir64) + __nonnull ((1)); +# else +# define readdir readdir64 +# endif +#endif + +#ifdef __USE_LARGEFILE64 +extern struct dirent64 *readdir64 (DIR *__dirp) __nonnull ((1)); +#endif + +#if defined __USE_POSIX || defined __USE_MISC +/* Reentrant version of `readdir'. Return in RESULT a pointer to the + next entry. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +# ifndef __USE_FILE_OFFSET64 +extern int readdir_r (DIR *__restrict __dirp, + struct dirent *__restrict __entry, + struct dirent **__restrict __result) + __nonnull ((1, 2, 3)); +# else +# ifdef __REDIRECT +extern int __REDIRECT (readdir_r, + (DIR *__restrict __dirp, + struct dirent *__restrict __entry, + struct dirent **__restrict __result), + readdir64_r) __nonnull ((1, 2, 3)); +# else +# define readdir_r readdir64_r +# endif +# endif + +# ifdef __USE_LARGEFILE64 +extern int readdir64_r (DIR *__restrict __dirp, + struct dirent64 *__restrict __entry, + struct dirent64 **__restrict __result) + __nonnull ((1, 2, 3)); +# endif +#endif /* POSIX or misc */ + +/* Rewind DIRP to the beginning of the directory. */ +extern void rewinddir (DIR *__dirp) __THROW __nonnull ((1)); + +#if defined __USE_BSD || defined __USE_MISC || defined __USE_XOPEN +# include + +/* Seek to position POS on DIRP. */ +extern void seekdir (DIR *__dirp, long int __pos) __THROW __nonnull ((1)); + +/* Return the current position of DIRP. */ +extern long int telldir (DIR *__dirp) __THROW __nonnull ((1)); +#endif + +#if defined __USE_BSD || defined __USE_MISC + +/* Return the file descriptor used by DIRP. */ +extern int dirfd (DIR *__dirp) __THROW __nonnull ((1)); + +# if 0 /* defined __OPTIMIZE__ && defined _DIR_dirfd */ +# define dirfd(dirp) _DIR_dirfd (dirp) +# endif + +# ifndef MAXNAMLEN +/* Get the definitions of the POSIX.1 limits. */ +# include + +/* `MAXNAMLEN' is the BSD name for what POSIX calls `NAME_MAX'. */ +# ifdef NAME_MAX +# define MAXNAMLEN NAME_MAX +# else +# define MAXNAMLEN 255 +# endif +# endif + +# define __need_size_t +# include + +/* Scan the directory DIR, calling SELECTOR on each directory entry. + Entries for which SELECT returns nonzero are individually malloc'd, + sorted using qsort with CMP, and collected in a malloc'd array in + *NAMELIST. Returns the number of entries selected, or -1 on error. */ +# ifndef __USE_FILE_OFFSET64 +extern int scandir (__const char *__restrict __dir, + struct dirent ***__restrict __namelist, + int (*__selector) (__const struct dirent *), + int (*__cmp) (__const void *, __const void *)) + __nonnull ((1, 2)); +# else +# ifdef __REDIRECT +extern int __REDIRECT (scandir, + (__const char *__restrict __dir, + struct dirent ***__restrict __namelist, + int (*__selector) (__const struct dirent *), + int (*__cmp) (__const void *, __const void *)), + scandir64) __nonnull ((1, 2)); +# else +# define scandir scandir64 +# endif +# endif + +# if defined __USE_GNU && defined __USE_LARGEFILE64 +/* This function is like `scandir' but it uses the 64bit dirent structure. + Please note that the CMP function must now work with struct dirent64 **. */ +extern int scandir64 (__const char *__restrict __dir, + struct dirent64 ***__restrict __namelist, + int (*__selector) (__const struct dirent64 *), + int (*__cmp) (__const void *, __const void *)) + __nonnull ((1, 2)); +# endif + +/* Function to compare two `struct dirent's alphabetically. */ +# ifndef __USE_FILE_OFFSET64 +extern int alphasort (__const void *__e1, __const void *__e2) + __THROW __attribute_pure__ __nonnull ((1, 2)); +# else +# ifdef __REDIRECT +extern int __REDIRECT (alphasort, + (__const void *__e1, __const void *__e2), + alphasort64) __attribute_pure__ __nonnull ((1, 2)); +# else +# define alphasort alphasort64 +# endif +# endif + +# if defined __USE_GNU && defined __USE_LARGEFILE64 +extern int alphasort64 (__const void *__e1, __const void *__e2) + __THROW __attribute_pure__ __nonnull ((1, 2)); +# endif + +#endif /* Use BSD or misc. */ + +__END_DECLS + +#endif /* dirent.h */ diff --git a/conts/posix/libposix/include/posix/dlfcn.h b/conts/posix/libposix/include/posix/dlfcn.h new file mode 100644 index 0000000..2348e43 --- /dev/null +++ b/conts/posix/libposix/include/posix/dlfcn.h @@ -0,0 +1,201 @@ +/* User functions for run-time dynamic loading. + Copyright (C) 1995-1999,2000,2001,2003,2004,2006 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _DLFCN_H +#define _DLFCN_H 1 + +#include +#define __need_size_t +#include + +/* Collect various system dependent definitions and declarations. */ +#include + + +#ifdef __USE_GNU +/* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT + the run-time address of the symbol called NAME in the next shared + object is returned. The "next" relation is defined by the order + the shared objects were loaded. */ +# define RTLD_NEXT ((void *) -1l) + +/* If the first argument to `dlsym' or `dlvsym' is set to RTLD_DEFAULT + the run-time address of the symbol called NAME in the global scope + is returned. */ +# define RTLD_DEFAULT ((void *) 0) + + +# if 0 /* uClibc doesnt support this */ +/* Type for namespace indeces. */ +typedef long int Lmid_t; + +/* Special namespace ID values. */ +# define LM_ID_BASE 0 /* Initial namespace. */ +# define LM_ID_NEWLM -1 /* For dlmopen: request new namespace. */ +# endif +#endif + +__BEGIN_DECLS + +/* Open the shared object FILE and map it in; return a handle that can be + passed to `dlsym' to get symbol values from it. */ +extern void *dlopen (__const char *__file, int __mode) __THROW; + +/* Unmap and close a shared object opened by `dlopen'. + The handle cannot be used again after calling `dlclose'. */ +extern int dlclose (void *__handle) __THROW __nonnull ((1)); + +/* Find the run-time address in the shared object HANDLE refers to + of the symbol called NAME. */ +extern void *dlsym (void *__restrict __handle, + __const char *__restrict __name) __THROW __nonnull ((2)); + +#if 0 /*def __USE_GNU*/ +/* Like `dlopen', but request object to be allocated in a new namespace. */ +extern void *dlmopen (Lmid_t __nsid, __const char *__file, int __mode) __THROW; + +/* Find the run-time address in the shared object HANDLE refers to + of the symbol called NAME with VERSION. */ +extern void *dlvsym (void *__restrict __handle, + __const char *__restrict __name, + __const char *__restrict __version) + __THROW __nonnull ((2, 3)); +#endif + +/* When any of the above functions fails, call this function + to return a string describing the error. Each call resets + the error string so that a following call returns null. */ +extern char *dlerror (void) __THROW; + + +#ifdef __USE_GNU +/* Structure containing information about object searched using + `dladdr'. */ +typedef struct +{ + __const char *dli_fname; /* File name of defining object. */ + void *dli_fbase; /* Load address of that object. */ + __const char *dli_sname; /* Name of nearest symbol. */ + void *dli_saddr; /* Exact value of nearest symbol. */ +} Dl_info; + +/* Fill in *INFO with the following information about ADDRESS. + Returns 0 iff no shared object's segments contain that address. */ +extern int dladdr (__const void *__address, Dl_info *__info) + __THROW __nonnull ((2)); + +#if 0 /* not supported by uClibc */ +/* Same as `dladdr', but additionally sets *EXTRA_INFO according to FLAGS. */ +extern int dladdr1 (__const void *__address, Dl_info *__info, + void **__extra_info, int __flags) __THROW __nonnull ((2)); + +/* These are the possible values for the FLAGS argument to `dladdr1'. + This indicates what extra information is stored at *EXTRA_INFO. + It may also be zero, in which case the EXTRA_INFO argument is not used. */ +enum + { + /* Matching symbol table entry (const ElfNN_Sym *). */ + RTLD_DL_SYMENT = 1, + + /* The object containing the address (struct link_map *). */ + RTLD_DL_LINKMAP = 2 + }; + + +/* Get information about the shared object HANDLE refers to. + REQUEST is from among the values below, and determines the use of ARG. + + On success, returns zero. On failure, returns -1 and records an error + message to be fetched with `dlerror'. */ +extern int dlinfo (void *__restrict __handle, + int __request, void *__restrict __arg) + __THROW __nonnull ((1, 3)); + +/* These are the possible values for the REQUEST argument to `dlinfo'. */ +enum + { + /* Treat ARG as `lmid_t *'; store namespace ID for HANDLE there. */ + RTLD_DI_LMID = 1, + + /* Treat ARG as `struct link_map **'; + store the `struct link_map *' for HANDLE there. */ + RTLD_DI_LINKMAP = 2, + + RTLD_DI_CONFIGADDR = 3, /* Unsupported, defined by Solaris. */ + + /* Treat ARG as `Dl_serinfo *' (see below), and fill in to describe the + directories that will be searched for dependencies of this object. + RTLD_DI_SERINFOSIZE fills in just the `dls_cnt' and `dls_size' + entries to indicate the size of the buffer that must be passed to + RTLD_DI_SERINFO to fill in the full information. */ + RTLD_DI_SERINFO = 4, + RTLD_DI_SERINFOSIZE = 5, + + /* Treat ARG as `char *', and store there the directory name used to + expand $ORIGIN in this shared object's dependency file names. */ + RTLD_DI_ORIGIN = 6, + + RTLD_DI_PROFILENAME = 7, /* Unsupported, defined by Solaris. */ + RTLD_DI_PROFILEOUT = 8, /* Unsupported, defined by Solaris. */ + + /* Treat ARG as `size_t *', and store there the TLS module ID + of this object's PT_TLS segment, as used in TLS relocations; + store zero if this object does not define a PT_TLS segment. */ + RTLD_DI_TLS_MODID = 9, + + /* Treat ARG as `void **', and store there a pointer to the calling + thread's TLS block corresponding to this object's PT_TLS segment. + Store a null pointer if this object does not define a PT_TLS + segment, or if the calling thread has not allocated a block for it. */ + RTLD_DI_TLS_DATA = 10, + + RTLD_DI_MAX = 10, + }; + + +/* This is the type of elements in `Dl_serinfo', below. + The `dls_name' member points to space in the buffer passed to `dlinfo'. */ +typedef struct +{ + char *dls_name; /* Name of library search path directory. */ + unsigned int dls_flags; /* Indicates where this directory came from. */ +} Dl_serpath; + +/* This is the structure that must be passed (by reference) to `dlinfo' for + the RTLD_DI_SERINFO and RTLD_DI_SERINFOSIZE requests. */ +typedef struct +{ + size_t dls_size; /* Size in bytes of the whole buffer. */ + unsigned int dls_cnt; /* Number of elements in `dls_serpath'. */ + Dl_serpath dls_serpath[1]; /* Actually longer, dls_cnt elements. */ +} Dl_serinfo; + +#else + +/* Get information about the shared objects currently loaded */ +extern int dlinfo (void); + +#endif +#endif /* __USE_GNU */ + + +__END_DECLS + +#endif /* dlfcn.h */ diff --git a/conts/posix/libposix/include/posix/elf.h b/conts/posix/libposix/include/posix/elf.h new file mode 100644 index 0000000..ab90160 --- /dev/null +++ b/conts/posix/libposix/include/posix/elf.h @@ -0,0 +1,2979 @@ +/* This file defines standard ELF types, structures, and macros. + Copyright (C) 1995-2003, 2004, 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _ELF_H +#define _ELF_H 1 + +#include + +__BEGIN_DECLS + +/* Standard ELF types. */ + +#include + +/* Type for a 16-bit quantity. */ +typedef uint16_t Elf32_Half; +typedef uint16_t Elf64_Half; + +/* Types for signed and unsigned 32-bit quantities. */ +typedef uint32_t Elf32_Word; +typedef int32_t Elf32_Sword; +typedef uint32_t Elf64_Word; +typedef int32_t Elf64_Sword; + +/* Types for signed and unsigned 64-bit quantities. */ +typedef uint64_t Elf32_Xword; +typedef int64_t Elf32_Sxword; +typedef uint64_t Elf64_Xword; +typedef int64_t Elf64_Sxword; + +/* Type of addresses. */ +typedef uint32_t Elf32_Addr; +typedef uint64_t Elf64_Addr; + +/* Type of file offsets. */ +typedef uint32_t Elf32_Off; +typedef uint64_t Elf64_Off; + +/* Type for section indices, which are 16-bit quantities. */ +typedef uint16_t Elf32_Section; +typedef uint16_t Elf64_Section; + +/* Type for version symbol information. */ +typedef Elf32_Half Elf32_Versym; +typedef Elf64_Half Elf64_Versym; + + +/* The ELF file header. This appears at the start of every ELF file. */ + +#define EI_NIDENT (16) + +typedef struct +{ + unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ + Elf32_Half e_type; /* Object file type */ + Elf32_Half e_machine; /* Architecture */ + Elf32_Word e_version; /* Object file version */ + Elf32_Addr e_entry; /* Entry point virtual address */ + Elf32_Off e_phoff; /* Program header table file offset */ + Elf32_Off e_shoff; /* Section header table file offset */ + Elf32_Word e_flags; /* Processor-specific flags */ + Elf32_Half e_ehsize; /* ELF header size in bytes */ + Elf32_Half e_phentsize; /* Program header table entry size */ + Elf32_Half e_phnum; /* Program header table entry count */ + Elf32_Half e_shentsize; /* Section header table entry size */ + Elf32_Half e_shnum; /* Section header table entry count */ + Elf32_Half e_shstrndx; /* Section header string table index */ +} Elf32_Ehdr; + +typedef struct +{ + unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */ + Elf64_Half e_type; /* Object file type */ + Elf64_Half e_machine; /* Architecture */ + Elf64_Word e_version; /* Object file version */ + Elf64_Addr e_entry; /* Entry point virtual address */ + Elf64_Off e_phoff; /* Program header table file offset */ + Elf64_Off e_shoff; /* Section header table file offset */ + Elf64_Word e_flags; /* Processor-specific flags */ + Elf64_Half e_ehsize; /* ELF header size in bytes */ + Elf64_Half e_phentsize; /* Program header table entry size */ + Elf64_Half e_phnum; /* Program header table entry count */ + Elf64_Half e_shentsize; /* Section header table entry size */ + Elf64_Half e_shnum; /* Section header table entry count */ + Elf64_Half e_shstrndx; /* Section header string table index */ +} Elf64_Ehdr; + +/* Fields in the e_ident array. The EI_* macros are indices into the + array. The macros under each EI_* macro are the values the byte + may have. */ + +#define EI_MAG0 0 /* File identification byte 0 index */ +#define ELFMAG0 0x7f /* Magic number byte 0 */ + +#define EI_MAG1 1 /* File identification byte 1 index */ +#define ELFMAG1 'E' /* Magic number byte 1 */ + +#define EI_MAG2 2 /* File identification byte 2 index */ +#define ELFMAG2 'L' /* Magic number byte 2 */ + +#define EI_MAG3 3 /* File identification byte 3 index */ +#define ELFMAG3 'F' /* Magic number byte 3 */ + +/* Conglomeration of the identification bytes, for easy testing as a word. */ +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +#define EI_CLASS 4 /* File class byte index */ +#define ELFCLASSNONE 0 /* Invalid class */ +#define ELFCLASS32 1 /* 32-bit objects */ +#define ELFCLASS64 2 /* 64-bit objects */ +#define ELFCLASSNUM 3 + +#define EI_DATA 5 /* Data encoding byte index */ +#define ELFDATANONE 0 /* Invalid data encoding */ +#define ELFDATA2LSB 1 /* 2's complement, little endian */ +#define ELFDATA2MSB 2 /* 2's complement, big endian */ +#define ELFDATANUM 3 + +#define EI_VERSION 6 /* File version byte index */ + /* Value must be EV_CURRENT */ + +#define EI_OSABI 7 /* OS ABI identification */ +#define ELFOSABI_NONE 0 /* UNIX System V ABI */ +#define ELFOSABI_SYSV 0 /* Alias. */ +#define ELFOSABI_HPUX 1 /* HP-UX */ +#define ELFOSABI_NETBSD 2 /* NetBSD. */ +#define ELFOSABI_LINUX 3 /* Linux. */ +#define ELFOSABI_HURD 4 /* GNU/Hurd */ +#define ELFOSABI_SOLARIS 6 /* Sun Solaris. */ +#define ELFOSABI_AIX 7 /* IBM AIX. */ +#define ELFOSABI_IRIX 8 /* SGI Irix. */ +#define ELFOSABI_FREEBSD 9 /* FreeBSD. */ +#define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX. */ +#define ELFOSABI_MODESTO 11 /* Novell Modesto. */ +#define ELFOSABI_OPENBSD 12 /* OpenBSD. */ +#define ELFOSABI_OPENVMS 13 /* OpenVMS */ +#define ELFOSABI_NSK 14 /* Hewlett-Packard Non-Stop Kernel */ +#define ELFOSABI_AROS 15 /* Amiga Research OS */ +#define ELFOSABI_ARM 97 /* ARM */ +#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ + +#define EI_ABIVERSION 8 /* ABI version */ + +#define EI_PAD 9 /* Byte index of padding bytes */ + +/* Legal values for e_type (object file type). */ + +#define ET_NONE 0 /* No file type */ +#define ET_REL 1 /* Relocatable file */ +#define ET_EXEC 2 /* Executable file */ +#define ET_DYN 3 /* Shared object file */ +#define ET_CORE 4 /* Core file */ +#define ET_NUM 5 /* Number of defined types */ +#define ET_LOOS 0xfe00 /* OS-specific range start */ +#define ET_HIOS 0xfeff /* OS-specific range end */ +#define ET_LOPROC 0xff00 /* Processor-specific range start */ +#define ET_HIPROC 0xffff /* Processor-specific range end */ + +/* Legal values for e_machine (architecture). */ + +#define EM_NONE 0 /* No machine */ +#define EM_M32 1 /* AT&T WE 32100 */ +#define EM_SPARC 2 /* SUN SPARC */ +#define EM_386 3 /* Intel 80386 */ +#define EM_68K 4 /* Motorola m68k family */ +#define EM_88K 5 /* Motorola m88k family */ +#define EM_486 6 /* Intel 80486 *//* Reserved for future use */ +#define EM_860 7 /* Intel 80860 */ +#define EM_MIPS 8 /* MIPS R3000 big-endian */ +#define EM_S370 9 /* IBM System/370 */ +#define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ + +#define EM_PARISC 15 /* HPPA */ +#define EM_VPP500 17 /* Fujitsu VPP500 */ +#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ +#define EM_960 19 /* Intel 80960 */ +#define EM_PPC 20 /* PowerPC */ +#define EM_PPC64 21 /* PowerPC 64-bit */ +#define EM_S390 22 /* IBM S390 */ + +#define EM_V800 36 /* NEC V800 series */ +#define EM_FR20 37 /* Fujitsu FR20 */ +#define EM_RH32 38 /* TRW RH-32 */ +#define EM_MCORE 39 /* Motorola M*Core */ /* May also be taken by Fujitsu MMA */ +#define EM_RCE 39 /* Old name for MCore */ +#define EM_ARM 40 /* ARM */ +#define EM_FAKE_ALPHA 41 /* Digital Alpha */ +#define EM_SH 42 /* Renesas SH */ +#define EM_SPARCV9 43 /* SPARC v9 64-bit */ +#define EM_TRICORE 44 /* Siemens Tricore */ +#define EM_ARC 45 /* Argonaut RISC Core */ +#define EM_H8_300 46 /* Renesas H8/300 */ +#define EM_H8_300H 47 /* Renesas H8/300H */ +#define EM_H8S 48 /* Renesas H8S */ +#define EM_H8_500 49 /* Renesas H8/500 */ +#define EM_IA_64 50 /* Intel Merced */ +#define EM_MIPS_X 51 /* Stanford MIPS-X */ +#define EM_COLDFIRE 52 /* Motorola Coldfire */ +#define EM_68HC12 53 /* Motorola M68HC12 */ +#define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/ +#define EM_PCP 55 /* Siemens PCP */ +#define EM_NCPU 56 /* Sony nCPU embeeded RISC */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor */ +#define EM_STARCORE 58 /* Motorola Start*Core processor */ +#define EM_ME16 59 /* Toyota ME16 processor */ +#define EM_ST100 60 /* STMicroelectronic ST100 processor */ +#define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/ +#define EM_X86_64 62 /* AMD x86-64 architecture */ +#define EM_PDSP 63 /* Sony DSP Processor */ + +#define EM_FX66 66 /* Siemens FX66 microcontroller */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ +#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ +#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ +#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ +#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ +#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ +#define EM_SVX 73 /* Silicon Graphics SVx */ +#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */ +#define EM_VAX 75 /* Digital VAX */ +#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */ +#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ +#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ +#define EM_HUANY 81 /* Harvard University machine-independent object files */ +#define EM_PRISM 82 /* SiTera Prism */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ +#define EM_FR30 84 /* Fujitsu FR30 */ +#define EM_D10V 85 /* Mitsubishi D10V */ +#define EM_D30V 86 /* Mitsubishi D30V */ +#define EM_V850 87 /* NEC v850 */ +#define EM_M32R 88 /* Renesas M32R */ +#define EM_MN10300 89 /* Matsushita MN10300 */ +#define EM_MN10200 90 /* Matsushita MN10200 */ +#define EM_PJ 91 /* picoJava */ +#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ +#define EM_IP2K 101 /* Ubicom IP2022 micro controller */ +#define EM_CR 103 /* National Semiconductor CompactRISC */ +#define EM_MSP430 105 /* TI msp430 micro controller */ +#define EM_BLACKFIN 106 /* Analog Devices Blackfin */ +#define EM_ALTERA_NIOS2 113 /* Altera Nios II soft-core processor */ +#define EM_CRX 114 /* National Semiconductor CRX */ +#define EM_NUM 95 + +/* If it is necessary to assign new unofficial EM_* values, please pick large + random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision + with official or non-GNU unofficial values. + + NOTE: Do not just increment the most recent number by one. + Somebody else somewhere will do exactly the same thing, and you + will have a collision. Instead, pick a random number. + + Normally, each entity or maintainer responsible for a machine with an + unofficial e_machine number should eventually ask registry@caldera.com for + an officially blessed number to be added to the list above. */ + +/* picoJava */ +#define EM_PJ_OLD 99 + +/* Cygnus PowerPC ELF backend. Written in the absence of an ABI. */ +#define EM_CYGNUS_POWERPC 0x9025 + +/* Old version of Sparc v9, from before the ABI; this should be + removed shortly. */ +#define EM_OLD_SPARCV9 11 + +/* Old version of PowerPC, this should be removed shortly. */ +#define EM_PPC_OLD 17 + +/* (Deprecated) Temporary number for the OpenRISC processor. */ +#define EM_OR32 0x8472 + +/* Renesas M32C and M16C. */ +#define EM_M32C 0xFEB0 + +/* Cygnus M32R ELF backend. Written in the absence of an ABI. */ +#define EM_CYGNUS_M32R 0x9041 + +/* old S/390 backend magic number. Written in the absence of an ABI. */ +#define EM_S390_OLD 0xa390 + +/* D10V backend magic number. Written in the absence of an ABI. */ +#define EM_CYGNUS_D10V 0x7650 + +/* D30V backend magic number. Written in the absence of an ABI. */ +#define EM_CYGNUS_D30V 0x7676 + +/* V850 backend magic number. Written in the absense of an ABI. */ +#define EM_CYGNUS_V850 0x9080 + +/* mn10200 and mn10300 backend magic numbers. + Written in the absense of an ABI. */ +#define EM_CYGNUS_MN10200 0xdead +#define EM_CYGNUS_MN10300 0xbeef + +/* FR30 magic number - no EABI available. */ +#define EM_CYGNUS_FR30 0x3330 + +/* AVR magic number + Written in the absense of an ABI. */ +#define EM_AVR_OLD 0x1057 + +/* OpenRISC magic number + Written in the absense of an ABI. */ +#define EM_OPENRISC_OLD 0x3426 + +/* DLX magic number + Written in the absense of an ABI. */ +#define EM_DLX 0x5aa5 + +#define EM_XSTORMY16 0xad45 + +/* FRV magic number - no EABI available??. */ +#define EM_CYGNUS_FRV 0x5441 + +/* Ubicom IP2xxx; no ABI */ +#define EM_IP2K_OLD 0x8217 + +#define EM_MT 0x2530 /* Morpho MT; no ABI */ + +/* MSP430 magic number + Written in the absense everything. */ +#define EM_MSP430_OLD 0x1059 + +/* Vitesse IQ2000. */ +#define EM_IQ2000 0xFEBA + +/* Old, unofficial value for Xtensa. */ +#define EM_XTENSA_OLD 0xabc7 + +/* Alpha backend magic number. Written in the absence of an ABI. */ +#define EM_ALPHA 0x9026 + +/* NIOS magic number - no EABI available. */ +#define EM_NIOS32 0xFEBB + +#define EM_AVR32 0x18ad + +/* V850 backend magic number. Written in the absense of an ABI. */ +#define EM_CYGNUS_V850 0x9080 + +/* Legal values for e_version (version). */ + +#define EV_NONE 0 /* Invalid ELF version */ +#define EV_CURRENT 1 /* Current version */ +#define EV_NUM 2 + +/* Section header. */ + +typedef struct +{ + Elf32_Word sh_name; /* Section name (string tbl index) */ + Elf32_Word sh_type; /* Section type */ + Elf32_Word sh_flags; /* Section flags */ + Elf32_Addr sh_addr; /* Section virtual addr at execution */ + Elf32_Off sh_offset; /* Section file offset */ + Elf32_Word sh_size; /* Section size in bytes */ + Elf32_Word sh_link; /* Link to another section */ + Elf32_Word sh_info; /* Additional section information */ + Elf32_Word sh_addralign; /* Section alignment */ + Elf32_Word sh_entsize; /* Entry size if section holds table */ +} Elf32_Shdr; + +typedef struct +{ + Elf64_Word sh_name; /* Section name (string tbl index) */ + Elf64_Word sh_type; /* Section type */ + Elf64_Xword sh_flags; /* Section flags */ + Elf64_Addr sh_addr; /* Section virtual addr at execution */ + Elf64_Off sh_offset; /* Section file offset */ + Elf64_Xword sh_size; /* Section size in bytes */ + Elf64_Word sh_link; /* Link to another section */ + Elf64_Word sh_info; /* Additional section information */ + Elf64_Xword sh_addralign; /* Section alignment */ + Elf64_Xword sh_entsize; /* Entry size if section holds table */ +} Elf64_Shdr; + +/* Special section indices. */ + +#define SHN_UNDEF 0 /* Undefined section */ +#define SHN_LORESERVE 0xff00 /* Start of reserved indices */ +#define SHN_LOPROC 0xff00 /* Start of processor-specific */ +#define SHN_BEFORE 0xff00 /* Order section before all others + (Solaris). */ +#define SHN_AFTER 0xff01 /* Order section after all others + (Solaris). */ +#define SHN_HIPROC 0xff1f /* End of processor-specific */ +#define SHN_LOOS 0xff20 /* Start of OS-specific */ +#define SHN_HIOS 0xff3f /* End of OS-specific */ +#define SHN_ABS 0xfff1 /* Associated symbol is absolute */ +#define SHN_COMMON 0xfff2 /* Associated symbol is common */ +#define SHN_XINDEX 0xffff /* Index is in extra table. */ +#define SHN_HIRESERVE 0xffff /* End of reserved indices */ + +/* Legal values for sh_type (section type). */ + +#define SHT_NULL 0 /* Section header table entry unused */ +#define SHT_PROGBITS 1 /* Program data */ +#define SHT_SYMTAB 2 /* Symbol table */ +#define SHT_STRTAB 3 /* String table */ +#define SHT_RELA 4 /* Relocation entries with addends */ +#define SHT_HASH 5 /* Symbol hash table */ +#define SHT_DYNAMIC 6 /* Dynamic linking information */ +#define SHT_NOTE 7 /* Notes */ +#define SHT_NOBITS 8 /* Program space with no data (bss) */ +#define SHT_REL 9 /* Relocation entries, no addends */ +#define SHT_SHLIB 10 /* Reserved */ +#define SHT_DYNSYM 11 /* Dynamic linker symbol table */ +#define SHT_INIT_ARRAY 14 /* Array of constructors */ +#define SHT_FINI_ARRAY 15 /* Array of destructors */ +#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */ +#define SHT_GROUP 17 /* Section group */ +#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */ +#define SHT_NUM 19 /* Number of defined types. */ +#define SHT_LOOS 0x60000000 /* Start OS-specific */ +#define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */ +#define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */ +#define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */ +#define SHT_SUNW_move 0x6ffffffa +#define SHT_SUNW_COMDAT 0x6ffffffb +#define SHT_SUNW_syminfo 0x6ffffffc +#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ +#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ +#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ +#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */ +#define SHT_HIOS 0x6fffffff /* End OS-specific type */ +#define SHT_LOPROC 0x70000000 /* Start of processor-specific */ +#define SHT_HIPROC 0x7fffffff /* End of processor-specific */ +#define SHT_LOUSER 0x80000000 /* Start of application-specific */ +#define SHT_HIUSER 0x8fffffff /* End of application-specific */ + +/* Legal values for sh_flags (section flags). */ + +#define SHF_WRITE (1 << 0) /* Writable */ +#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ +#define SHF_EXECINSTR (1 << 2) /* Executable */ +#define SHF_MERGE (1 << 4) /* Might be merged */ +#define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */ +#define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */ +#define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */ +#define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling + required */ +#define SHF_GROUP (1 << 9) /* Section is member of a group. */ +#define SHF_TLS (1 << 10) /* Section hold thread-local data. */ +#define SHF_MASKOS 0x0ff00000 /* OS-specific. */ +#define SHF_MASKPROC 0xf0000000 /* Processor-specific */ +#define SHF_ORDERED (1 << 30) /* Special ordering requirement + (Solaris). */ +#define SHF_EXCLUDE (1 << 31) /* Section is excluded unless + referenced or allocated (Solaris).*/ + +/* Section group handling. */ +#define GRP_COMDAT 0x1 /* Mark group as COMDAT. */ + +/* Symbol table entry. */ + +typedef struct +{ + Elf32_Word st_name; /* Symbol name (string tbl index) */ + Elf32_Addr st_value; /* Symbol value */ + Elf32_Word st_size; /* Symbol size */ + unsigned char st_info; /* Symbol type and binding */ + unsigned char st_other; /* Symbol visibility */ + Elf32_Section st_shndx; /* Section index */ +} Elf32_Sym; + +typedef struct +{ + Elf64_Word st_name; /* Symbol name (string tbl index) */ + unsigned char st_info; /* Symbol type and binding */ + unsigned char st_other; /* Symbol visibility */ + Elf64_Section st_shndx; /* Section index */ + Elf64_Addr st_value; /* Symbol value */ + Elf64_Xword st_size; /* Symbol size */ +} Elf64_Sym; + +/* The syminfo section if available contains additional information about + every dynamic symbol. */ + +typedef struct +{ + Elf32_Half si_boundto; /* Direct bindings, symbol bound to */ + Elf32_Half si_flags; /* Per symbol flags */ +} Elf32_Syminfo; + +typedef struct +{ + Elf64_Half si_boundto; /* Direct bindings, symbol bound to */ + Elf64_Half si_flags; /* Per symbol flags */ +} Elf64_Syminfo; + +/* Possible values for si_boundto. */ +#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */ +#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */ +#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */ + +/* Possible bitmasks for si_flags. */ +#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */ +#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */ +#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */ +#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy + loaded */ +/* Syminfo version values. */ +#define SYMINFO_NONE 0 +#define SYMINFO_CURRENT 1 +#define SYMINFO_NUM 2 + + +/* How to extract and insert information held in the st_info field. */ + +#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4) +#define ELF32_ST_TYPE(val) ((val) & 0xf) +#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf)) + +/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */ +#define ELF64_ST_BIND(val) ELF32_ST_BIND (val) +#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val) +#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type)) + +/* Legal values for ST_BIND subfield of st_info (symbol binding). */ + +#define STB_LOCAL 0 /* Local symbol */ +#define STB_GLOBAL 1 /* Global symbol */ +#define STB_WEAK 2 /* Weak symbol */ +#define STB_NUM 3 /* Number of defined types. */ +#define STB_LOOS 10 /* Start of OS-specific */ +#define STB_HIOS 12 /* End of OS-specific */ +#define STB_LOPROC 13 /* Start of processor-specific */ +#define STB_HIPROC 15 /* End of processor-specific */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_NOTYPE 0 /* Symbol type is unspecified */ +#define STT_OBJECT 1 /* Symbol is a data object */ +#define STT_FUNC 2 /* Symbol is a code object */ +#define STT_SECTION 3 /* Symbol associated with a section */ +#define STT_FILE 4 /* Symbol's name is file name */ +#define STT_COMMON 5 /* Symbol is a common data object */ +#define STT_TLS 6 /* Symbol is thread-local data object*/ +#define STT_NUM 7 /* Number of defined types. */ +#define STT_LOOS 10 /* Start of OS-specific */ +#define STT_HIOS 12 /* End of OS-specific */ +#define STT_LOPROC 13 /* Start of processor-specific */ +#define STT_HIPROC 15 /* End of processor-specific */ + + +/* Symbol table indices are found in the hash buckets and chain table + of a symbol hash table section. This special index value indicates + the end of a chain, meaning no further symbols are found in that bucket. */ + +#define STN_UNDEF 0 /* End of a chain. */ + + +/* How to extract and insert information held in the st_other field. */ + +#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) + +/* For ELF64 the definitions are the same. */ +#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) + +/* Symbol visibility specification encoded in the st_other field. */ +#define STV_DEFAULT 0 /* Default symbol visibility rules */ +#define STV_INTERNAL 1 /* Processor specific hidden class */ +#define STV_HIDDEN 2 /* Sym unavailable in other modules */ +#define STV_PROTECTED 3 /* Not preemptible, not exported */ + + +/* Relocation table entry without addend (in section of type SHT_REL). */ + +typedef struct +{ + Elf32_Addr r_offset; /* Address */ + Elf32_Word r_info; /* Relocation type and symbol index */ +} Elf32_Rel; + +/* I have seen two different definitions of the Elf64_Rel and + Elf64_Rela structures, so we'll leave them out until Novell (or + whoever) gets their act together. */ +/* The following, at least, is used on Sparc v9, MIPS, and Alpha. */ + +typedef struct +{ + Elf64_Addr r_offset; /* Address */ + Elf64_Xword r_info; /* Relocation type and symbol index */ +} Elf64_Rel; + +/* Relocation table entry with addend (in section of type SHT_RELA). */ + +typedef struct +{ + Elf32_Addr r_offset; /* Address */ + Elf32_Word r_info; /* Relocation type and symbol index */ + Elf32_Sword r_addend; /* Addend */ +} Elf32_Rela; + +typedef struct +{ + Elf64_Addr r_offset; /* Address */ + Elf64_Xword r_info; /* Relocation type and symbol index */ + Elf64_Sxword r_addend; /* Addend */ +} Elf64_Rela; + +/* How to extract and insert information held in the r_info field. */ + +#define ELF32_R_SYM(val) ((val) >> 8) +#define ELF32_R_TYPE(val) ((val) & 0xff) +#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) + +#define ELF64_R_SYM(i) ((i) >> 32) +#define ELF64_R_TYPE(i) ((i) & 0xffffffff) +#define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) + +/* Program segment header. */ + +typedef struct +{ + Elf32_Word p_type; /* Segment type */ + Elf32_Off p_offset; /* Segment file offset */ + Elf32_Addr p_vaddr; /* Segment virtual address */ + Elf32_Addr p_paddr; /* Segment physical address */ + Elf32_Word p_filesz; /* Segment size in file */ + Elf32_Word p_memsz; /* Segment size in memory */ + Elf32_Word p_flags; /* Segment flags */ + Elf32_Word p_align; /* Segment alignment */ +} Elf32_Phdr; + +typedef struct +{ + Elf64_Word p_type; /* Segment type */ + Elf64_Word p_flags; /* Segment flags */ + Elf64_Off p_offset; /* Segment file offset */ + Elf64_Addr p_vaddr; /* Segment virtual address */ + Elf64_Addr p_paddr; /* Segment physical address */ + Elf64_Xword p_filesz; /* Segment size in file */ + Elf64_Xword p_memsz; /* Segment size in memory */ + Elf64_Xword p_align; /* Segment alignment */ +} Elf64_Phdr; + +/* Legal values for p_type (segment type). */ + +#define PT_NULL 0 /* Program header table entry unused */ +#define PT_LOAD 1 /* Loadable program segment */ +#define PT_DYNAMIC 2 /* Dynamic linking information */ +#define PT_INTERP 3 /* Program interpreter */ +#define PT_NOTE 4 /* Auxiliary information */ +#define PT_SHLIB 5 /* Reserved */ +#define PT_PHDR 6 /* Entry for header table itself */ +#define PT_TLS 7 /* Thread-local storage segment */ +#define PT_NUM 8 /* Number of defined types */ +#define PT_LOOS 0x60000000 /* Start of OS-specific */ +#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */ +#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */ +#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */ +#define PT_PAX_FLAGS 0x65041580 /* Indicates PaX flag markings */ +#define PT_LOSUNW 0x6ffffffa +#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */ +#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */ +#define PT_HISUNW 0x6fffffff +#define PT_HIOS 0x6fffffff /* End of OS-specific */ +#define PT_LOPROC 0x70000000 /* Start of processor-specific */ +#define PT_HIPROC 0x7fffffff /* End of processor-specific */ + +/* Legal values for p_flags (segment flags). */ + +#define PF_X (1 << 0) /* Segment is executable */ +#define PF_W (1 << 1) /* Segment is writable */ +#define PF_R (1 << 2) /* Segment is readable */ +#define PF_PAGEEXEC (1 << 4) /* Enable PAGEEXEC */ +#define PF_NOPAGEEXEC (1 << 5) /* Disable PAGEEXEC */ +#define PF_SEGMEXEC (1 << 6) /* Enable SEGMEXEC */ +#define PF_NOSEGMEXEC (1 << 7) /* Disable SEGMEXEC */ +#define PF_MPROTECT (1 << 8) /* Enable MPROTECT */ +#define PF_NOMPROTECT (1 << 9) /* Disable MPROTECT */ +#define PF_RANDEXEC (1 << 10) /* Enable RANDEXEC */ +#define PF_NORANDEXEC (1 << 11) /* Disable RANDEXEC */ +#define PF_EMUTRAMP (1 << 12) /* Enable EMUTRAMP */ +#define PF_NOEMUTRAMP (1 << 13) /* Disable EMUTRAMP */ +#define PF_RANDMMAP (1 << 14) /* Enable RANDMMAP */ +#define PF_NORANDMMAP (1 << 15) /* Disable RANDMMAP */ +#define PF_MASKOS 0x0ff00000 /* OS-specific */ +#define PF_MASKPROC 0xf0000000 /* Processor-specific */ + +/* Legal values for note segment descriptor types for core files. */ + +#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ +#define NT_FPREGSET 2 /* Contains copy of fpregset struct */ +#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */ +#define NT_PRXREG 4 /* Contains copy of prxregset struct */ +#define NT_TASKSTRUCT 4 /* Contains copy of task structure */ +#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */ +#define NT_AUXV 6 /* Contains copy of auxv array */ +#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */ +#define NT_ASRS 8 /* Contains copy of asrset struct */ +#define NT_PSTATUS 10 /* Contains copy of pstatus struct */ +#define NT_PSINFO 13 /* Contains copy of psinfo struct */ +#define NT_PRCRED 14 /* Contains copy of prcred struct */ +#define NT_UTSNAME 15 /* Contains copy of utsname struct */ +#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */ +#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */ +#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct*/ + +/* Legal values for the note segment descriptor types for object files. */ + +#define NT_VERSION 1 /* Contains a version string. */ + + +/* Dynamic section entry. */ + +typedef struct +{ + Elf32_Sword d_tag; /* Dynamic entry type */ + union + { + Elf32_Word d_val; /* Integer value */ + Elf32_Addr d_ptr; /* Address value */ + } d_un; +} Elf32_Dyn; + +typedef struct +{ + Elf64_Sxword d_tag; /* Dynamic entry type */ + union + { + Elf64_Xword d_val; /* Integer value */ + Elf64_Addr d_ptr; /* Address value */ + } d_un; +} Elf64_Dyn; + +/* Legal values for d_tag (dynamic entry type). */ + +#define DT_NULL 0 /* Marks end of dynamic section */ +#define DT_NEEDED 1 /* Name of needed library */ +#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */ +#define DT_PLTGOT 3 /* Processor defined value */ +#define DT_HASH 4 /* Address of symbol hash table */ +#define DT_STRTAB 5 /* Address of string table */ +#define DT_SYMTAB 6 /* Address of symbol table */ +#define DT_RELA 7 /* Address of Rela relocs */ +#define DT_RELASZ 8 /* Total size of Rela relocs */ +#define DT_RELAENT 9 /* Size of one Rela reloc */ +#define DT_STRSZ 10 /* Size of string table */ +#define DT_SYMENT 11 /* Size of one symbol table entry */ +#define DT_INIT 12 /* Address of init function */ +#define DT_FINI 13 /* Address of termination function */ +#define DT_SONAME 14 /* Name of shared object */ +#define DT_RPATH 15 /* Library search path (deprecated) */ +#define DT_SYMBOLIC 16 /* Start symbol search here */ +#define DT_REL 17 /* Address of Rel relocs */ +#define DT_RELSZ 18 /* Total size of Rel relocs */ +#define DT_RELENT 19 /* Size of one Rel reloc */ +#define DT_PLTREL 20 /* Type of reloc in PLT */ +#define DT_DEBUG 21 /* For debugging; unspecified */ +#define DT_TEXTREL 22 /* Reloc might modify .text */ +#define DT_JMPREL 23 /* Address of PLT relocs */ +#define DT_BIND_NOW 24 /* Process relocations of object */ +#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */ +#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */ +#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */ +#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */ +#define DT_RUNPATH 29 /* Library search path */ +#define DT_FLAGS 30 /* Flags for the object being loaded */ +#define DT_ENCODING 32 /* Start of encoded range */ +#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ +#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ +#define DT_NUM 34 /* Number used */ +#define DT_LOOS 0x6000000d /* Start of OS-specific */ +#define DT_HIOS 0x6ffff000 /* End of OS-specific */ +#define DT_LOPROC 0x70000000 /* Start of processor-specific */ +#define DT_HIPROC 0x7fffffff /* End of processor-specific */ +#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */ + +/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the + Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's + approach. */ +#define DT_VALRNGLO 0x6ffffd00 +#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */ +#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */ +#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */ +#define DT_CHECKSUM 0x6ffffdf8 +#define DT_PLTPADSZ 0x6ffffdf9 +#define DT_MOVEENT 0x6ffffdfa +#define DT_MOVESZ 0x6ffffdfb +#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */ +#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting + the following DT_* entry. */ +#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */ +#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */ +#define DT_VALRNGHI 0x6ffffdff +#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */ +#define DT_VALNUM 12 + +/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the + Dyn.d_un.d_ptr field of the Elf*_Dyn structure. + + If any adjustment is made to the ELF object after it has been + built these entries will need to be adjusted. */ +#define DT_ADDRRNGLO 0x6ffffe00 +#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */ +#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */ +#define DT_CONFIG 0x6ffffefa /* Configuration information. */ +#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */ +#define DT_AUDIT 0x6ffffefc /* Object auditing. */ +#define DT_PLTPAD 0x6ffffefd /* PLT padding. */ +#define DT_MOVETAB 0x6ffffefe /* Move table. */ +#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */ +#define DT_ADDRRNGHI 0x6ffffeff +#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */ +#define DT_ADDRNUM 10 + +/* The versioning entry types. The next are defined as part of the + GNU extension. */ +#define DT_VERSYM 0x6ffffff0 + +#define DT_RELACOUNT 0x6ffffff9 +#define DT_RELCOUNT 0x6ffffffa + +/* These were chosen by Sun. */ +#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */ +#define DT_VERDEF 0x6ffffffc /* Address of version definition + table */ +#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */ +#define DT_VERNEED 0x6ffffffe /* Address of table with needed + versions */ +#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */ +#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ +#define DT_VERSIONTAGNUM 16 + +/* Sun added these machine-independent extensions in the "processor-specific" + range. Be compatible. */ +#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */ +#define DT_FILTER 0x7fffffff /* Shared object to get values from */ +#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) +#define DT_EXTRANUM 3 + +/* Values of `d_un.d_val' in the DT_FLAGS entry. */ +#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */ +#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ +#define DF_TEXTREL 0x00000004 /* Object contains text relocations */ +#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ +#define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */ + +/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 + entry in the dynamic section. */ +#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ +#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ +#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ +#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ +#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/ +#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/ +#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ +#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ +#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ +#define DF_1_TRANS 0x00000200 +#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ +#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ +#define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */ +#define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/ +#define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */ +#define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */ +#define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */ + +/* Flags for the feature selection in DT_FEATURE_1. */ +#define DTF_1_PARINIT 0x00000001 +#define DTF_1_CONFEXP 0x00000002 + +/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */ +#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ +#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not + generally available. */ + +/* Version definition sections. */ + +typedef struct +{ + Elf32_Half vd_version; /* Version revision */ + Elf32_Half vd_flags; /* Version information */ + Elf32_Half vd_ndx; /* Version Index */ + Elf32_Half vd_cnt; /* Number of associated aux entries */ + Elf32_Word vd_hash; /* Version name hash value */ + Elf32_Word vd_aux; /* Offset in bytes to verdaux array */ + Elf32_Word vd_next; /* Offset in bytes to next verdef + entry */ +} Elf32_Verdef; + +typedef struct +{ + Elf64_Half vd_version; /* Version revision */ + Elf64_Half vd_flags; /* Version information */ + Elf64_Half vd_ndx; /* Version Index */ + Elf64_Half vd_cnt; /* Number of associated aux entries */ + Elf64_Word vd_hash; /* Version name hash value */ + Elf64_Word vd_aux; /* Offset in bytes to verdaux array */ + Elf64_Word vd_next; /* Offset in bytes to next verdef + entry */ +} Elf64_Verdef; + + +/* Legal values for vd_version (version revision). */ +#define VER_DEF_NONE 0 /* No version */ +#define VER_DEF_CURRENT 1 /* Current version */ +#define VER_DEF_NUM 2 /* Given version number */ + +/* Legal values for vd_flags (version information flags). */ +#define VER_FLG_BASE 0x1 /* Version definition of file itself */ +#define VER_FLG_WEAK 0x2 /* Weak version identifier */ + +/* Versym symbol index values. */ +#define VER_NDX_LOCAL 0 /* Symbol is local. */ +#define VER_NDX_GLOBAL 1 /* Symbol is global. */ +#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */ +#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */ + +/* Auxialiary version information. */ + +typedef struct +{ + Elf32_Word vda_name; /* Version or dependency names */ + Elf32_Word vda_next; /* Offset in bytes to next verdaux + entry */ +} Elf32_Verdaux; + +typedef struct +{ + Elf64_Word vda_name; /* Version or dependency names */ + Elf64_Word vda_next; /* Offset in bytes to next verdaux + entry */ +} Elf64_Verdaux; + + +/* Version dependency section. */ + +typedef struct +{ + Elf32_Half vn_version; /* Version of structure */ + Elf32_Half vn_cnt; /* Number of associated aux entries */ + Elf32_Word vn_file; /* Offset of filename for this + dependency */ + Elf32_Word vn_aux; /* Offset in bytes to vernaux array */ + Elf32_Word vn_next; /* Offset in bytes to next verneed + entry */ +} Elf32_Verneed; + +typedef struct +{ + Elf64_Half vn_version; /* Version of structure */ + Elf64_Half vn_cnt; /* Number of associated aux entries */ + Elf64_Word vn_file; /* Offset of filename for this + dependency */ + Elf64_Word vn_aux; /* Offset in bytes to vernaux array */ + Elf64_Word vn_next; /* Offset in bytes to next verneed + entry */ +} Elf64_Verneed; + + +/* Legal values for vn_version (version revision). */ +#define VER_NEED_NONE 0 /* No version */ +#define VER_NEED_CURRENT 1 /* Current version */ +#define VER_NEED_NUM 2 /* Given version number */ + +/* Auxiliary needed version information. */ + +typedef struct +{ + Elf32_Word vna_hash; /* Hash value of dependency name */ + Elf32_Half vna_flags; /* Dependency specific information */ + Elf32_Half vna_other; /* Unused */ + Elf32_Word vna_name; /* Dependency name string offset */ + Elf32_Word vna_next; /* Offset in bytes to next vernaux + entry */ +} Elf32_Vernaux; + +typedef struct +{ + Elf64_Word vna_hash; /* Hash value of dependency name */ + Elf64_Half vna_flags; /* Dependency specific information */ + Elf64_Half vna_other; /* Unused */ + Elf64_Word vna_name; /* Dependency name string offset */ + Elf64_Word vna_next; /* Offset in bytes to next vernaux + entry */ +} Elf64_Vernaux; + + +/* Legal values for vna_flags. */ +#define VER_FLG_WEAK 0x2 /* Weak version identifier */ + + +/* Auxiliary vector. */ + +/* This vector is normally only used by the program interpreter. The + usual definition in an ABI supplement uses the name auxv_t. The + vector is not usually defined in a standard file, but it + can't hurt. We rename it to avoid conflicts. The sizes of these + types are an arrangement between the exec server and the program + interpreter, so we don't fully specify them here. */ + +typedef struct +{ + uint32_t a_type; /* Entry type */ + union + { + uint32_t a_val; /* Integer value */ + /* We use to have pointer elements added here. We cannot do that, + though, since it does not work when using 32-bit definitions + on 64-bit platforms and vice versa. */ + } a_un; +} Elf32_auxv_t; + +typedef struct +{ + uint64_t a_type; /* Entry type */ + union + { + uint64_t a_val; /* Integer value */ + /* We use to have pointer elements added here. We cannot do that, + though, since it does not work when using 32-bit definitions + on 64-bit platforms and vice versa. */ + } a_un; +} Elf64_auxv_t; + +/* Legal values for a_type (entry type). */ + +#define AT_NULL 0 /* End of vector */ +#define AT_IGNORE 1 /* Entry should be ignored */ +#define AT_EXECFD 2 /* File descriptor of program */ +#define AT_PHDR 3 /* Program headers for program */ +#define AT_PHENT 4 /* Size of program header entry */ +#define AT_PHNUM 5 /* Number of program headers */ +#define AT_PAGESZ 6 /* System page size */ +#define AT_BASE 7 /* Base address of interpreter */ +#define AT_FLAGS 8 /* Flags */ +#define AT_ENTRY 9 /* Entry point of program */ +#define AT_NOTELF 10 /* Program is not ELF */ +#define AT_UID 11 /* Real uid */ +#define AT_EUID 12 /* Effective uid */ +#define AT_GID 13 /* Real gid */ +#define AT_EGID 14 /* Effective gid */ +#define AT_CLKTCK 17 /* Frequency of times() */ + +/* Some more special a_type values describing the hardware. */ +#define AT_PLATFORM 15 /* String identifying platform. */ +#define AT_HWCAP 16 /* Machine dependent hints about + processor capabilities. */ + +/* This entry gives some information about the FPU initialization + performed by the kernel. */ +#define AT_FPUCW 18 /* Used FPU control word. */ + +/* Cache block sizes. */ +#define AT_DCACHEBSIZE 19 /* Data cache block size. */ +#define AT_ICACHEBSIZE 20 /* Instruction cache block size. */ +#define AT_UCACHEBSIZE 21 /* Unified cache block size. */ + +/* A special ignored value for PPC, used by the kernel to control the + interpretation of the AUXV. Must be > 16. */ +#define AT_IGNOREPPC 22 /* Entry should be ignored. */ + +#define AT_SECURE 23 /* Boolean, was exec setuid-like? */ + +/* Pointer to the global system page used for system calls and other + nice things. */ +#define AT_SYSINFO 32 +#define AT_SYSINFO_EHDR 33 + +/* Shapes of the caches. Bits 0-3 contains associativity; bits 4-7 contains + log2 of line size; mask those to get cache size. */ +#define AT_L1I_CACHESHAPE 34 +#define AT_L1D_CACHESHAPE 35 +#define AT_L2_CACHESHAPE 36 +#define AT_L3_CACHESHAPE 37 + +/* Note section contents. Each entry in the note section begins with + a header of a fixed form. */ + +typedef struct +{ + Elf32_Word n_namesz; /* Length of the note's name. */ + Elf32_Word n_descsz; /* Length of the note's descriptor. */ + Elf32_Word n_type; /* Type of the note. */ +} Elf32_Nhdr; + +typedef struct +{ + Elf64_Word n_namesz; /* Length of the note's name. */ + Elf64_Word n_descsz; /* Length of the note's descriptor. */ + Elf64_Word n_type; /* Type of the note. */ +} Elf64_Nhdr; + +/* Known names of notes. */ + +/* Solaris entries in the note section have this name. */ +#define ELF_NOTE_SOLARIS "SUNW Solaris" + +/* Note entries for GNU systems have this name. */ +#define ELF_NOTE_GNU "GNU" + + +/* Defined types of notes for Solaris. */ + +/* Value of descriptor (one word) is desired pagesize for the binary. */ +#define ELF_NOTE_PAGESIZE_HINT 1 + + +/* Defined note types for GNU systems. */ + +/* ABI information. The descriptor consists of words: + word 0: OS descriptor + word 1: major version of the ABI + word 2: minor version of the ABI + word 3: subminor version of the ABI +*/ +#define ELF_NOTE_ABI 1 + +/* Known OSes. These value can appear in word 0 of an ELF_NOTE_ABI + note section entry. */ +#define ELF_NOTE_OS_LINUX 0 +#define ELF_NOTE_OS_GNU 1 +#define ELF_NOTE_OS_SOLARIS2 2 +#define ELF_NOTE_OS_FREEBSD 3 + + +/* Move records. */ +typedef struct +{ + Elf32_Xword m_value; /* Symbol value. */ + Elf32_Word m_info; /* Size and index. */ + Elf32_Word m_poffset; /* Symbol offset. */ + Elf32_Half m_repeat; /* Repeat count. */ + Elf32_Half m_stride; /* Stride info. */ +} Elf32_Move; + +typedef struct +{ + Elf64_Xword m_value; /* Symbol value. */ + Elf64_Xword m_info; /* Size and index. */ + Elf64_Xword m_poffset; /* Symbol offset. */ + Elf64_Half m_repeat; /* Repeat count. */ + Elf64_Half m_stride; /* Stride info. */ +} Elf64_Move; + +/* Macro to construct move records. */ +#define ELF32_M_SYM(info) ((info) >> 8) +#define ELF32_M_SIZE(info) ((unsigned char) (info)) +#define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char) (size)) + +#define ELF64_M_SYM(info) ELF32_M_SYM (info) +#define ELF64_M_SIZE(info) ELF32_M_SIZE (info) +#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) + + +/* Motorola 68k specific definitions. */ + +/* Values for Elf32_Ehdr.e_flags. */ +#define EF_CPU32 0x00810000 + +/* m68k relocs. */ + +#define R_68K_NONE 0 /* No reloc */ +#define R_68K_32 1 /* Direct 32 bit */ +#define R_68K_16 2 /* Direct 16 bit */ +#define R_68K_8 3 /* Direct 8 bit */ +#define R_68K_PC32 4 /* PC relative 32 bit */ +#define R_68K_PC16 5 /* PC relative 16 bit */ +#define R_68K_PC8 6 /* PC relative 8 bit */ +#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */ +#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */ +#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */ +#define R_68K_GOT32O 10 /* 32 bit GOT offset */ +#define R_68K_GOT16O 11 /* 16 bit GOT offset */ +#define R_68K_GOT8O 12 /* 8 bit GOT offset */ +#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */ +#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */ +#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */ +#define R_68K_PLT32O 16 /* 32 bit PLT offset */ +#define R_68K_PLT16O 17 /* 16 bit PLT offset */ +#define R_68K_PLT8O 18 /* 8 bit PLT offset */ +#define R_68K_COPY 19 /* Copy symbol at runtime */ +#define R_68K_GLOB_DAT 20 /* Create GOT entry */ +#define R_68K_JMP_SLOT 21 /* Create PLT entry */ +#define R_68K_RELATIVE 22 /* Adjust by program base */ +/* Keep this the last entry. */ +#define R_68K_NUM 23 + +/* Intel 80386 specific definitions. */ + +/* i386 relocs. */ + +#define R_386_NONE 0 /* No reloc */ +#define R_386_32 1 /* Direct 32 bit */ +#define R_386_PC32 2 /* PC relative 32 bit */ +#define R_386_GOT32 3 /* 32 bit GOT entry */ +#define R_386_PLT32 4 /* 32 bit PLT address */ +#define R_386_COPY 5 /* Copy symbol at runtime */ +#define R_386_GLOB_DAT 6 /* Create GOT entry */ +#define R_386_JMP_SLOT 7 /* Create PLT entry */ +#define R_386_RELATIVE 8 /* Adjust by program base */ +#define R_386_GOTOFF 9 /* 32 bit offset to GOT */ +#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */ +#define R_386_32PLT 11 +#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */ +#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS + block offset */ +#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block + offset */ +#define R_386_TLS_LE 17 /* Offset relative to static TLS + block */ +#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of + general dynamic thread local data */ +#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of + local dynamic thread local data + in LE code */ +#define R_386_16 20 +#define R_386_PC16 21 +#define R_386_8 22 +#define R_386_PC8 23 +#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic + thread local data */ +#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */ +#define R_386_TLS_GD_CALL 26 /* Relocation for call to + __tls_get_addr() */ +#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */ +#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic + thread local data in LE code */ +#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */ +#define R_386_TLS_LDM_CALL 30 /* Relocation for call to + __tls_get_addr() in LDM code */ +#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */ +#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */ +#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS + block offset */ +#define R_386_TLS_LE_32 34 /* Negated offset relative to static + TLS block */ +#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */ +#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */ +#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */ +/* Keep this the last entry. */ +#define R_386_NUM 38 + +/* Blackfin specific definitions. */ +#define R_BFIN_unused0 0x00 +#define R_BFIN_pcrel5m2 0x01 +#define R_BFIN_unused1 0x02 +#define R_BFIN_pcrel10 0x03 +#define R_BFIN_pcrel12_jump 0x04 +#define R_BFIN_rimm16 0x05 +#define R_BFIN_luimm16 0x06 +#define R_BFIN_huimm16 0x07 +#define R_BFIN_pcrel12_jump_s 0x08 +#define R_BFIN_pcrel24_jump_x 0x09 +#define R_BFIN_pcrel24 0x0a +#define R_BFIN_unusedb 0x0b +#define R_BFIN_unusedc 0x0c +#define R_BFIN_pcrel24_jump_l 0x0d +#define R_BFIN_pcrel24_call_x 0x0e +#define R_BFIN_var_eq_symb 0x0f +#define R_BFIN_byte_data 0x10 +#define R_BFIN_byte2_data 0x11 +#define R_BFIN_byte4_data 0x12 +#define R_BFIN_pcrel11 0x13 + +#define R_BFIN_GOT17M4 0x14 +#define R_BFIN_GOTHI 0x15 +#define R_BFIN_GOTLO 0x16 +#define R_BFIN_FUNCDESC 0x17 +#define R_BFIN_FUNCDESC_GOT17M4 0x18 +#define R_BFIN_FUNCDESC_GOTHI 0x19 +#define R_BFIN_FUNCDESC_GOTLO 0x1a +#define R_BFIN_FUNCDESC_VALUE 0x1b +#define R_BFIN_FUNCDESC_GOTOFF17M4 0x1c +#define R_BFIN_FUNCDESC_GOTOFFHI 0x1d +#define R_BFIN_FUNCDESC_GOTOFFLO 0x1e +#define R_BFIN_GOTOFF17M4 0x1f +#define R_BFIN_GOTOFFHI 0x20 +#define R_BFIN_GOTOFFLO 0x21 + +#define EF_BFIN_PIC 0x00000001 /* -fpic */ +#define EF_BFIN_FDPIC 0x00000002 /* -mfdpic */ +#define EF_BFIN_CODE_IN_L1 0x00000010 /* --code-in-l1 */ +#define EF_BFIN_DATA_IN_L1 0x00000020 /* --data-in-l1 */ + +/* FR-V specific definitions. */ +#define R_FRV_NONE 0 /* No reloc. */ +#define R_FRV_32 1 /* Direct 32 bit. */ +/* Canonical function descriptor address. */ +#define R_FRV_FUNCDESC 14 +/* Private function descriptor initialization. */ +#define R_FRV_FUNCDESC_VALUE 18 + + /* gpr support */ +#define EF_FRV_GPR_MASK 0x00000003 /* mask for # of gprs */ +#define EF_FRV_GPR_32 0x00000001 /* -mgpr-32 */ +#define EF_FRV_GPR_64 0x00000002 /* -mgpr-64 */ + + /* fpr support */ +#define EF_FRV_FPR_MASK 0x0000000c /* mask for # of fprs */ +#define EF_FRV_FPR_32 0x00000004 /* -mfpr-32 */ +#define EF_FRV_FPR_64 0x00000008 /* -mfpr-64 */ +#define EF_FRV_FPR_NONE 0x0000000c /* -msoft-float */ + +#define EF_FRV_PIC 0x00000100 +#define EF_FRV_FDPIC 0x00008000 + +/* SUN SPARC specific definitions. */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_SPARC_REGISTER 13 /* Global register reserved to app. */ + +/* Values for Elf64_Ehdr.e_flags. */ + +#define EF_SPARCV9_MM 3 +#define EF_SPARCV9_TSO 0 +#define EF_SPARCV9_PSO 1 +#define EF_SPARCV9_RMO 2 +#define EF_SPARC_LEDATA 0x800000 /* little endian data */ +#define EF_SPARC_EXT_MASK 0xFFFF00 +#define EF_SPARC_32PLUS 0x000100 /* generic V8+ features */ +#define EF_SPARC_SUN_US1 0x000200 /* Sun UltraSPARC1 extensions */ +#define EF_SPARC_HAL_R1 0x000400 /* HAL R1 extensions */ +#define EF_SPARC_SUN_US3 0x000800 /* Sun UltraSPARCIII extensions */ + +/* SPARC relocs. */ + +#define R_SPARC_NONE 0 /* No reloc */ +#define R_SPARC_8 1 /* Direct 8 bit */ +#define R_SPARC_16 2 /* Direct 16 bit */ +#define R_SPARC_32 3 /* Direct 32 bit */ +#define R_SPARC_DISP8 4 /* PC relative 8 bit */ +#define R_SPARC_DISP16 5 /* PC relative 16 bit */ +#define R_SPARC_DISP32 6 /* PC relative 32 bit */ +#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */ +#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */ +#define R_SPARC_HI22 9 /* High 22 bit */ +#define R_SPARC_22 10 /* Direct 22 bit */ +#define R_SPARC_13 11 /* Direct 13 bit */ +#define R_SPARC_LO10 12 /* Truncated 10 bit */ +#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */ +#define R_SPARC_GOT13 14 /* 13 bit GOT entry */ +#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */ +#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */ +#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */ +#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */ +#define R_SPARC_COPY 19 /* Copy symbol at runtime */ +#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */ +#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */ +#define R_SPARC_RELATIVE 22 /* Adjust by program base */ +#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */ + +/* Additional Sparc64 relocs. */ + +#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */ +#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */ +#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */ +#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */ +#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */ +#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */ +#define R_SPARC_10 30 /* Direct 10 bit */ +#define R_SPARC_11 31 /* Direct 11 bit */ +#define R_SPARC_64 32 /* Direct 64 bit */ +#define R_SPARC_OLO10 33 /* 10bit with secondary 13bit addend */ +#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */ +#define R_SPARC_HM10 35 /* High middle 10 bits of ... */ +#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */ +#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */ +#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */ +#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */ +#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */ +#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */ +#define R_SPARC_7 43 /* Direct 7 bit */ +#define R_SPARC_5 44 /* Direct 5 bit */ +#define R_SPARC_6 45 /* Direct 6 bit */ +#define R_SPARC_DISP64 46 /* PC relative 64 bit */ +#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */ +#define R_SPARC_HIX22 48 /* High 22 bit complemented */ +#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */ +#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */ +#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */ +#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */ +#define R_SPARC_REGISTER 53 /* Global register usage */ +#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */ +#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */ +#define R_SPARC_TLS_GD_HI22 56 +#define R_SPARC_TLS_GD_LO10 57 +#define R_SPARC_TLS_GD_ADD 58 +#define R_SPARC_TLS_GD_CALL 59 +#define R_SPARC_TLS_LDM_HI22 60 +#define R_SPARC_TLS_LDM_LO10 61 +#define R_SPARC_TLS_LDM_ADD 62 +#define R_SPARC_TLS_LDM_CALL 63 +#define R_SPARC_TLS_LDO_HIX22 64 +#define R_SPARC_TLS_LDO_LOX10 65 +#define R_SPARC_TLS_LDO_ADD 66 +#define R_SPARC_TLS_IE_HI22 67 +#define R_SPARC_TLS_IE_LO10 68 +#define R_SPARC_TLS_IE_LD 69 +#define R_SPARC_TLS_IE_LDX 70 +#define R_SPARC_TLS_IE_ADD 71 +#define R_SPARC_TLS_LE_HIX22 72 +#define R_SPARC_TLS_LE_LOX10 73 +#define R_SPARC_TLS_DTPMOD32 74 +#define R_SPARC_TLS_DTPMOD64 75 +#define R_SPARC_TLS_DTPOFF32 76 +#define R_SPARC_TLS_DTPOFF64 77 +#define R_SPARC_TLS_TPOFF32 78 +#define R_SPARC_TLS_TPOFF64 79 +/* Keep this the last entry. */ +#define R_SPARC_NUM 80 + +/* For Sparc64, legal values for d_tag of Elf64_Dyn. */ + +#define DT_SPARC_REGISTER 0x70000001 +#define DT_SPARC_NUM 2 + +/* Bits present in AT_HWCAP, primarily for Sparc32. */ + +#define HWCAP_SPARC_FLUSH 1 /* The cpu supports flush insn. */ +#define HWCAP_SPARC_STBAR 2 +#define HWCAP_SPARC_SWAP 4 +#define HWCAP_SPARC_MULDIV 8 +#define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */ +#define HWCAP_SPARC_ULTRA3 32 + +/* MIPS R3000 specific definitions. */ + +/* Legal values for e_flags field of Elf32_Ehdr. */ + +#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */ +#define EF_MIPS_PIC 2 /* Contains PIC code */ +#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */ +#define EF_MIPS_XGOT 8 +#define EF_MIPS_64BIT_WHIRL 16 +#define EF_MIPS_ABI2 32 +#define EF_MIPS_ABI_ON32 64 +#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */ + +/* Legal values for MIPS architecture level. */ + +#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ +#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ +#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ +#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ +#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ +#define EF_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */ +#define EF_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */ + +/* The following are non-official names and should not be used. */ + +#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */ +#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */ +#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */ +#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */ +#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */ +#define E_MIPS_ARCH_32 0x60000000 /* MIPS32 code. */ +#define E_MIPS_ARCH_64 0x70000000 /* MIPS64 code. */ + +/* Special section indices. */ + +#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */ +#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */ +#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */ +#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */ +#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */ + +/* Legal values for sh_type field of Elf32_Shdr. */ + +#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */ +#define SHT_MIPS_MSYM 0x70000001 +#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */ +#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */ +#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */ +#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/ +#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */ +#define SHT_MIPS_PACKAGE 0x70000007 +#define SHT_MIPS_PACKSYM 0x70000008 +#define SHT_MIPS_RELD 0x70000009 +#define SHT_MIPS_IFACE 0x7000000b +#define SHT_MIPS_CONTENT 0x7000000c +#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */ +#define SHT_MIPS_SHDR 0x70000010 +#define SHT_MIPS_FDESC 0x70000011 +#define SHT_MIPS_EXTSYM 0x70000012 +#define SHT_MIPS_DENSE 0x70000013 +#define SHT_MIPS_PDESC 0x70000014 +#define SHT_MIPS_LOCSYM 0x70000015 +#define SHT_MIPS_AUXSYM 0x70000016 +#define SHT_MIPS_OPTSYM 0x70000017 +#define SHT_MIPS_LOCSTR 0x70000018 +#define SHT_MIPS_LINE 0x70000019 +#define SHT_MIPS_RFDESC 0x7000001a +#define SHT_MIPS_DELTASYM 0x7000001b +#define SHT_MIPS_DELTAINST 0x7000001c +#define SHT_MIPS_DELTACLASS 0x7000001d +#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */ +#define SHT_MIPS_DELTADECL 0x7000001f +#define SHT_MIPS_SYMBOL_LIB 0x70000020 +#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */ +#define SHT_MIPS_TRANSLATE 0x70000022 +#define SHT_MIPS_PIXIE 0x70000023 +#define SHT_MIPS_XLATE 0x70000024 +#define SHT_MIPS_XLATE_DEBUG 0x70000025 +#define SHT_MIPS_WHIRL 0x70000026 +#define SHT_MIPS_EH_REGION 0x70000027 +#define SHT_MIPS_XLATE_OLD 0x70000028 +#define SHT_MIPS_PDR_EXCEPTION 0x70000029 + +/* Legal values for sh_flags field of Elf32_Shdr. */ + +#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */ +#define SHF_MIPS_MERGE 0x20000000 +#define SHF_MIPS_ADDR 0x40000000 +#define SHF_MIPS_STRINGS 0x80000000 +#define SHF_MIPS_NOSTRIP 0x08000000 +#define SHF_MIPS_LOCAL 0x04000000 +#define SHF_MIPS_NAMES 0x02000000 +#define SHF_MIPS_NODUPE 0x01000000 + + +/* Symbol tables. */ + +/* MIPS specific values for `st_other'. */ +#define STO_MIPS_DEFAULT 0x0 +#define STO_MIPS_INTERNAL 0x1 +#define STO_MIPS_HIDDEN 0x2 +#define STO_MIPS_PROTECTED 0x3 +#define STO_MIPS_SC_ALIGN_UNUSED 0xff + +/* MIPS specific values for `st_info'. */ +#define STB_MIPS_SPLIT_COMMON 13 + +/* Entries found in sections of type SHT_MIPS_GPTAB. */ + +typedef union +{ + struct + { + Elf32_Word gt_current_g_value; /* -G value used for compilation */ + Elf32_Word gt_unused; /* Not used */ + } gt_header; /* First entry in section */ + struct + { + Elf32_Word gt_g_value; /* If this value were used for -G */ + Elf32_Word gt_bytes; /* This many bytes would be used */ + } gt_entry; /* Subsequent entries in section */ +} Elf32_gptab; + +/* Entry found in sections of type SHT_MIPS_REGINFO. */ + +typedef struct +{ + Elf32_Word ri_gprmask; /* General registers used */ + Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */ + Elf32_Sword ri_gp_value; /* $gp register value */ +} Elf32_RegInfo; + +/* Entries found in sections of type SHT_MIPS_OPTIONS. */ + +typedef struct +{ + unsigned char kind; /* Determines interpretation of the + variable part of descriptor. */ + unsigned char size; /* Size of descriptor, including header. */ + Elf32_Section section; /* Section header index of section affected, + 0 for global options. */ + Elf32_Word info; /* Kind-specific information. */ +} Elf_Options; + +/* Values for `kind' field in Elf_Options. */ + +#define ODK_NULL 0 /* Undefined. */ +#define ODK_REGINFO 1 /* Register usage information. */ +#define ODK_EXCEPTIONS 2 /* Exception processing options. */ +#define ODK_PAD 3 /* Section padding options. */ +#define ODK_HWPATCH 4 /* Hardware workarounds performed */ +#define ODK_FILL 5 /* record the fill value used by the linker. */ +#define ODK_TAGS 6 /* reserve space for desktop tools to write. */ +#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */ +#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */ + +/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */ + +#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */ +#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */ +#define OEX_PAGE0 0x10000 /* page zero must be mapped. */ +#define OEX_SMM 0x20000 /* Force sequential memory mode? */ +#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */ +#define OEX_PRECISEFP OEX_FPDBUG +#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */ + +#define OEX_FPU_INVAL 0x10 +#define OEX_FPU_DIV0 0x08 +#define OEX_FPU_OFLO 0x04 +#define OEX_FPU_UFLO 0x02 +#define OEX_FPU_INEX 0x01 + +/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */ + +#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */ +#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */ +#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */ +#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */ + +#define OPAD_PREFIX 0x1 +#define OPAD_POSTFIX 0x2 +#define OPAD_SYMBOL 0x4 + +/* Entry found in `.options' section. */ + +typedef struct +{ + Elf32_Word hwp_flags1; /* Extra flags. */ + Elf32_Word hwp_flags2; /* Extra flags. */ +} Elf_Options_Hw; + +/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */ + +#define OHWA0_R4KEOP_CHECKED 0x00000001 +#define OHWA1_R4KEOP_CLEAN 0x00000002 + +/* MIPS relocs. */ + +#define R_MIPS_NONE 0 /* No reloc */ +#define R_MIPS_16 1 /* Direct 16 bit */ +#define R_MIPS_32 2 /* Direct 32 bit */ +#define R_MIPS_REL32 3 /* PC relative 32 bit */ +#define R_MIPS_26 4 /* Direct 26 bit shifted */ +#define R_MIPS_HI16 5 /* High 16 bit */ +#define R_MIPS_LO16 6 /* Low 16 bit */ +#define R_MIPS_GPREL16 7 /* GP relative 16 bit */ +#define R_MIPS_LITERAL 8 /* 16 bit literal entry */ +#define R_MIPS_GOT16 9 /* 16 bit GOT entry */ +#define R_MIPS_PC16 10 /* PC relative 16 bit */ +#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ +#define R_MIPS_GPREL32 12 /* GP relative 32 bit */ + +#define R_MIPS_SHIFT5 16 +#define R_MIPS_SHIFT6 17 +#define R_MIPS_64 18 +#define R_MIPS_GOT_DISP 19 +#define R_MIPS_GOT_PAGE 20 +#define R_MIPS_GOT_OFST 21 +#define R_MIPS_GOT_HI16 22 +#define R_MIPS_GOT_LO16 23 +#define R_MIPS_SUB 24 +#define R_MIPS_INSERT_A 25 +#define R_MIPS_INSERT_B 26 +#define R_MIPS_DELETE 27 +#define R_MIPS_HIGHER 28 +#define R_MIPS_HIGHEST 29 +#define R_MIPS_CALL_HI16 30 +#define R_MIPS_CALL_LO16 31 +#define R_MIPS_SCN_DISP 32 +#define R_MIPS_REL16 33 +#define R_MIPS_ADD_IMMEDIATE 34 +#define R_MIPS_PJUMP 35 +#define R_MIPS_RELGOT 36 +#define R_MIPS_JALR 37 +#define R_MIPS_TLS_DTPMOD32 38 /* Module number 32 bit */ +#define R_MIPS_TLS_DTPREL32 39 /* Module-relative offset 32 bit */ +#define R_MIPS_TLS_DTPMOD64 40 /* Module number 64 bit */ +#define R_MIPS_TLS_DTPREL64 41 /* Module-relative offset 64 bit */ +#define R_MIPS_TLS_GD 42 /* 16 bit GOT offset for GD */ +#define R_MIPS_TLS_LDM 43 /* 16 bit GOT offset for LDM */ +#define R_MIPS_TLS_DTPREL_HI16 44 /* Module-relative offset, high 16 bits */ +#define R_MIPS_TLS_DTPREL_LO16 45 /* Module-relative offset, low 16 bits */ +#define R_MIPS_TLS_GOTTPREL 46 /* 16 bit GOT offset for IE */ +#define R_MIPS_TLS_TPREL32 47 /* TP-relative offset, 32 bit */ +#define R_MIPS_TLS_TPREL64 48 /* TP-relative offset, 64 bit */ +#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */ +#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */ +/* Keep this the last entry. */ +#define R_MIPS_NUM 51 + +/* Legal values for p_type field of Elf32_Phdr. */ + +#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */ +#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */ +#define PT_MIPS_OPTIONS 0x70000002 + +/* Special program header types. */ + +#define PF_MIPS_LOCAL 0x10000000 + +/* Legal values for d_tag field of Elf32_Dyn. */ + +#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */ +#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */ +#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */ +#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */ +#define DT_MIPS_FLAGS 0x70000005 /* Flags */ +#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */ +#define DT_MIPS_MSYM 0x70000007 +#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */ +#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */ +#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */ +#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */ +#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */ +#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */ +#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */ +#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */ +#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */ +#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */ +#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */ +#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in + DT_MIPS_DELTA_CLASS. */ +#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */ +#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in + DT_MIPS_DELTA_INSTANCE. */ +#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */ +#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in + DT_MIPS_DELTA_RELOC. */ +#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta + relocations refer to. */ +#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in + DT_MIPS_DELTA_SYM. */ +#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the + class declaration. */ +#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in + DT_MIPS_DELTA_CLASSSYM. */ +#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */ +#define DT_MIPS_PIXIE_INIT 0x70000023 +#define DT_MIPS_SYMBOL_LIB 0x70000024 +#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 +#define DT_MIPS_LOCAL_GOTIDX 0x70000026 +#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 +#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 +#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */ +#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */ +#define DT_MIPS_DYNSTR_ALIGN 0x7000002b +#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */ +#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve + function stored in GOT. */ +#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added + by rld on dlopen() calls. */ +#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */ +#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */ +#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */ +#define DT_MIPS_NUM 0x32 + +/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */ + +#define RHF_NONE 0 /* No flags */ +#define RHF_QUICKSTART (1 << 0) /* Use quickstart */ +#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */ +#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */ +#define RHF_NO_MOVE (1 << 3) +#define RHF_SGI_ONLY (1 << 4) +#define RHF_GUARANTEE_INIT (1 << 5) +#define RHF_DELTA_C_PLUS_PLUS (1 << 6) +#define RHF_GUARANTEE_START_INIT (1 << 7) +#define RHF_PIXIE (1 << 8) +#define RHF_DEFAULT_DELAY_LOAD (1 << 9) +#define RHF_REQUICKSTART (1 << 10) +#define RHF_REQUICKSTARTED (1 << 11) +#define RHF_CORD (1 << 12) +#define RHF_NO_UNRES_UNDEF (1 << 13) +#define RHF_RLD_ORDER_SAFE (1 << 14) + +/* Entries found in sections of type SHT_MIPS_LIBLIST. */ + +typedef struct +{ + Elf32_Word l_name; /* Name (string table index) */ + Elf32_Word l_time_stamp; /* Timestamp */ + Elf32_Word l_checksum; /* Checksum */ + Elf32_Word l_version; /* Interface version */ + Elf32_Word l_flags; /* Flags */ +} Elf32_Lib; + +typedef struct +{ + Elf64_Word l_name; /* Name (string table index) */ + Elf64_Word l_time_stamp; /* Timestamp */ + Elf64_Word l_checksum; /* Checksum */ + Elf64_Word l_version; /* Interface version */ + Elf64_Word l_flags; /* Flags */ +} Elf64_Lib; + + +/* Legal values for l_flags. */ + +#define LL_NONE 0 +#define LL_EXACT_MATCH (1 << 0) /* Require exact match */ +#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */ +#define LL_REQUIRE_MINOR (1 << 2) +#define LL_EXPORTS (1 << 3) +#define LL_DELAY_LOAD (1 << 4) +#define LL_DELTA (1 << 5) + +/* Entries found in sections of type SHT_MIPS_CONFLICT. */ + +typedef Elf32_Addr Elf32_Conflict; + + +/* HPPA specific definitions. */ + +/* Legal values for e_flags field of Elf32_Ehdr. */ + +#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */ +#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */ +#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */ +#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */ +#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch + prediction. */ +#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */ +#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */ + +/* Defined values for `e_flags & EF_PARISC_ARCH' are: */ + +#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */ +#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */ +#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */ + +/* Additional section indeces. */ + +#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared + symbols in ANSI C. */ +#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */ + +/* Legal values for sh_type field of Elf32_Shdr. */ + +#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */ +#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */ +#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */ + +/* Legal values for sh_flags field of Elf32_Shdr. */ + +#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */ +#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */ +#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */ + +/* Legal values for ST_TYPE subfield of st_info (symbol type). */ + +#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */ + +#define STT_HP_OPAQUE (STT_LOOS + 0x1) +#define STT_HP_STUB (STT_LOOS + 0x2) + +/* HPPA relocs. */ + +#define R_PARISC_NONE 0 /* No reloc. */ +#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */ +#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */ +#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */ +#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */ +#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */ +#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */ +#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */ +#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */ +#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */ +#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */ +#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */ +#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */ +#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */ +#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */ +#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */ +#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */ +#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */ +#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */ +#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */ +#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */ +#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */ +#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */ +#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */ +#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */ +#define R_PARISC_FPTR64 64 /* 64 bits function address. */ +#define R_PARISC_PLABEL32 65 /* 32 bits function address. */ +#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */ +#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */ +#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */ +#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */ +#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */ +#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */ +#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */ +#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */ +#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */ +#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */ +#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */ +#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */ +#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */ +#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */ +#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */ +#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */ +#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */ +#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */ +#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */ +#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */ +#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */ +#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */ +#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */ +#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */ +#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */ +#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */ +#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */ +#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */ +#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */ +#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */ +#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */ +#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */ +#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */ +#define R_PARISC_LORESERVE 128 +#define R_PARISC_COPY 128 /* Copy relocation. */ +#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */ +#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */ +#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */ +#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */ +#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */ +#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */ +#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */ +#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */ +#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */ +#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */ +#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */ +#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/ +#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */ +#define R_PARISC_HIRESERVE 255 + +/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */ + +#define PT_HP_TLS (PT_LOOS + 0x0) +#define PT_HP_CORE_NONE (PT_LOOS + 0x1) +#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) +#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) +#define PT_HP_CORE_COMM (PT_LOOS + 0x4) +#define PT_HP_CORE_PROC (PT_LOOS + 0x5) +#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) +#define PT_HP_CORE_STACK (PT_LOOS + 0x7) +#define PT_HP_CORE_SHM (PT_LOOS + 0x8) +#define PT_HP_CORE_MMF (PT_LOOS + 0x9) +#define PT_HP_PARALLEL (PT_LOOS + 0x10) +#define PT_HP_FASTBIND (PT_LOOS + 0x11) +#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) +#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) +#define PT_HP_STACK (PT_LOOS + 0x14) + +#define PT_PARISC_ARCHEXT 0x70000000 +#define PT_PARISC_UNWIND 0x70000001 + +/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */ + +#define PF_PARISC_SBP 0x08000000 + +#define PF_HP_PAGE_SIZE 0x00100000 +#define PF_HP_FAR_SHARED 0x00200000 +#define PF_HP_NEAR_SHARED 0x00400000 +#define PF_HP_CODE 0x01000000 +#define PF_HP_MODIFY 0x02000000 +#define PF_HP_LAZYSWAP 0x04000000 +#define PF_HP_SBP 0x08000000 + + +/* Alpha specific definitions. */ + +/* Legal values for e_flags field of Elf64_Ehdr. */ + +#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */ +#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */ + +/* Legal values for sh_type field of Elf64_Shdr. */ + +/* These two are primerily concerned with ECOFF debugging info. */ +#define SHT_ALPHA_DEBUG 0x70000001 +#define SHT_ALPHA_REGINFO 0x70000002 + +/* Legal values for sh_flags field of Elf64_Shdr. */ + +#define SHF_ALPHA_GPREL 0x10000000 + +/* Legal values for st_other field of Elf64_Sym. */ +#define STO_ALPHA_NOPV 0x80 /* No PV required. */ +#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */ + +/* Alpha relocs. */ + +#define R_ALPHA_NONE 0 /* No reloc */ +#define R_ALPHA_REFLONG 1 /* Direct 32 bit */ +#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */ +#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */ +#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */ +#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */ +#define R_ALPHA_GPDISP 6 /* Add displacement to GP */ +#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */ +#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */ +#define R_ALPHA_SREL16 9 /* PC relative 16 bit */ +#define R_ALPHA_SREL32 10 /* PC relative 32 bit */ +#define R_ALPHA_SREL64 11 /* PC relative 64 bit */ +#define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */ +#define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */ +#define R_ALPHA_GPREL16 19 /* GP relative 16 bit */ +#define R_ALPHA_COPY 24 /* Copy symbol at runtime */ +#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */ +#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */ +#define R_ALPHA_RELATIVE 27 /* Adjust by program base */ +#define R_ALPHA_TLS_GD_HI 28 +#define R_ALPHA_TLSGD 29 +#define R_ALPHA_TLS_LDM 30 +#define R_ALPHA_DTPMOD64 31 +#define R_ALPHA_GOTDTPREL 32 +#define R_ALPHA_DTPREL64 33 +#define R_ALPHA_DTPRELHI 34 +#define R_ALPHA_DTPRELLO 35 +#define R_ALPHA_DTPREL16 36 +#define R_ALPHA_GOTTPREL 37 +#define R_ALPHA_TPREL64 38 +#define R_ALPHA_TPRELHI 39 +#define R_ALPHA_TPRELLO 40 +#define R_ALPHA_TPREL16 41 +/* Keep this the last entry. */ +#define R_ALPHA_NUM 46 + +/* Magic values of the LITUSE relocation addend. */ +#define LITUSE_ALPHA_ADDR 0 +#define LITUSE_ALPHA_BASE 1 +#define LITUSE_ALPHA_BYTOFF 2 +#define LITUSE_ALPHA_JSR 3 +#define LITUSE_ALPHA_TLS_GD 4 +#define LITUSE_ALPHA_TLS_LDM 5 + +/* Legal values for d_tag of Elf64_Dyn. */ +#define DT_ALPHA_PLTRO (DT_LOPROC + 0) +#define DT_ALPHA_NUM 1 + +/* PowerPC specific declarations */ + +/* Values for Elf32/64_Ehdr.e_flags. */ +#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag */ + +/* Cygnus local bits below */ +#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/ +#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib + flag */ + +/* PowerPC relocations defined by the ABIs */ +#define R_PPC_NONE 0 +#define R_PPC_ADDR32 1 /* 32bit absolute address */ +#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */ +#define R_PPC_ADDR16 3 /* 16bit absolute address */ +#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */ +#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */ +#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */ +#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */ +#define R_PPC_ADDR14_BRTAKEN 8 +#define R_PPC_ADDR14_BRNTAKEN 9 +#define R_PPC_REL24 10 /* PC relative 26 bit */ +#define R_PPC_REL14 11 /* PC relative 16 bit */ +#define R_PPC_REL14_BRTAKEN 12 +#define R_PPC_REL14_BRNTAKEN 13 +#define R_PPC_GOT16 14 +#define R_PPC_GOT16_LO 15 +#define R_PPC_GOT16_HI 16 +#define R_PPC_GOT16_HA 17 +#define R_PPC_PLTREL24 18 +#define R_PPC_COPY 19 +#define R_PPC_GLOB_DAT 20 +#define R_PPC_JMP_SLOT 21 +#define R_PPC_RELATIVE 22 +#define R_PPC_LOCAL24PC 23 +#define R_PPC_UADDR32 24 +#define R_PPC_UADDR16 25 +#define R_PPC_REL32 26 +#define R_PPC_PLT32 27 +#define R_PPC_PLTREL32 28 +#define R_PPC_PLT16_LO 29 +#define R_PPC_PLT16_HI 30 +#define R_PPC_PLT16_HA 31 +#define R_PPC_SDAREL16 32 +#define R_PPC_SECTOFF 33 +#define R_PPC_SECTOFF_LO 34 +#define R_PPC_SECTOFF_HI 35 +#define R_PPC_SECTOFF_HA 36 + +/* PowerPC relocations defined for the TLS access ABI. */ +#define R_PPC_TLS 67 /* none (sym+add)@tls */ +#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */ +#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */ +#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ +#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ +#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ +#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */ +#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */ +#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ +#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ +#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ +#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */ +#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ +#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ +#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ +#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ +#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ +#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ +#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ +#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ +#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */ +#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */ +#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ +#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ +#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */ +#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */ +#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */ +#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */ + +/* Keep this the last entry. */ +#define R_PPC_NUM 95 + +/* The remaining relocs are from the Embedded ELF ABI, and are not + in the SVR4 ELF ABI. */ +#define R_PPC_EMB_NADDR32 101 +#define R_PPC_EMB_NADDR16 102 +#define R_PPC_EMB_NADDR16_LO 103 +#define R_PPC_EMB_NADDR16_HI 104 +#define R_PPC_EMB_NADDR16_HA 105 +#define R_PPC_EMB_SDAI16 106 +#define R_PPC_EMB_SDA2I16 107 +#define R_PPC_EMB_SDA2REL 108 +#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */ +#define R_PPC_EMB_MRKREF 110 +#define R_PPC_EMB_RELSEC16 111 +#define R_PPC_EMB_RELST_LO 112 +#define R_PPC_EMB_RELST_HI 113 +#define R_PPC_EMB_RELST_HA 114 +#define R_PPC_EMB_BIT_FLD 115 +#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */ + +/* Diab tool relocations. */ +#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */ +#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */ +#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */ +#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */ +#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */ +#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */ + +/* GNU relocs used in PIC code sequences. */ +#define R_PPC_REL16 249 /* word32 (sym-.) */ +#define R_PPC_REL16_LO 250 /* half16 (sym-.)@l */ +#define R_PPC_REL16_HI 251 /* half16 (sym-.)@h */ +#define R_PPC_REL16_HA 252 /* half16 (sym-.)@ha */ + +/* This is a phony reloc to handle any old fashioned TOC16 references + that may still be in object files. */ +#define R_PPC_TOC16 255 + +/* PowerPC specific values for the Dyn d_tag field. */ +#define DT_PPC_GOT (DT_LOPROC + 0) +#define DT_PPC_NUM 1 + +/* PowerPC64 relocations defined by the ABIs */ +#define R_PPC64_NONE R_PPC_NONE +#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address */ +#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned */ +#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address */ +#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of address */ +#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of address. */ +#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */ +#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned */ +#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN +#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN +#define R_PPC64_REL24 R_PPC_REL24 /* PC-rel. 26 bit, word aligned */ +#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit */ +#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN +#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN +#define R_PPC64_GOT16 R_PPC_GOT16 +#define R_PPC64_GOT16_LO R_PPC_GOT16_LO +#define R_PPC64_GOT16_HI R_PPC_GOT16_HI +#define R_PPC64_GOT16_HA R_PPC_GOT16_HA + +#define R_PPC64_COPY R_PPC_COPY +#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT +#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT +#define R_PPC64_RELATIVE R_PPC_RELATIVE + +#define R_PPC64_UADDR32 R_PPC_UADDR32 +#define R_PPC64_UADDR16 R_PPC_UADDR16 +#define R_PPC64_REL32 R_PPC_REL32 +#define R_PPC64_PLT32 R_PPC_PLT32 +#define R_PPC64_PLTREL32 R_PPC_PLTREL32 +#define R_PPC64_PLT16_LO R_PPC_PLT16_LO +#define R_PPC64_PLT16_HI R_PPC_PLT16_HI +#define R_PPC64_PLT16_HA R_PPC_PLT16_HA + +#define R_PPC64_SECTOFF R_PPC_SECTOFF +#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO +#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI +#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA +#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2 */ +#define R_PPC64_ADDR64 38 /* doubleword64 S + A */ +#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A) */ +#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */ +#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */ +#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A) */ +#define R_PPC64_UADDR64 43 /* doubleword64 S + A */ +#define R_PPC64_REL64 44 /* doubleword64 S + A - P */ +#define R_PPC64_PLT64 45 /* doubleword64 L + A */ +#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P */ +#define R_PPC64_TOC16 47 /* half16* S + A - .TOC */ +#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.) */ +#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.) */ +#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.) */ +#define R_PPC64_TOC 51 /* doubleword64 .TOC */ +#define R_PPC64_PLTGOT16 52 /* half16* M + A */ +#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A) */ +#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A) */ +#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A) */ + +#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2 */ +#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2 */ +#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2 */ +#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2 */ +#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2 */ +#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2 */ +#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2 */ +#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2 */ +#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2 */ +#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2 */ +#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2 */ + +/* PowerPC64 relocations defined for the TLS access ABI. */ +#define R_PPC64_TLS 67 /* none (sym+add)@tls */ +#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */ +#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */ +#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */ +#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */ +#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */ +#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */ +#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */ +#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */ +#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */ +#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */ +#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */ +#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */ +#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */ +#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */ +#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */ +#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */ +#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */ +#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */ +#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */ +#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */ +#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */ +#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */ +#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */ +#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */ +#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */ +#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */ +#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */ +#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */ +#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */ +#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */ +#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */ +#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */ +#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */ +#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */ +#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */ +#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */ +#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */ +#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */ +#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */ + +/* Keep this the last entry. */ +#define R_PPC64_NUM 107 + +/* PowerPC64 specific values for the Dyn d_tag field. */ +#define DT_PPC64_GLINK (DT_LOPROC + 0) +#define DT_PPC64_OPD (DT_LOPROC + 1) +#define DT_PPC64_OPDSZ (DT_LOPROC + 2) +#define DT_PPC64_NUM 3 + + +/* ARM specific declarations */ + +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_ARM_RELEXEC 0x01 +#define EF_ARM_HASENTRY 0x02 +#define EF_ARM_INTERWORK 0x04 +#define EF_ARM_APCS_26 0x08 +#define EF_ARM_APCS_FLOAT 0x10 +#define EF_ARM_PIC 0x20 +#define EF_ARM_ALIGN8 0x40 /* 8-bit structure alignment is in use */ +#define EF_ARM_NEW_ABI 0x80 +#define EF_ARM_OLD_ABI 0x100 + +/* Other constants defined in the ARM ELF spec. version B-01. */ +/* NB. These conflict with values defined above. */ +#define EF_ARM_SYMSARESORTED 0x04 +#define EF_ARM_DYNSYMSUSESEGIDX 0x08 +#define EF_ARM_MAPSYMSFIRST 0x10 +#define EF_ARM_EABIMASK 0XFF000000 + +#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK) +#define EF_ARM_EABI_UNKNOWN 0x00000000 +#define EF_ARM_EABI_VER1 0x01000000 +#define EF_ARM_EABI_VER2 0x02000000 + +/* Additional symbol types for Thumb */ +#define STT_ARM_TFUNC 0xd + +/* ARM-specific values for sh_flags */ +#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */ +#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined + in the input to a link step */ + +/* ARM-specific program header flags */ +#define PF_ARM_SB 0x10000000 /* Segment contains the location + addressed by the static base */ + +/* Processor specific values for the Phdr p_type field. */ +#define PT_ARM_EXIDX 0x70000001 /* .ARM.exidx segment */ + +/* ARM relocs. */ + +#define R_ARM_NONE 0 /* No reloc */ +#define R_ARM_PC24 1 /* PC relative 26 bit branch */ +#define R_ARM_ABS32 2 /* Direct 32 bit */ +#define R_ARM_REL32 3 /* PC relative 32 bit */ +#define R_ARM_PC13 4 +#define R_ARM_ABS16 5 /* Direct 16 bit */ +#define R_ARM_ABS12 6 /* Direct 12 bit */ +#define R_ARM_THM_ABS5 7 +#define R_ARM_ABS8 8 /* Direct 8 bit */ +#define R_ARM_SBREL32 9 +#define R_ARM_THM_PC22 10 +#define R_ARM_THM_PC8 11 +#define R_ARM_AMP_VCALL9 12 +#define R_ARM_SWI24 13 +#define R_ARM_THM_SWI8 14 +#define R_ARM_XPC25 15 +#define R_ARM_THM_XPC22 16 +#define R_ARM_COPY 20 /* Copy symbol at runtime */ +#define R_ARM_GLOB_DAT 21 /* Create GOT entry */ +#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */ +#define R_ARM_RELATIVE 23 /* Adjust by program base */ +#define R_ARM_GOTOFF 24 /* 32 bit offset to GOT */ +#define R_ARM_GOTPC 25 /* 32 bit PC relative offset to GOT */ +#define R_ARM_GOT32 26 /* 32 bit GOT entry */ +#define R_ARM_PLT32 27 /* 32 bit PLT address */ +#define R_ARM_ALU_PCREL_7_0 32 +#define R_ARM_ALU_PCREL_15_8 33 +#define R_ARM_ALU_PCREL_23_15 34 +#define R_ARM_LDR_SBREL_11_0 35 +#define R_ARM_ALU_SBREL_19_12 36 +#define R_ARM_ALU_SBREL_27_20 37 +#define R_ARM_GNU_VTENTRY 100 +#define R_ARM_GNU_VTINHERIT 101 +#define R_ARM_THM_PC11 102 /* thumb unconditional branch */ +#define R_ARM_THM_PC9 103 /* thumb conditional branch */ +#define R_ARM_RXPC25 249 +#define R_ARM_RSBREL32 250 +#define R_ARM_THM_RPC22 251 +#define R_ARM_RREL32 252 +#define R_ARM_RABS22 253 +#define R_ARM_RPC24 254 +#define R_ARM_RBASE 255 +/* Keep this the last entry. */ +#define R_ARM_NUM 256 + +/* IA-64 specific declarations. */ + +/* Processor specific flags for the Ehdr e_flags field. */ +#define EF_IA_64_MASKOS 0x0000000f /* os-specific flags */ +#define EF_IA_64_ABI64 0x00000010 /* 64-bit ABI */ +#define EF_IA_64_ARCH 0xff000000 /* arch. version mask */ + +/* Processor specific values for the Phdr p_type field. */ +#define PT_IA_64_ARCHEXT (PT_LOPROC + 0) /* arch extension bits */ +#define PT_IA_64_UNWIND (PT_LOPROC + 1) /* ia64 unwind bits */ +#define PT_IA_64_HP_OPT_ANOT (PT_LOOS + 0x12) +#define PT_IA_64_HP_HSL_ANOT (PT_LOOS + 0x13) +#define PT_IA_64_HP_STACK (PT_LOOS + 0x14) + +/* Processor specific flags for the Phdr p_flags field. */ +#define PF_IA_64_NORECOV 0x80000000 /* spec insns w/o recovery */ + +/* Processor specific values for the Shdr sh_type field. */ +#define SHT_IA_64_EXT (SHT_LOPROC + 0) /* extension bits */ +#define SHT_IA_64_UNWIND (SHT_LOPROC + 1) /* unwind bits */ + +/* Processor specific flags for the Shdr sh_flags field. */ +#define SHF_IA_64_SHORT 0x10000000 /* section near gp */ +#define SHF_IA_64_NORECOV 0x20000000 /* spec insns w/o recovery */ + +/* Processor specific values for the Dyn d_tag field. */ +#define DT_IA_64_PLT_RESERVE (DT_LOPROC + 0) +#define DT_IA_64_NUM 1 + +/* IA-64 relocations. */ +#define R_IA64_NONE 0x00 /* none */ +#define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */ +#define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */ +#define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */ +#define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */ +#define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */ +#define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */ +#define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */ +#define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */ +#define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */ +#define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */ +#define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */ +#define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */ +#define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */ +#define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */ +#define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */ +#define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */ +#define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */ +#define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */ +#define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */ +#define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */ +#define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */ +#define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */ +#define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */ +#define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */ +#define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */ +#define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */ +#define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */ +#define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */ +#define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */ +#define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */ +#define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */ +#define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */ +#define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */ +#define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */ +#define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */ +#define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */ +#define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */ +#define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */ +#define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */ +#define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */ +#define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */ +#define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */ +#define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */ +#define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */ +#define R_IA64_REL32MSB 0x6c /* data 4 + REL */ +#define R_IA64_REL32LSB 0x6d /* data 4 + REL */ +#define R_IA64_REL64MSB 0x6e /* data 8 + REL */ +#define R_IA64_REL64LSB 0x6f /* data 8 + REL */ +#define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */ +#define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */ +#define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */ +#define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */ +#define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */ +#define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */ +#define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */ +#define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */ +#define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */ +#define R_IA64_COPY 0x84 /* copy relocation */ +#define R_IA64_SUB 0x85 /* Addend and symbol difference */ +#define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */ +#define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */ +#define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */ +#define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */ +#define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */ +#define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */ +#define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */ +#define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */ +#define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */ +#define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */ +#define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */ +#define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */ +#define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */ +#define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */ +#define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */ +#define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */ +#define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */ +#define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */ + +/* SH specific declarations */ + +/* SH specific values for `st_other'. */ + +/* If set, this is a symbol pointing to SHmedia code, which will be branched + to, so need to add 1 to the symbol value. */ +#define STO_SH5_ISA32 (1 << 2) + +/* SH relocs. */ +#define R_SH_NONE 0 +#define R_SH_DIR32 1 +#define R_SH_REL32 2 +#define R_SH_DIR8WPN 3 +#define R_SH_IND12W 4 +#define R_SH_DIR8WPL 5 +#define R_SH_DIR8WPZ 6 +#define R_SH_DIR8BP 7 +#define R_SH_DIR8W 8 +#define R_SH_DIR8L 9 +#define R_SH_SWITCH16 25 +#define R_SH_SWITCH32 26 +#define R_SH_USES 27 +#define R_SH_COUNT 28 +#define R_SH_ALIGN 29 +#define R_SH_CODE 30 +#define R_SH_DATA 31 +#define R_SH_LABEL 32 +#define R_SH_SWITCH8 33 +#define R_SH_GNU_VTINHERIT 34 +#define R_SH_GNU_VTENTRY 35 +#define R_SH_TLS_GD_32 144 +#define R_SH_TLS_LD_32 145 +#define R_SH_TLS_LDO_32 146 +#define R_SH_TLS_IE_32 147 +#define R_SH_TLS_LE_32 148 +#define R_SH_TLS_DTPMOD32 149 +#define R_SH_TLS_DTPOFF32 150 +#define R_SH_TLS_TPOFF32 151 +#define R_SH_GOT32 160 +#define R_SH_PLT32 161 +#define R_SH_COPY 162 +#define R_SH_GLOB_DAT 163 +#define R_SH_JMP_SLOT 164 +#define R_SH_RELATIVE 165 +#define R_SH_GOTOFF 166 +#define R_SH_GOTPC 167 +#define R_SH_RELATIVE_LOW16 197 +#define R_SH_RELATIVE_MEDLOW16 198 +#define R_SH_IMM_LOW16 246 +#define R_SH_IMM_LOW16_PCREL 247 +#define R_SH_IMM_MEDLOW16 248 +#define R_SH_IMM_MEDLOW16_PCREL 249 + +/* Keep this the last entry. */ +#define R_SH_NUM 256 + +/* Additional s390 relocs */ + +#define R_390_NONE 0 /* No reloc. */ +#define R_390_8 1 /* Direct 8 bit. */ +#define R_390_12 2 /* Direct 12 bit. */ +#define R_390_16 3 /* Direct 16 bit. */ +#define R_390_32 4 /* Direct 32 bit. */ +#define R_390_PC32 5 /* PC relative 32 bit. */ +#define R_390_GOT12 6 /* 12 bit GOT offset. */ +#define R_390_GOT32 7 /* 32 bit GOT offset. */ +#define R_390_PLT32 8 /* 32 bit PC relative PLT address. */ +#define R_390_COPY 9 /* Copy symbol at runtime. */ +#define R_390_GLOB_DAT 10 /* Create GOT entry. */ +#define R_390_JMP_SLOT 11 /* Create PLT entry. */ +#define R_390_RELATIVE 12 /* Adjust by program base. */ +#define R_390_GOTOFF32 13 /* 32 bit offset to GOT. */ +#define R_390_GOTPC 14 /* 32 bit PC relative offset to GOT. */ +#define R_390_GOT16 15 /* 16 bit GOT offset. */ +#define R_390_PC16 16 /* PC relative 16 bit. */ +#define R_390_PC16DBL 17 /* PC relative 16 bit shifted by 1. */ +#define R_390_PLT16DBL 18 /* 16 bit PC rel. PLT shifted by 1. */ +#define R_390_PC32DBL 19 /* PC relative 32 bit shifted by 1. */ +#define R_390_PLT32DBL 20 /* 32 bit PC rel. PLT shifted by 1. */ +#define R_390_GOTPCDBL 21 /* 32 bit PC rel. GOT shifted by 1. */ +#define R_390_64 22 /* Direct 64 bit. */ +#define R_390_PC64 23 /* PC relative 64 bit. */ +#define R_390_GOT64 24 /* 64 bit GOT offset. */ +#define R_390_PLT64 25 /* 64 bit PC relative PLT address. */ +#define R_390_GOTENT 26 /* 32 bit PC rel. to GOT entry >> 1. */ +#define R_390_GOTOFF16 27 /* 16 bit offset to GOT. */ +#define R_390_GOTOFF64 28 /* 64 bit offset to GOT. */ +#define R_390_GOTPLT12 29 /* 12 bit offset to jump slot. */ +#define R_390_GOTPLT16 30 /* 16 bit offset to jump slot. */ +#define R_390_GOTPLT32 31 /* 32 bit offset to jump slot. */ +#define R_390_GOTPLT64 32 /* 64 bit offset to jump slot. */ +#define R_390_GOTPLTENT 33 /* 32 bit rel. offset to jump slot. */ +#define R_390_PLTOFF16 34 /* 16 bit offset from GOT to PLT. */ +#define R_390_PLTOFF32 35 /* 32 bit offset from GOT to PLT. */ +#define R_390_PLTOFF64 36 /* 16 bit offset from GOT to PLT. */ +#define R_390_TLS_LOAD 37 /* Tag for load insn in TLS code. */ +#define R_390_TLS_GDCALL 38 /* Tag for function call in general + dynamic TLS code. */ +#define R_390_TLS_LDCALL 39 /* Tag for function call in local + dynamic TLS code. */ +#define R_390_TLS_GD32 40 /* Direct 32 bit for general dynamic + thread local data. */ +#define R_390_TLS_GD64 41 /* Direct 64 bit for general dynamic + thread local data. */ +#define R_390_TLS_GOTIE12 42 /* 12 bit GOT offset for static TLS + block offset. */ +#define R_390_TLS_GOTIE32 43 /* 32 bit GOT offset for static TLS + block offset. */ +#define R_390_TLS_GOTIE64 44 /* 64 bit GOT offset for static TLS + block offset. */ +#define R_390_TLS_LDM32 45 /* Direct 32 bit for local dynamic + thread local data in LE code. */ +#define R_390_TLS_LDM64 46 /* Direct 64 bit for local dynamic + thread local data in LE code. */ +#define R_390_TLS_IE32 47 /* 32 bit address of GOT entry for + negated static TLS block offset. */ +#define R_390_TLS_IE64 48 /* 64 bit address of GOT entry for + negated static TLS block offset. */ +#define R_390_TLS_IEENT 49 /* 32 bit rel. offset to GOT entry for + negated static TLS block offset. */ +#define R_390_TLS_LE32 50 /* 32 bit negated offset relative to + static TLS block. */ +#define R_390_TLS_LE64 51 /* 64 bit negated offset relative to + static TLS block. */ +#define R_390_TLS_LDO32 52 /* 32 bit offset relative to TLS + block. */ +#define R_390_TLS_LDO64 53 /* 64 bit offset relative to TLS + block. */ +#define R_390_TLS_DTPMOD 54 /* ID of module containing symbol. */ +#define R_390_TLS_DTPOFF 55 /* Offset in TLS block. */ +#define R_390_TLS_TPOFF 56 /* Negated offset in static TLS + block. */ +#define R_390_20 57 /* Direct 20 bit. */ +#define R_390_GOT20 58 /* 20 bit GOT offset. */ +#define R_390_GOTPLT20 59 /* 20 bit offset to jump slot. */ +#define R_390_TLS_GOTIE20 60 /* 20 bit GOT offset for static TLS + block offset. */ +/* Keep this the last entry. */ +#define R_390_NUM 61 + + +/* CRIS flags. */ +#define EF_CRIS_VARIANT_MASK 0x0000000e +#define EF_CRIS_VARIANT_ANY_V0_V10 0x00000000 +#define EF_CRIS_VARIANT_V32 0x00000002 +#define EF_CRIS_VARIANT_COMMON_V10_V32 0x00000004 + +/* CRIS relocations. */ +#define R_CRIS_NONE 0 +#define R_CRIS_8 1 +#define R_CRIS_16 2 +#define R_CRIS_32 3 +#define R_CRIS_8_PCREL 4 +#define R_CRIS_16_PCREL 5 +#define R_CRIS_32_PCREL 6 +#define R_CRIS_GNU_VTINHERIT 7 +#define R_CRIS_GNU_VTENTRY 8 +#define R_CRIS_COPY 9 +#define R_CRIS_GLOB_DAT 10 +#define R_CRIS_JUMP_SLOT 11 +#define R_CRIS_RELATIVE 12 +#define R_CRIS_16_GOT 13 +#define R_CRIS_32_GOT 14 +#define R_CRIS_16_GOTPLT 15 +#define R_CRIS_32_GOTPLT 16 +#define R_CRIS_32_GOTREL 17 +#define R_CRIS_32_PLT_GOTREL 18 +#define R_CRIS_32_PLT_PCREL 19 + +/* Keep this the last entry. */ +#define R_CRIS_NUM 20 + + +/* AMD x86-64 relocations. */ +#define R_X86_64_NONE 0 /* No reloc */ +#define R_X86_64_64 1 /* Direct 64 bit */ +#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ +#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ +#define R_X86_64_PLT32 4 /* 32 bit PLT address */ +#define R_X86_64_COPY 5 /* Copy symbol at runtime */ +#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ +#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ +#define R_X86_64_RELATIVE 8 /* Adjust by program base */ +#define R_X86_64_GOTPCREL 9 /* 32 bit signed PC relative + offset to GOT */ +#define R_X86_64_32 10 /* Direct 32 bit zero extended */ +#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ +#define R_X86_64_16 12 /* Direct 16 bit zero extended */ +#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ +#define R_X86_64_8 14 /* Direct 8 bit sign extended */ +#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ +#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */ +#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */ +#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */ +#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset + to two GOT entries for GD symbol */ +#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset + to two GOT entries for LD symbol */ +#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */ +#define R_X86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset + to GOT entry for IE symbol */ +#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */ + +#define R_X86_64_NUM 24 + + +/* AM33 relocations. */ +#define R_MN10300_NONE 0 /* No reloc. */ +#define R_MN10300_32 1 /* Direct 32 bit. */ +#define R_MN10300_16 2 /* Direct 16 bit. */ +#define R_MN10300_8 3 /* Direct 8 bit. */ +#define R_MN10300_PCREL32 4 /* PC-relative 32-bit. */ +#define R_MN10300_PCREL16 5 /* PC-relative 16-bit signed. */ +#define R_MN10300_PCREL8 6 /* PC-relative 8-bit signed. */ +#define R_MN10300_GNU_VTINHERIT 7 /* Ancient C++ vtable garbage... */ +#define R_MN10300_GNU_VTENTRY 8 /* ... collection annotation. */ +#define R_MN10300_24 9 /* Direct 24 bit. */ +#define R_MN10300_GOTPC32 10 /* 32-bit PCrel offset to GOT. */ +#define R_MN10300_GOTPC16 11 /* 16-bit PCrel offset to GOT. */ +#define R_MN10300_GOTOFF32 12 /* 32-bit offset from GOT. */ +#define R_MN10300_GOTOFF24 13 /* 24-bit offset from GOT. */ +#define R_MN10300_GOTOFF16 14 /* 16-bit offset from GOT. */ +#define R_MN10300_PLT32 15 /* 32-bit PCrel to PLT entry. */ +#define R_MN10300_PLT16 16 /* 16-bit PCrel to PLT entry. */ +#define R_MN10300_GOT32 17 /* 32-bit offset to GOT entry. */ +#define R_MN10300_GOT24 18 /* 24-bit offset to GOT entry. */ +#define R_MN10300_GOT16 19 /* 16-bit offset to GOT entry. */ +#define R_MN10300_COPY 20 /* Copy symbol at runtime. */ +#define R_MN10300_GLOB_DAT 21 /* Create GOT entry. */ +#define R_MN10300_JMP_SLOT 22 /* Create PLT entry. */ +#define R_MN10300_RELATIVE 23 /* Adjust by program base. */ + +#define R_MN10300_NUM 24 + + +/* M32R relocs. */ +#define R_M32R_NONE 0 /* No reloc. */ +#define R_M32R_16 1 /* Direct 16 bit. */ +#define R_M32R_32 2 /* Direct 32 bit. */ +#define R_M32R_24 3 /* Direct 24 bit. */ +#define R_M32R_10_PCREL 4 /* PC relative 10 bit shifted. */ +#define R_M32R_18_PCREL 5 /* PC relative 18 bit shifted. */ +#define R_M32R_26_PCREL 6 /* PC relative 26 bit shifted. */ +#define R_M32R_HI16_ULO 7 /* High 16 bit with unsigned low. */ +#define R_M32R_HI16_SLO 8 /* High 16 bit with signed low. */ +#define R_M32R_LO16 9 /* Low 16 bit. */ +#define R_M32R_SDA16 10 /* 16 bit offset in SDA. */ +#define R_M32R_GNU_VTINHERIT 11 +#define R_M32R_GNU_VTENTRY 12 +/* M32R relocs use SHT_RELA. */ +#define R_M32R_16_RELA 33 /* Direct 16 bit. */ +#define R_M32R_32_RELA 34 /* Direct 32 bit. */ +#define R_M32R_24_RELA 35 /* Direct 24 bit. */ +#define R_M32R_10_PCREL_RELA 36 /* PC relative 10 bit shifted. */ +#define R_M32R_18_PCREL_RELA 37 /* PC relative 18 bit shifted. */ +#define R_M32R_26_PCREL_RELA 38 /* PC relative 26 bit shifted. */ +#define R_M32R_HI16_ULO_RELA 39 /* High 16 bit with unsigned low */ +#define R_M32R_HI16_SLO_RELA 40 /* High 16 bit with signed low */ +#define R_M32R_LO16_RELA 41 /* Low 16 bit */ +#define R_M32R_SDA16_RELA 42 /* 16 bit offset in SDA */ +#define R_M32R_RELA_GNU_VTINHERIT 43 +#define R_M32R_RELA_GNU_VTENTRY 44 + +#define R_M32R_GOT24 48 /* 24 bit GOT entry */ +#define R_M32R_26_PLTREL 49 /* 26 bit PC relative to PLT shifted */ +#define R_M32R_COPY 50 /* Copy symbol at runtime */ +#define R_M32R_GLOB_DAT 51 /* Create GOT entry */ +#define R_M32R_JMP_SLOT 52 /* Create PLT entry */ +#define R_M32R_RELATIVE 53 /* Adjust by program base */ +#define R_M32R_GOTOFF 54 /* 24 bit offset to GOT */ +#define R_M32R_GOTPC24 55 /* 24 bit PC relative offset to GOT */ +#define R_M32R_GOT16_HI_ULO 56 /* High 16 bit GOT entry with unsigned + low */ +#define R_M32R_GOT16_HI_SLO 57 /* High 16 bit GOT entry with signed + low */ +#define R_M32R_GOT16_LO 58 /* Low 16 bit GOT entry */ +#define R_M32R_GOTPC_HI_ULO 59 /* High 16 bit PC relative offset to + GOT with unsigned low */ +#define R_M32R_GOTPC_HI_SLO 60 /* High 16 bit PC relative offset to + GOT with signed low */ +#define R_M32R_GOTPC_LO 61 /* Low 16 bit PC relative offset to + GOT */ +#define R_M32R_GOTOFF_HI_ULO 62 /* High 16 bit offset to GOT + with unsigned low */ +#define R_M32R_GOTOFF_HI_SLO 63 /* High 16 bit offset to GOT + with signed low */ +#define R_M32R_GOTOFF_LO 64 /* Low 16 bit offset to GOT */ +#define R_M32R_NUM 256 /* Keep this the last entry. */ + +/* i960 Relocations */ +#define R_960_NONE 0 +#define R_960_12 1 +#define R_960_32 2 +#define R_960_IP24 3 +#define R_960_SUB 4 +#define R_960_OPTCALL 5 +#define R_960_OPTCALLX 6 +#define R_960_OPTCALLXA 7 +/* Keep this the last entry. */ +#define R_960_NUM 8 + + +/* v850 relocations. */ +#define R_V850_NONE 0 +#define R_V850_9_PCREL 1 +#define R_V850_22_PCREL 2 +#define R_V850_HI16_S 3 +#define R_V850_HI16 4 +#define R_V850_LO16 5 +#define R_V850_32 6 +#define R_V850_16 7 +#define R_V850_8 8 +#define R_V850_SDA_16_16_OFFSET 9 /* For ld.b, st.b, set1, clr1, + not1, tst1, movea, movhi */ +#define R_V850_SDA_15_16_OFFSET 10 /* For ld.w, ld.h, ld.hu, st.w, st.h */ +#define R_V850_ZDA_16_16_OFFSET 11 /* For ld.b, st.b, set1, clr1, + not1, tst1, movea, movhi */ +#define R_V850_ZDA_15_16_OFFSET 12 /* For ld.w, ld.h, ld.hu, st.w, st.h */ +#define R_V850_TDA_6_8_OFFSET 13 /* For sst.w, sld.w */ +#define R_V850_TDA_7_8_OFFSET 14 /* For sst.h, sld.h */ +#define R_V850_TDA_7_7_OFFSET 15 /* For sst.b, sld.b */ +#define R_V850_TDA_16_16_OFFSET 16 /* For set1, clr1, not1, tst1, + movea, movhi */ +/* CYGNUS LOCAL v850e */ +#define R_V850_TDA_4_5_OFFSET 17 /* For sld.hu */ +#define R_V850_TDA_4_4_OFFSET 18 /* For sld.bu */ +#define R_V850_SDA_16_16_SPLIT_OFFSET 19 /* For ld.bu */ +#define R_V850_ZDA_16_16_SPLIT_OFFSET 20 /* For ld.bu */ +#define R_V850_CALLT_6_7_OFFSET 21 /* For callt */ +#define R_V850_CALLT_16_16_OFFSET 22 /* For callt */ +/* END CYGNUS LOCAL */ +#define R_V850_GNU_VTINHERIT 23 +#define R_V850_GNU_VTENTRY 24 +/* Keep this the last entry. */ +#define R_V850_NUM 25 + +/* Atmel AVR32 relocations. */ +#define R_AVR32_NONE 0 +#define R_AVR32_32 1 +#define R_AVR32_16 2 +#define R_AVR32_8 3 +#define R_AVR32_32_PCREL 4 +#define R_AVR32_16_PCREL 5 +#define R_AVR32_8_PCREL 6 +#define R_AVR32_DIFF32 7 +#define R_AVR32_DIFF16 8 +#define R_AVR32_DIFF8 9 +#define R_AVR32_GOT32 10 +#define R_AVR32_GOT16 11 +#define R_AVR32_GOT8 12 +#define R_AVR32_21S 13 +#define R_AVR32_16U 14 +#define R_AVR32_16S 15 +#define R_AVR32_8S 16 +#define R_AVR32_8S_EXT 17 +#define R_AVR32_22H_PCREL 18 +#define R_AVR32_18W_PCREL 19 +#define R_AVR32_16B_PCREL 20 +#define R_AVR32_16N_PCREL 21 +#define R_AVR32_14UW_PCREL 22 +#define R_AVR32_11H_PCREL 23 +#define R_AVR32_10UW_PCREL 24 +#define R_AVR32_9H_PCREL 25 +#define R_AVR32_9UW_PCREL 26 +#define R_AVR32_HI16 27 +#define R_AVR32_LO16 28 +#define R_AVR32_GOTPC 29 +#define R_AVR32_GOTCALL 30 +#define R_AVR32_LDA_GOT 31 +#define R_AVR32_GOT21S 32 +#define R_AVR32_GOT18SW 33 +#define R_AVR32_GOT16S 34 +#define R_AVR32_GOT7UW 35 +#define R_AVR32_32_CPENT 36 +#define R_AVR32_CPCALL 37 +#define R_AVR32_16_CP 38 +#define R_AVR32_9W_CP 39 +#define R_AVR32_RELATIVE 40 +#define R_AVR32_GLOB_DAT 41 +#define R_AVR32_JMP_SLOT 42 +#define R_AVR32_ALIGN 43 +#define R_AVR32_NUM 44 + +/* AVR32 dynamic tags */ +#define DT_AVR32_GOTSZ 0x70000001 /* Total size of GOT in bytes */ + +/* Renesas H8/300 Relocations */ +#define R_H8_NONE 0 +#define R_H8_DIR32 1 +#define R_H8_DIR32_28 2 +#define R_H8_DIR32_24 3 +#define R_H8_DIR32_16 4 +#define R_H8_DIR32U 6 +#define R_H8_DIR32U_28 7 +#define R_H8_DIR32U_24 8 +#define R_H8_DIR32U_20 9 +#define R_H8_DIR32U_16 10 +#define R_H8_DIR24 11 +#define R_H8_DIR24_20 12 +#define R_H8_DIR24_16 13 +#define R_H8_DIR24U 14 +#define R_H8_DIR24U_20 15 +#define R_H8_DIR24U_16 16 +#define R_H8_DIR16 17 +#define R_H8_DIR16U 18 +#define R_H8_DIR16S_32 19 +#define R_H8_DIR16S_28 20 +#define R_H8_DIR16S_24 21 +#define R_H8_DIR16S_20 22 +#define R_H8_DIR16S 23 +#define R_H8_DIR8 24 +#define R_H8_DIR8U 25 +#define R_H8_DIR8Z_32 26 +#define R_H8_DIR8Z_28 27 +#define R_H8_DIR8Z_24 28 +#define R_H8_DIR8Z_20 29 +#define R_H8_DIR8Z_16 30 +#define R_H8_PCREL16 31 +#define R_H8_PCREL8 32 +#define R_H8_BPOS 33 +#define R_H8_PCREL32 34 +#define R_H8_GOT32O 35 +#define R_H8_GOT16O 36 +#define R_H8_DIR16A8 59 +#define R_H8_DIR16R8 60 +#define R_H8_DIR24A8 61 +#define R_H8_DIR24R8 62 +#define R_H8_DIR32A16 63 +#define R_H8_ABS32 65 +#define R_H8_ABS32A16 127 +#define R_H8_NUM 128 + +/* NIOS relocations. */ +#define R_NIOS_NONE 0 +#define R_NIOS_32 1 /* A 32 bit absolute relocation.*/ +#define R_NIOS_LO16_LO5 2 /* A LO-16 5 bit absolute relocation. */ +#define R_NIOS_LO16_HI11 3 /* A LO-16 top 11 bit absolute relocation. */ +#define R_NIOS_HI16_LO5 4 /* A HI-16 5 bit absolute relocation. */ +#define R_NIOS_HI16_HI11 5 /* A HI-16 top 11 bit absolute relocation. */ +#define R_NIOS_PCREL6 6 /* A 6 bit relative relocation. */ +#define R_NIOS_PCREL8 7 /* An 8 bit relative relocation. */ +#define R_NIOS_PCREL11 8 /* An 11 bit relative relocation. */ +#define R_NIOS_16 9 /* A 16 bit absolute relocation. */ +#define R_NIOS_H_LO5 10 /* Low 5-bits of absolute relocation in halfwords. */ +#define R_NIOS_H_HI11 11 /* Top 11 bits of 16-bit absolute relocation in halfwords. */ +#define R_NIOS_H_XLO5 12 /* Low 5 bits of top 16-bits of 32-bit absolute relocation in halfwords. */ +#define R_NIOS_H_XHI11 13 /* Top 11 bits of top 16-bits of 32-bit absolute relocation in halfwords. */ +#define R_NIOS_H_16 14 /* Half-word @h value */ +#define R_NIOS_H_32 15 /* Word @h value */ +#define R_NIOS_GNU_VTINHERIT 200 /* GNU extension to record C++ vtable hierarchy */ +#define R_NIOS_GNU_VTENTRY 201 /* GNU extension to record C++ vtable member usage */ +/* Keep this the last entry. */ +#define R_NIOS_NUM 202 + +/* NIOS II relocations */ +#define R_NIOS2_NONE 0 +#define R_NIOS2_S16 1 +#define R_NIOS2_U16 2 +#define R_NIOS2_PCREL16 3 +#define R_NIOS2_CALL26 4 +#define R_NIOS2_IMM5 5 +#define R_NIOS2_CACHE_OPX 6 +#define R_NIOS2_IMM6 7 +#define R_NIOS2_IMM8 8 +#define R_NIOS2_HI16 9 +#define R_NIOS2_LO16 10 +#define R_NIOS2_HIADJ16 11 +#define R_NIOS2_BFD_RELOC_32 12 +#define R_NIOS2_BFD_RELOC_16 13 +#define R_NIOS2_BFD_RELOC_8 14 +#define R_NIOS2_GPREL 15 +#define R_NIOS2_GNU_VTINHERIT 16 +#define R_NIOS2_GNU_VTENTRY 17 +#define R_NIOS2_UJMP 18 +#define R_NIOS2_CJMP 19 +#define R_NIOS2_CALLR 20 +#define R_NIOS2_ALIGN 21 +/* Keep this the last entry. */ +#define R_NIOS2_NUM 22 + +__END_DECLS + +#endif /* elf.h */ diff --git a/conts/posix/libposix/include/posix/endian.h b/conts/posix/libposix/include/posix/endian.h new file mode 100644 index 0000000..2f7bce1 --- /dev/null +++ b/conts/posix/libposix/include/posix/endian.h @@ -0,0 +1,58 @@ +/* Copyright (C) 1992, 1996, 1997, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _ENDIAN_H +#define _ENDIAN_H 1 + +#include + +/* Definitions for byte order, according to significance of bytes, + from low addresses to high addresses. The value is what you get by + putting '4' in the most significant byte, '3' in the second most + significant byte, '2' in the second least significant byte, and '1' + in the least significant byte, and then writing down one digit for + each byte, starting with the byte at the lowest address at the left, + and proceeding to the byte with the highest address at the right. */ + +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __PDP_ENDIAN 3412 + +/* This file defines `__BYTE_ORDER' for the particular machine. */ +#include + +/* Some machines may need to use a different endianness for floating point + values. */ +#ifndef __FLOAT_WORD_ORDER +# define __FLOAT_WORD_ORDER __BYTE_ORDER +#endif + +#ifdef __USE_BSD +# define LITTLE_ENDIAN __LITTLE_ENDIAN +# define BIG_ENDIAN __BIG_ENDIAN +# define PDP_ENDIAN __PDP_ENDIAN +# define BYTE_ORDER __BYTE_ORDER +#endif + +#if __BYTE_ORDER == __LITTLE_ENDIAN +# define __LONG_LONG_PAIR(HI, LO) LO, HI +#elif __BYTE_ORDER == __BIG_ENDIAN +# define __LONG_LONG_PAIR(HI, LO) HI, LO +#endif + +#endif /* endian.h */ diff --git a/conts/posix/libposix/include/posix/err.h b/conts/posix/libposix/include/posix/err.h new file mode 100644 index 0000000..7ff3553 --- /dev/null +++ b/conts/posix/libposix/include/posix/err.h @@ -0,0 +1,58 @@ +/* 4.4BSD utility functions for error messages. + Copyright (C) 1995,1996,1997,1998,1999,2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _ERR_H +#define _ERR_H 1 + +#include + +#define __need___va_list +#include +#ifndef __GNUC_VA_LIST +# define __gnuc_va_list __ptr_t +#endif + +__BEGIN_DECLS + +/* Print "program: ", FORMAT, ": ", the standard error string for errno, + and a newline, on stderr. */ +extern void warn (__const char *__format, ...) + __attribute__ ((__format__ (__printf__, 1, 2))); +extern void vwarn (__const char *__format, __gnuc_va_list) + __attribute__ ((__format__ (__printf__, 1, 0))); + +/* Likewise, but without ": " and the standard error string. */ +extern void warnx (__const char *__format, ...) + __attribute__ ((__format__ (__printf__, 1, 2))); +extern void vwarnx (__const char *__format, __gnuc_va_list) + __attribute__ ((__format__ (__printf__, 1, 0))); + +/* Likewise, and then exit with STATUS. */ +extern void err (int __status, __const char *__format, ...) + __attribute__ ((__noreturn__, __format__ (__printf__, 2, 3))); +extern void verr (int __status, __const char *__format, __gnuc_va_list) + __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0))); +extern void errx (int __status, __const char *__format, ...) + __attribute__ ((__noreturn__, __format__ (__printf__, 2, 3))); +extern void verrx (int __status, __const char *, __gnuc_va_list) + __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0))); + +__END_DECLS + +#endif /* err.h */ diff --git a/conts/posix/libposix/include/posix/errno.h b/conts/posix/libposix/include/posix/errno.h new file mode 100644 index 0000000..aef117e --- /dev/null +++ b/conts/posix/libposix/include/posix/errno.h @@ -0,0 +1,77 @@ +/* Copyright (C) 1991,92,93,94,95,96,97,2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard: 7.5 Errors + */ + +#ifndef _ERRNO_H + +/* The includer defined __need_Emath if he wants only the definitions + of EDOM and ERANGE, and not everything else. */ +#ifndef __need_Emath +# define _ERRNO_H 1 +# include +#endif + +__BEGIN_DECLS + +/* Get the error number constants from the system-specific file. + This file will test __need_Emath and _ERRNO_H. */ +#include +#undef __need_Emath + +#ifdef _ERRNO_H + +/* Declare the `errno' variable, unless it's defined as a macro by + bits/errno.h. This is the case in GNU, where it is a per-thread + variable. This redeclaration using the macro still works, but it + will be a function declaration without a prototype and may trigger + a -Wstrict-prototypes warning. */ +#ifndef errno +extern int errno; +#endif + +#if defined __USE_GNU && defined __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__ + +/* The full and simple forms of the name with which the program was + invoked. These variables are set up automatically at startup based on + the value of ARGV[0] (this works only if you use GNU ld). */ +extern char *program_invocation_name, *program_invocation_short_name; +#endif /* __USE_GNU */ +#endif /* _ERRNO_H */ + +__END_DECLS + +#if defined _LIBC && ( defined IS_IN_libc || defined NOT_IN_libc ) +#include +#endif + +#endif /* _ERRNO_H */ + +/* The Hurd defines `error_t' as an enumerated type so + that printing `error_t' values in the debugger shows the names. We + might need this definition sometimes even if this file was included + before. */ +#if defined __USE_GNU || defined __need_error_t +# ifndef __error_t_defined +typedef int error_t; +# define __error_t_defined 1 +# endif +# undef __need_error_t +#endif diff --git a/conts/posix/libposix/include/posix/error.h b/conts/posix/libposix/include/posix/error.h new file mode 100644 index 0000000..b553cae --- /dev/null +++ b/conts/posix/libposix/include/posix/error.h @@ -0,0 +1,52 @@ +/* Declaration for error-reporting function + Copyright (C) 1995, 1996, 1997, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _ERROR_H +#define _ERROR_H 1 + +#include + +__BEGIN_DECLS + +/* Print a message with `fprintf (stderr, FORMAT, ...)'; + if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). + If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ + +extern void error (int __status, int __errnum, const char *__format, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); + +extern void error_at_line (int __status, int __errnum, const char *__fname, + unsigned int __lineno, const char *__format, ...) + __attribute__ ((__format__ (__printf__, 5, 6))); + +/* If NULL, error will flush stdout, then print on stderr the program + name, a colon and a space. Otherwise, error will call this + function without parameters instead. */ +extern void (*error_print_progname) (void); + +/* This variable is incremented each time `error' is called. */ +extern unsigned int error_message_count; + +/* Sometimes we want to have at most one error per line. This + variable controls whether this mode is selected or not. */ +extern int error_one_per_line; + +__END_DECLS + +#endif /* error.h */ diff --git a/conts/posix/libposix/include/posix/fcntl.h b/conts/posix/libposix/include/posix/fcntl.h new file mode 100644 index 0000000..a438902 --- /dev/null +++ b/conts/posix/libposix/include/posix/fcntl.h @@ -0,0 +1,228 @@ +/* Copyright (C) 1991,1992,1994-2001,2003,2004,2005 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * POSIX Standard: 6.5 File Control Operations + */ + +#ifndef _FCNTL_H +#define _FCNTL_H 1 + +#include + +/* This must be early so can define types winningly. */ +__BEGIN_DECLS + +/* Get the definitions of O_*, F_*, FD_*: all the + numbers and flag bits for `open', `fcntl', et al. */ +#include + +/* For XPG all symbols from should also be available. */ +#ifdef __USE_XOPEN +# include +#endif + +#ifdef __USE_MISC +# ifndef R_OK /* Verbatim from . Ugh. */ +/* Values for the second argument to access. + These may be OR'd together. */ +# define R_OK 4 /* Test for read permission. */ +# define W_OK 2 /* Test for write permission. */ +# define X_OK 1 /* Test for execute permission. */ +# define F_OK 0 /* Test for existence. */ +# endif +#endif /* Use misc. */ + +/* XPG wants the following symbols. */ +#ifdef __USE_XOPEN /* has the same definitions. */ +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Seek from end of file. */ +#endif /* XPG */ + +#if 0 /*def __USE_GNU*/ +# define AT_FDCWD -100 /* Special value used to indicate + openat should use the current + working directory. */ +# define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */ +# define AT_REMOVEDIR 0x200 /* Remove directory instead of + unlinking file. */ +#endif + +/* Do the file control operation described by CMD on FD. + The remaining arguments are interpreted depending on CMD. + + This function is a cancellation point and therefore not marked with + __THROW. */ +#ifndef __USE_FILE_OFFSET64 +extern int fcntl (int __fd, int __cmd, ...); +#else +# ifdef __REDIRECT +extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64); +# else +# define fcntl fcntl64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern int fcntl64 (int __fd, int __cmd, ...); +#endif + +/* Open FILE and return a new file descriptor for it, or -1 on error. + OFLAG determines the type of access used. If O_CREAT is on OFLAG, + the third argument is taken as a `mode_t', the mode of the created file. + + This function is a cancellation point and therefore not marked with + __THROW. */ +#ifndef __USE_FILE_OFFSET64 +extern int open (__const char *__file, int __oflag, ...) __nonnull ((1)); +#else +# ifdef __REDIRECT +extern int __REDIRECT (open, (__const char *__file, int __oflag, ...), open64) + __nonnull ((1)); +# else +# define open open64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern int open64 (__const char *__file, int __oflag, ...) __nonnull ((1)); +#endif + +#if 0 /*def __USE_GNU*/ +/* Similar to OPEN but a relative path name is interpreted relative to + the directory for which FD is a descriptor. + + NOTE: some other OPENAT implementation support additional functionality + through this interface, especially using the O_XATTR flag. This is not + yet supported here. + + This function is a cancellation point and therefore not marked with + __THROW. */ +# ifndef __USE_FILE_OFFSET64 +extern int openat (int __fd, __const char *__file, int __oflag, ...) + __nonnull ((2)); +# else +# ifdef __REDIRECT +extern int __REDIRECT (openat, (int __fd, __const char *__file, int __oflag, + ...), openat64) __nonnull ((2)); +# else +# define openat openat64 +# endif +# endif + +extern int openat64 (int __fd, __const char *__file, int __oflag, ...) + __nonnull ((2)); +#endif + +/* Create and open FILE, with mode MODE. This takes an `int' MODE + argument because that is what `mode_t' will be widened to. + + This function is a cancellation point and therefore not marked with + __THROW. */ +#ifndef __USE_FILE_OFFSET64 +extern int creat (__const char *__file, __mode_t __mode) __nonnull ((1)); +#else +# ifdef __REDIRECT +extern int __REDIRECT (creat, (__const char *__file, __mode_t __mode), + creat64) __nonnull ((1)); +# else +# define creat creat64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern int creat64 (__const char *__file, __mode_t __mode) __nonnull ((1)); +#endif + +#if !defined F_LOCK && (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \ + && !defined __USE_POSIX)) +/* NOTE: These declarations also appear in ; be sure to keep both + files consistent. Some systems have them there and some here, and some + software depends on the macros being defined without including both. */ + +/* `lockf' is a simpler interface to the locking facilities of `fcntl'. + LEN is always relative to the current file position. + The CMD argument is one of the following. */ + +# define F_ULOCK 0 /* Unlock a previously locked region. */ +# define F_LOCK 1 /* Lock a region for exclusive use. */ +# define F_TLOCK 2 /* Test and lock a region for exclusive use. */ +# define F_TEST 3 /* Test a region for other processes locks. */ + +# ifndef __USE_FILE_OFFSET64 +extern int lockf (int __fd, int __cmd, __off_t __len); +# else +# ifdef __REDIRECT +extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), lockf64); +# else +# define lockf lockf64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int lockf64 (int __fd, int __cmd, __off64_t __len); +# endif +#endif + +#ifdef __USE_XOPEN2K +/* Advice the system about the expected behaviour of the application with + respect to the file associated with FD. */ +# ifndef __USE_FILE_OFFSET64 +extern int posix_fadvise (int __fd, __off_t __offset, __off_t __len, + int __advise) __THROW; +# else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (posix_fadvise, (int __fd, __off64_t __offset, + __off64_t __len, int __advise), + posix_fadvise64); +# else +# define posix_fadvise posix_fadvise64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int posix_fadvise64 (int __fd, __off64_t __offset, __off64_t __len, + int __advise) __THROW; +# endif + +#endif + +#if 0 + +/* FIXME -- uClibc should probably implement these... */ + +/* Reserve storage for the data of the file associated with FD. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +# ifndef __USE_FILE_OFFSET64 +extern int posix_fallocate (int __fd, __off_t __offset, __off_t __len); +# else +# ifdef __REDIRECT +extern int __REDIRECT (posix_fallocate, (int __fd, __off64_t __offset, + __off64_t __len), + posix_fallocate64); +# else +# define posix_fallocate posix_fallocate64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int posix_fallocate64 (int __fd, __off64_t __offset, __off64_t __len); +# endif +#endif + +__END_DECLS + +#endif /* fcntl.h */ diff --git a/conts/posix/libposix/include/posix/features.h b/conts/posix/libposix/include/posix/features.h new file mode 100644 index 0000000..aab3b7c --- /dev/null +++ b/conts/posix/libposix/include/posix/features.h @@ -0,0 +1,424 @@ +/* Copyright (C) 1991-1993,1995-2003,2004,2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _FEATURES_H +#define _FEATURES_H 1 + +/* This macro indicates that the installed library is uClibc. Use + * __UCLIBC_MAJOR__ and __UCLIBC_MINOR__ to test for the features in + * specific releases. */ +#define __UCLIBC__ 1 + +/* Load up the current set of uClibc supported features along + * with the current uClibc major and minor version numbers. + * For uClibc release 0.9.26, these numbers would be: + * #define __UCLIBC_MAJOR__ 0 + * #define __UCLIBC_MINOR__ 9 + * #define __UCLIBC_SUBLEVEL__ 26 + */ +#define __need_uClibc_config_h +#include +#undef __need_uClibc_config_h +#include + +/* For uClibc, always optimize for size -- this should disable + * a lot of expensive inlining... */ +#define __OPTIMIZE_SIZE__ 1 + +/* These are defined by the user (or the compiler) + to specify the desired environment: + + __STRICT_ANSI__ ISO Standard C. + _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. + _POSIX_SOURCE IEEE Std 1003.1. + _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; + if >=199309L, add IEEE Std 1003.1b-1993; + if >=199506L, add IEEE Std 1003.1c-1995; + if >=200112L, all of IEEE 1003.1-2004 + _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if + Single Unix conformance is wanted, to 600 for the + upcoming sixth revision. + _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. + _LARGEFILE_SOURCE Some more functions for correct standard I/O. + _LARGEFILE64_SOURCE Additional functionality from LFS for large files. + _FILE_OFFSET_BITS=N Select default filesystem interface. + _BSD_SOURCE ISO C, POSIX, and 4.3BSD things. + _SVID_SOURCE ISO C, POSIX, and SVID things. + _ATFILE_SOURCE Additional *at interfaces. + _GNU_SOURCE All of the above, plus GNU extensions. + _REENTRANT Select additionally reentrant object. + _THREAD_SAFE Same as _REENTRANT, often used by other systems. + _FORTIFY_SOURCE If set to numeric value > 0 additional security + measures are defined, according to level. + + The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__. + If none of these are defined, the default is to have _SVID_SOURCE, + _BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to + 199506L. If more than one of these are defined, they accumulate. + For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE + together give you ISO C, 1003.1, and 1003.2, but nothing else. + + These are defined by this file and are used by the + header files to decide what to declare or define: + + __USE_ISOC99 Define ISO C99 things. + __USE_POSIX Define IEEE Std 1003.1 things. + __USE_POSIX2 Define IEEE Std 1003.2 things. + __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. + __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. + __USE_XOPEN Define XPG things. + __USE_XOPEN_EXTENDED Define X/Open Unix things. + __USE_UNIX98 Define Single Unix V2 things. + __USE_XOPEN2K Define XPG6 things. + __USE_LARGEFILE Define correct standard I/O things. + __USE_LARGEFILE64 Define LFS things with separate names. + __USE_FILE_OFFSET64 Define 64bit interface as default. + __USE_BSD Define 4.3BSD things. + __USE_SVID Define SVID things. + __USE_MISC Define things common to BSD and System V Unix. + __USE_ATFILE Define *at interfaces and AT_* constants for them. + __USE_GNU Define GNU extensions. + __USE_REENTRANT Define reentrant/thread-safe *_r functions. + __USE_FORTIFY_LEVEL Additional security measures used, according to level. + __FAVOR_BSD Favor 4.3BSD things in cases of conflict. + + The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are + defined by this file unconditionally. `__GNU_LIBRARY__' is provided + only for compatibility. All new code should use the other symbols + to test for features. + + All macros listed above as possibly being defined by this file are + explicitly undefined if they are not explicitly defined. + Feature-test macros that are not defined by the user or compiler + but are implied by the other feature-test macros defined (or by the + lack of any definitions) are defined by the file. */ + + +/* Undefine everything, so we get a clean slate. */ +#undef __USE_ISOC99 +#undef __USE_POSIX +#undef __USE_POSIX2 +#undef __USE_POSIX199309 +#undef __USE_POSIX199506 +#undef __USE_XOPEN +#undef __USE_XOPEN_EXTENDED +#undef __USE_UNIX98 +#undef __USE_XOPEN2K +#undef __USE_LARGEFILE +#undef __USE_LARGEFILE64 +#undef __USE_FILE_OFFSET64 +#undef __USE_BSD +#undef __USE_SVID +#undef __USE_MISC +#undef __USE_ATFILE +#undef __USE_GNU +#undef __USE_REENTRANT +#undef __USE_FORTIFY_LEVEL +#undef __FAVOR_BSD +#undef __KERNEL_STRICT_NAMES + +/* Suppress kernel-name space pollution unless user expressedly asks + for it. */ +#ifndef _LOOSE_KERNEL_NAMES +# define __KERNEL_STRICT_NAMES +#endif + +/* Always use ISO C things. */ +#define __USE_ANSI 1 + +/* Convenience macros to test the versions of glibc and gcc. + Use them like this: + #if __GNUC_PREREQ(2,8) + ... code requiring gcc 2.8 or later ... + #endif + Note - they won't work for gcc1 or glibc1, since the _MINOR macros + were not defined then. */ +#if defined __GNUC__ && defined __GNUC_MINOR__ +# define __GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define __GNUC_PREREQ(maj, min) 0 +#endif + + +/* If _BSD_SOURCE was defined by the user, favor BSD over POSIX. */ +#if defined _BSD_SOURCE && \ + !(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \ + defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \ + defined _GNU_SOURCE || defined _SVID_SOURCE) +# define __FAVOR_BSD 1 +#endif + +/* If _GNU_SOURCE was defined by the user, turn on all the other features. */ +#ifdef _GNU_SOURCE +# undef _ISOC99_SOURCE +# define _ISOC99_SOURCE 1 +# undef _POSIX_SOURCE +# define _POSIX_SOURCE 1 +# undef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 199506L +# undef _XOPEN_SOURCE +# define _XOPEN_SOURCE 600 +# undef _XOPEN_SOURCE_EXTENDED +# define _XOPEN_SOURCE_EXTENDED 1 +# ifdef __UCLIBC_HAS_LFS__ +# undef _LARGEFILE64_SOURCE +# define _LARGEFILE64_SOURCE 1 +# endif /* __UCLIBC_HAS_LFS__ */ +# undef _BSD_SOURCE +# define _BSD_SOURCE 1 +# undef _SVID_SOURCE +# define _SVID_SOURCE 1 +# undef _ATFILE_SOURCE +# define _ATFILE_SOURCE 1 +#endif + +/* If nothing (other than _GNU_SOURCE) is defined, + define _BSD_SOURCE and _SVID_SOURCE. */ +#if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \ + !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \ + !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \ + !defined _BSD_SOURCE && !defined _SVID_SOURCE) +# define _BSD_SOURCE 1 +# define _SVID_SOURCE 1 +#endif + +/* This is to enable the ISO C99 extension. Also recognize the old macro + which was used prior to the standard acceptance. This macro will + eventually go away and the features enabled by default once the ISO C99 + standard is widely adopted. */ +#if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) +# define __USE_ISOC99 1 +#endif + +/* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2 + (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */ +#if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \ + !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE) +# define _POSIX_SOURCE 1 +# if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500 +# define _POSIX_C_SOURCE 2 +# else +# define _POSIX_C_SOURCE 199506L +# endif +#endif + +#if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE +# define __USE_POSIX 1 +#endif + +#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE +# define __USE_POSIX2 1 +#endif + +#if (_POSIX_C_SOURCE - 0) >= 199309L +# define __USE_POSIX199309 1 +#endif + +#if (_POSIX_C_SOURCE - 0) >= 199506L +# define __USE_POSIX199506 1 +#endif + +#if (_POSIX_C_SOURCE - 0) >= 200112L +# define __USE_XOPEN2K 1 +#endif + +#ifdef _XOPEN_SOURCE +# define __USE_XOPEN 1 +# if (_XOPEN_SOURCE - 0) >= 500 +# define __USE_XOPEN_EXTENDED 1 +# define __USE_UNIX98 1 +# undef _LARGEFILE_SOURCE +# define _LARGEFILE_SOURCE 1 +# if (_XOPEN_SOURCE - 0) >= 600 +# define __USE_XOPEN2K 1 +# undef __USE_ISOC99 +# define __USE_ISOC99 1 +# endif +# else +# ifdef _XOPEN_SOURCE_EXTENDED +# define __USE_XOPEN_EXTENDED 1 +# endif +# endif +#endif + +#ifdef _LARGEFILE_SOURCE +# define __USE_LARGEFILE 1 +#endif + +#ifdef _LARGEFILE64_SOURCE +# define __USE_LARGEFILE64 1 +#endif + +#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 +# define __USE_FILE_OFFSET64 1 +#endif + +#if defined _BSD_SOURCE || defined _SVID_SOURCE +# define __USE_MISC 1 +#endif + +#ifdef _BSD_SOURCE +# define __USE_BSD 1 +#endif + +#ifdef _SVID_SOURCE +# define __USE_SVID 1 +#endif + +#ifdef _ATFILE_SOURCE +# define __USE_ATFILE 1 +#endif + +#ifdef _GNU_SOURCE +# define __USE_GNU 1 +#endif + +#if defined _REENTRANT || defined _THREAD_SAFE +# define __USE_REENTRANT 1 +#endif + +/* uClibc does not support _FORTIFY_SOURCE */ +#undef _FORTIFY_SOURCE +#if defined _FORTIFY_SOURCE && _FORTIFY_SOURCE > 0 \ + && __GNUC_PREREQ(4, 1) && defined __OPTIMIZE__ && __OPTIMIZE__ > 0 +# if _FORTIFY_SOURCE > 1 +# define __USE_FORTIFY_LEVEL 2 +# else +# define __USE_FORTIFY_LEVEL 1 +# endif +#else +# define __USE_FORTIFY_LEVEL 0 +#endif + +/* We do support the IEC 559 math functionality, real and complex. */ +#define __STDC_IEC_559__ 1 +#define __STDC_IEC_559_COMPLEX__ 1 + +#ifdef __UCLIBC_HAS_WCHAR__ +/* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.1. */ +# define __STDC_ISO_10646__ 200009L +#endif + +/* There is an unwholesomely huge amount of code out there that depends on the + * presence of GNU libc header files. We have GNU libc header files. So here + * we commit a horrible sin. At this point, we _lie_ and claim to be GNU libc + * to make things like /usr/include/linux/socket.h and lots of apps work as + * their developers intended. This is IMHO, pardonable, since these defines + * are not really intended to check for the presence of a particular library, + * but rather are used to define an _interface_. */ +#if !defined __FORCE_NOGLIBC && (!defined _LIBC || defined __FORCE_GLIBC) +/* This macro indicates that the installed library is the GNU C Library. + For historic reasons the value now is 6 and this will stay from now + on. The use of this variable is deprecated. */ +# undef __GNU_LIBRARY__ +# define __GNU_LIBRARY__ 6 + +/* Major and minor version number of the GNU C library package. Use + these macros to test for features in specific releases. */ +/* Don't do it, if you want to keep uClibc happy. */ +# define __GLIBC__ 2 +# define __GLIBC_MINOR__ 2 +#endif + +#define __GLIBC_PREREQ(maj, min) \ + ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min)) + +#ifndef __UCLIBC__ +/* Decide whether a compiler supports the long long datatypes. */ +#if defined __GNUC__ \ + || (defined __PGI && defined __i386__ ) \ + || (defined __INTEL_COMPILER && (defined __i386__ || defined __ia64__)) \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) +# define __GLIBC_HAVE_LONG_LONG 1 +#endif +#endif + +/* This is here only because every header file already includes this one. */ +#ifndef __ASSEMBLER__ +# ifndef _SYS_CDEFS_H +# include +# endif + +/* If we don't have __REDIRECT, prototypes will be missing if + __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */ +# if defined __USE_FILE_OFFSET64 && !defined __REDIRECT +# define __USE_LARGEFILE 1 +# define __USE_LARGEFILE64 1 +# endif + +#endif /* !ASSEMBLER */ + +/* Decide whether we can define 'extern inline' functions in headers. */ +#if __GNUC_PREREQ(2, 7) && defined __OPTIMIZE__ \ + && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ +# define __USE_EXTERN_INLINES 1 +#endif + + +/* Make sure users large file options agree with uClibc's configuration. */ +#ifndef __UCLIBC_HAS_LFS__ + +/* If uClibc was built without large file support, output an error if + * 64-bit file offsets were requested. + * NOTE: This is probably incorrect on a 64-bit arch... */ +# ifdef __USE_FILE_OFFSET64 +# error It appears you have defined _FILE_OFFSET_BITS=64. Unfortunately, \ +uClibc was built without large file support enabled. +# endif + +/* If uClibc was built without large file support and _LARGEFILE64_SOURCE + * is defined, undefine it. */ +# ifdef _LARGEFILE64_SOURCE +# undef _LARGEFILE64_SOURCE +# undef __USE_LARGEFILE64 +# endif + +/* If we're actually building uClibc with large file support, + * define __USE_LARGEFILE64 and __USE_LARGEFILE. */ +#elif defined _LIBC +# undef _LARGEFILE_SOURCE +# undef _LARGEFILE64_SOURCE +# undef _FILE_OFFSET_BITS +# undef __USE_LARGEFILE +# undef __USE_LARGEFILE64 +# undef __USE_FILE_OFFSET64 +# define _LARGEFILE_SOURCE 1 +# define _LARGEFILE64_SOURCE 1 +# define __USE_LARGEFILE 1 +# define __USE_LARGEFILE64 1 +#endif + +/* uClibc does not support *at interfaces. */ +#undef _ATFILE_SOURCE +#undef __USE_ATFILE + +#ifdef _LIBC +# include +#endif + +#ifndef __linux__ +# define __linux__ 1 +#endif + +/* Disable __user, which shows up in 2.6.x include asm headers + * that get pulled in by signal.h */ +#define __user + +#endif /* features.h */ diff --git a/conts/posix/libposix/include/posix/fnmatch.h b/conts/posix/libposix/include/posix/fnmatch.h new file mode 100644 index 0000000..aefb007 --- /dev/null +++ b/conts/posix/libposix/include/posix/fnmatch.h @@ -0,0 +1,72 @@ +/* Copyright (C) 1991-93,96,97,98,99,2001,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _FNMATCH_H +#define _FNMATCH_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef const +# if (defined __STDC__ && __STDC__) || defined __cplusplus +# define __const const +# else +# define __const +# endif +#endif + +/* We #undef these before defining them because some losing systems + (HP-UX A.08.07 for example) define these in . */ +#undef FNM_PATHNAME +#undef FNM_NOESCAPE +#undef FNM_PERIOD + +/* Bits set in the FLAGS argument to `fnmatch'. */ +#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ +#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ +#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ + +#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE +# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ +# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ +# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ +# define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */ +#endif + +/* Value returned by `fnmatch' if STRING does not match PATTERN. */ +#define FNM_NOMATCH 1 + +/* This value is returned if the implementation does not support + `fnmatch'. Since this is not the case here it will never be + returned but the conformance test suites still require the symbol + to be defined. */ +#ifdef _XOPEN_SOURCE +# define FNM_NOSYS (-1) +#endif + +/* Match NAME against the filename pattern PATTERN, + returning zero if it matches, FNM_NOMATCH if not. */ +extern int fnmatch (__const char *__pattern, __const char *__name, + int __flags); + +#ifdef __cplusplus +} +#endif + +#endif /* fnmatch.h */ diff --git a/conts/posix/libposix/include/posix/ftw.h b/conts/posix/libposix/include/posix/ftw.h new file mode 100644 index 0000000..4bdff88 --- /dev/null +++ b/conts/posix/libposix/include/posix/ftw.h @@ -0,0 +1,178 @@ +/* Copyright (C) 1992,1996-1999,2003,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * X/Open Portability Guide 4.2: ftw.h + */ + +#ifndef _FTW_H +#define _FTW_H 1 + +#include + +#include +#include + + +__BEGIN_DECLS + +/* Values for the FLAG argument to the user function passed to `ftw' + and 'nftw'. */ +enum +{ + FTW_F, /* Regular file. */ +#define FTW_F FTW_F + FTW_D, /* Directory. */ +#define FTW_D FTW_D + FTW_DNR, /* Unreadable directory. */ +#define FTW_DNR FTW_DNR + FTW_NS, /* Unstatable file. */ +#define FTW_NS FTW_NS + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED + + FTW_SL, /* Symbolic link. */ +# define FTW_SL FTW_SL +#endif + +#ifdef __USE_XOPEN_EXTENDED +/* These flags are only passed from the `nftw' function. */ + FTW_DP, /* Directory, all subdirs have been visited. */ +# define FTW_DP FTW_DP + FTW_SLN /* Symbolic link naming non-existing file. */ +# define FTW_SLN FTW_SLN + +#endif /* extended X/Open */ +}; + + +#ifdef __USE_XOPEN_EXTENDED +/* Flags for fourth argument of `nftw'. */ +enum +{ + FTW_PHYS = 1, /* Perform physical walk, ignore symlinks. */ +# define FTW_PHYS FTW_PHYS + FTW_MOUNT = 2, /* Report only files on same file system as the + argument. */ +# define FTW_MOUNT FTW_MOUNT + FTW_CHDIR = 4, /* Change to current directory while processing it. */ +# define FTW_CHDIR FTW_CHDIR + FTW_DEPTH = 8 /* Report files in directory before directory itself.*/ +# define FTW_DEPTH FTW_DEPTH +# ifdef __USE_GNU + , + FTW_ACTIONRETVAL = 16 /* Assume callback to return FTW_* values instead of + zero to continue and non-zero to terminate. */ +# define FTW_ACTIONRETVAL FTW_ACTIONRETVAL +# endif +}; + +#ifdef __USE_GNU +/* Return values from callback functions. */ +enum +{ + FTW_CONTINUE = 0, /* Continue with next sibling or for FTW_D with the + first child. */ +# define FTW_CONTINUE FTW_CONTINUE + FTW_STOP = 1, /* Return from `ftw' or `nftw' with FTW_STOP as return + value. */ +# define FTW_STOP FTW_STOP + FTW_SKIP_SUBTREE = 2, /* Only meaningful for FTW_D: Don't walk through the + subtree, instead just continue with its next + sibling. */ +# define FTW_SKIP_SUBTREE FTW_SKIP_SUBTREE + FTW_SKIP_SIBLINGS = 3,/* Continue with FTW_DP callback for current directory + (if FTW_DEPTH) and then its siblings. */ +# define FTW_SKIP_SIBLINGS FTW_SKIP_SIBLINGS +}; +#endif + +/* Structure used for fourth argument to callback function for `nftw'. */ +struct FTW + { + int base; + int level; + }; +#endif /* extended X/Open */ + + +/* Convenient types for callback functions. */ +typedef int (*__ftw_func_t) (__const char *__filename, + __const struct stat *__status, int __flag); +#ifdef __USE_LARGEFILE64 +typedef int (*__ftw64_func_t) (__const char *__filename, + __const struct stat64 *__status, int __flag); +#endif +#ifdef __USE_XOPEN_EXTENDED +typedef int (*__nftw_func_t) (__const char *__filename, + __const struct stat *__status, int __flag, + struct FTW *__info); +# ifdef __USE_LARGEFILE64 +typedef int (*__nftw64_func_t) (__const char *__filename, + __const struct stat64 *__status, + int __flag, struct FTW *__info); +# endif +#endif + +/* Call a function on every element in a directory tree. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +#ifndef __USE_FILE_OFFSET64 +extern int ftw (__const char *__dir, __ftw_func_t __func, int __descriptors) + __nonnull ((1, 2)); +#else +# ifdef __REDIRECT +extern int __REDIRECT (ftw, (__const char *__dir, __ftw_func_t __func, + int __descriptors), ftw64) __nonnull ((1, 2)); +# else +# define ftw ftw64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern int ftw64 (__const char *__dir, __ftw64_func_t __func, + int __descriptors) __nonnull ((1, 2)); +#endif + +#ifdef __USE_XOPEN_EXTENDED +/* Call a function on every element in a directory tree. FLAG allows + to specify the behaviour more detailed. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +# ifndef __USE_FILE_OFFSET64 +extern int nftw (__const char *__dir, __nftw_func_t __func, int __descriptors, + int __flag) __nonnull ((1, 2)); +# else +# ifdef __REDIRECT +extern int __REDIRECT (nftw, (__const char *__dir, __nftw_func_t __func, + int __descriptors, int __flag), nftw64) + __nonnull ((1, 2)); +# else +# define nftw nftw64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int nftw64 (__const char *__dir, __nftw64_func_t __func, + int __descriptors, int __flag) __nonnull ((1, 2)); +# endif +#endif + +__END_DECLS + +#endif /* ftw.h */ diff --git a/conts/posix/libposix/include/posix/getopt.h b/conts/posix/libposix/include/posix/getopt.h new file mode 100644 index 0000000..a682f9c --- /dev/null +++ b/conts/posix/libposix/include/posix/getopt.h @@ -0,0 +1,4 @@ +/* This file will not be installed if not using gnu getopt. */ + +#include + diff --git a/conts/posix/libposix/include/posix/glob.h b/conts/posix/libposix/include/posix/glob.h new file mode 100644 index 0000000..68ea2cb --- /dev/null +++ b/conts/posix/libposix/include/posix/glob.h @@ -0,0 +1,208 @@ +/* Copyright (C) 1991,92,95-98,2000,2001,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _GLOB_H +#define _GLOB_H 1 + +#include + +__BEGIN_DECLS + +/* We need `size_t' for the following definitions. */ +#ifndef __size_t +# if defined __GNUC__ && __GNUC__ >= 2 +typedef __SIZE_TYPE__ __size_t; +# ifdef __USE_XOPEN +typedef __SIZE_TYPE__ size_t; +# endif +# else +# include +# ifndef __size_t +# define __size_t size_t +# endif +# endif +#else +/* The GNU CC stddef.h version defines __size_t as empty. We need a real + definition. */ +# undef __size_t +# define __size_t size_t +#endif + +/* Bits set in the FLAGS argument to `glob'. */ +#define GLOB_ERR (1 << 0)/* Return on read errors. */ +#define GLOB_MARK (1 << 1)/* Append a slash to each name. */ +#define GLOB_NOSORT (1 << 2)/* Don't sort the names. */ +#define GLOB_DOOFFS (1 << 3)/* Insert PGLOB->gl_offs NULLs. */ +#define GLOB_NOCHECK (1 << 4)/* If nothing matches, return the pattern. */ +#define GLOB_APPEND (1 << 5)/* Append to results of a previous call. */ +#define GLOB_NOESCAPE (1 << 6)/* Backslashes don't quote metacharacters. */ +#define GLOB_PERIOD (1 << 7)/* Leading `.' can be matched by metachars. */ + +#if ( !defined __USE_POSIX2 || defined __USE_BSD || defined __USE_GNU ) && defined __UCLIBC_HAS_GNU_GLOB__ +# define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */ +#if 1 /* uClibc gnu glob does not support these */ +# define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */ +# define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */ +# define GLOB_NOMAGIC (1 << 11)/* If no magic chars, return the pattern. */ +# define GLOB_TILDE (1 << 12)/* Expand ~user and ~ to home directories. */ +# define GLOB_ONLYDIR (1 << 13)/* Match only directories. */ +# define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error + if the user name is not available. */ +# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \ + GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \ + GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \ + GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK) +#else +# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \ + GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \ + GLOB_PERIOD) +#endif +#else +# define __GLOB_FLAGS (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \ + GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND| \ + GLOB_PERIOD) +#endif + +/* Error returns from `glob'. */ +#define GLOB_NOSPACE 1 /* Ran out of memory. */ +#define GLOB_ABORTED 2 /* Read error. */ +#define GLOB_NOMATCH 3 /* No matches found. */ +#define GLOB_NOSYS 4 /* Not implemented. */ +#if defined __USE_GNU && defined __UCLIBC_HAS_GNU_GLOB__ +/* Previous versions of this file defined GLOB_ABEND instead of + GLOB_ABORTED. Provide a compatibility definition here. */ +# define GLOB_ABEND GLOB_ABORTED +#endif + +/* Structure describing a globbing run. */ +#if defined __USE_GNU && defined __UCLIBC_HAS_GNU_GLOB__ +struct stat; +#endif +typedef struct + { + __size_t gl_pathc; /* Count of paths matched by the pattern. */ + char **gl_pathv; /* List of matched pathnames. */ + __size_t gl_offs; /* Slots to reserve in `gl_pathv'. */ +#ifdef __UCLIBC_HAS_GNU_GLOB__ + int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */ + +#if 1 /* uClibc gnu glob does not support these */ + /* If the GLOB_ALTDIRFUNC flag is set, the following functions + are used instead of the normal file access functions. */ + void (*gl_closedir) (void *); +#ifdef __USE_GNU + struct dirent *(*gl_readdir) (void *); +#else + void *(*gl_readdir) (void *); +#endif + void *(*gl_opendir) (__const char *); +#ifdef __USE_GNU + int (*gl_lstat) (__const char *__restrict, struct stat *__restrict); + int (*gl_stat) (__const char *__restrict, struct stat *__restrict); +#else + int (*gl_lstat) (__const char *__restrict, void *__restrict); + int (*gl_stat) (__const char *__restrict, void *__restrict); +#endif +#endif +#endif /* __UCLIBC_HAS_GNU_GLOB__ */ + } glob_t; + +#ifdef __USE_LARGEFILE64 +# if defined __USE_GNU && defined __UCLIBC_HAS_GNU_GLOB__ +struct stat64; +# endif +typedef struct + { + __size_t gl_pathc; + char **gl_pathv; + __size_t gl_offs; +#ifdef __UCLIBC_HAS_GNU_GLOB__ + int gl_flags; + +#if 1 /* uClibc gnu glob does not support these */ + /* If the GLOB_ALTDIRFUNC flag is set, the following functions + are used instead of the normal file access functions. */ + void (*gl_closedir) (void *); +# ifdef __USE_GNU + struct dirent64 *(*gl_readdir) (void *); +# else + void *(*gl_readdir) (void *); +# endif + void *(*gl_opendir) (__const char *); +# ifdef __USE_GNU + int (*gl_lstat) (__const char *__restrict, struct stat64 *__restrict); + int (*gl_stat) (__const char *__restrict, struct stat64 *__restrict); +# else + int (*gl_lstat) (__const char *__restrict, void *__restrict); + int (*gl_stat) (__const char *__restrict, void *__restrict); +# endif +#endif +#endif /* __UCLIBC_HAS_GNU_GLOB__ */ + } glob64_t; +#endif + +#if defined(__USE_FILE_OFFSET64) && __GNUC__ < 2 +# define glob glob64 +# define globfree globfree64 +#endif + +/* Do glob searching for PATTERN, placing results in PGLOB. + The bits defined above may be set in FLAGS. + If a directory cannot be opened or read and ERRFUNC is not nil, + it is called with the pathname that caused the error, and the + `errno' value from the failing call; if it returns non-zero + `glob' returns GLOB_ABEND; if it returns zero, the error is ignored. + If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned. + Otherwise, `glob' returns zero. */ +#if !defined __USE_FILE_OFFSET64 || __GNUC__ < 2 +extern int glob (__const char *__restrict __pattern, int __flags, + int (*__errfunc) (__const char *, int), + glob_t *__restrict __pglob) __THROW; + +/* Free storage allocated in PGLOB by a previous `glob' call. */ +extern void globfree (glob_t *__pglob) __THROW; +#else +extern int __REDIRECT_NTH (glob, (__const char *__restrict __pattern, + int __flags, + int (*__errfunc) (__const char *, int), + glob_t *__restrict __pglob), glob64); + +extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64); +#endif + +#ifdef __USE_LARGEFILE64 +extern int glob64 (__const char *__restrict __pattern, int __flags, + int (*__errfunc) (__const char *, int), + glob64_t *__restrict __pglob) __THROW; + +extern void globfree64 (glob64_t *__pglob) __THROW; +#endif + + +#if defined __USE_GNU && defined __UCLIBC_HAS_GNU_GLOB__ +/* Return nonzero if PATTERN contains any metacharacters. + Metacharacters can be quoted with backslashes if QUOTE is nonzero. + + This function is not part of the interface specified by POSIX.2 + but several programs want to use it. */ +extern int glob_pattern_p (__const char *__pattern, int __quote) __THROW; +#endif + +__END_DECLS + +#endif /* glob.h */ diff --git a/conts/posix/libposix/include/posix/gnu-versions.h b/conts/posix/libposix/include/posix/gnu-versions.h new file mode 100644 index 0000000..59e617c --- /dev/null +++ b/conts/posix/libposix/include/posix/gnu-versions.h @@ -0,0 +1,53 @@ +/* Header with interface version macros for library pieces copied elsewhere. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _GNU_VERSIONS_H +#define _GNU_VERSIONS_H 1 + +/* This file exists to define these few macros. Each specifies a version + number associated with the library interface of a piece of the C library + which is also distributed with other GNU packages. These pieces are + both part of the GNU C library and also distributed with other GNU + packages so those packages may use their facilities on systems lacking + the GNU C library. The source files for each piece surround all their + code with `#ifndef ELIDE_CODE' after defining it with this: + + #define OBSTACK_INTERFACE_VERSION 1 + #if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 + #include + #if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION + #define ELIDE_CODE + #endif + #endif + + This allows those one to avoid compiling those files when part of a GNU + package not libc, on a system using a GNU C library that supports the + same interface. + + Please preserve the format of the comments after each macro. And + remember, if any of these versions change, the libc.so major version + number must change too (so avoid it)! */ + +#define _GNU_OBSTACK_INTERFACE_VERSION 1 /* vs malloc/obstack.c */ +#define _GNU_REGEX_INTERFACE_VERSION 1 /* vs posix/regex.c */ +#define _GNU_GLOB_INTERFACE_VERSION 1 /* vs posix/glob.c */ +#define _GNU_GETOPT_INTERFACE_VERSION 2 /* vs posix/getopt.c and + posix/getopt1.c */ + +#endif /* gnu-versions.h */ diff --git a/conts/posix/libposix/include/posix/grp.h b/conts/posix/libposix/include/posix/grp.h new file mode 100644 index 0000000..6ad8be1 --- /dev/null +++ b/conts/posix/libposix/include/posix/grp.h @@ -0,0 +1,207 @@ +/* Copyright (C) 1991,1992,1995-2001,2003,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * POSIX Standard: 9.2.1 Group Database Access + */ + +#ifndef _GRP_H +#define _GRP_H 1 + +#include + +__BEGIN_DECLS + +#include + +#define __need_size_t +#include + + +/* For the Single Unix specification we must define this type here. */ +#if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined +typedef __gid_t gid_t; +# define __gid_t_defined +#endif + +/* The group structure. */ +struct group + { + char *gr_name; /* Group name. */ + char *gr_passwd; /* Password. */ + __gid_t gr_gid; /* Group ID. */ + char **gr_mem; /* Member list. */ + }; + + +#if defined __USE_SVID || defined __USE_GNU +# define __need_FILE +# include +#endif + + +#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED +/* Rewind the group-file stream. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void setgrent (void); + +/* Close the group-file stream. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void endgrent (void); + +/* Read an entry from the group-file stream, opening it if necessary. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct group *getgrent (void); +#endif + +#ifdef __USE_SVID +/* Read a group entry from STREAM. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern struct group *fgetgrent (FILE *__stream); +#endif + +#ifdef __USE_GNU +/* Write the given entry onto the given stream. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int putgrent (__const struct group *__restrict __p, + FILE *__restrict __f); +#endif + +/* Search for an entry with a matching group ID. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct group *getgrgid (__gid_t __gid); + +/* Search for an entry with a matching group name. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct group *getgrnam (__const char *__name); + +#if defined __USE_POSIX || defined __USE_MISC + +# ifdef __USE_MISC +/* Reasonable value for the buffer sized used in the reentrant + functions below. But better use `sysconf'. */ +# define NSS_BUFLEN_GROUP 1024 +# endif + +/* Reentrant versions of some of the functions above. + + PLEASE NOTE: the `getgrent_r' function is not (yet) standardized. + The interface may change in later versions of this library. But + the interface is designed following the principals used for the + other reentrant functions so the chances are good this is what the + POSIX people would choose. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ + +# ifdef __USE_GNU +extern int getgrent_r (struct group *__restrict __resultbuf, + char *__restrict __buffer, size_t __buflen, + struct group **__restrict __result); +# endif + +/* Search for an entry with a matching group ID. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int getgrgid_r (__gid_t __gid, struct group *__restrict __resultbuf, + char *__restrict __buffer, size_t __buflen, + struct group **__restrict __result); + +/* Search for an entry with a matching group name. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int getgrnam_r (__const char *__restrict __name, + struct group *__restrict __resultbuf, + char *__restrict __buffer, size_t __buflen, + struct group **__restrict __result); + +# ifdef __USE_SVID +/* Read a group entry from STREAM. This function is not standardized + an probably never will. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int fgetgrent_r (FILE *__restrict __stream, + struct group *__restrict __resultbuf, + char *__restrict __buffer, size_t __buflen, + struct group **__restrict __result); +# endif + +#endif /* POSIX or reentrant */ + + +#ifdef __USE_BSD + +# define __need_size_t +# include + +/* Set the group set for the current user to GROUPS (N of them). */ +extern int setgroups (size_t __n, __const __gid_t *__groups) __THROW; + +#if 0 +/* Store at most *NGROUPS members of the group set for USER into + *GROUPS. Also include GROUP. The actual number of groups found is + returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int getgrouplist (__const char *__user, __gid_t __group, + __gid_t *__groups, int *__ngroups); +#endif + +/* Initialize the group set for the current user + by reading the group database and using all groups + of which USER is a member. Also include GROUP. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int initgroups (__const char *__user, __gid_t __group); + +#endif /* Use BSD. */ + +__END_DECLS + +#endif /* grp.h */ diff --git a/conts/posix/libposix/include/posix/iconv.h b/conts/posix/libposix/include/posix/iconv.h new file mode 100644 index 0000000..0a19c04 --- /dev/null +++ b/conts/posix/libposix/include/posix/iconv.h @@ -0,0 +1,60 @@ +/* Copyright (C) 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _ICONV_H +#define _ICONV_H 1 + +#include +#define __need_size_t +#include + +#ifndef __UCLIBC_HAS_LOCALE__ +#error Attempted to include iconv.h when uClibc was built without locale support. +#endif + + +__BEGIN_DECLS + +/* Identifier for conversion method from one codeset to another. */ +typedef void *iconv_t; + + +/* Allocate descriptor for code conversion from codeset FROMCODE to + codeset TOCODE. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +extern iconv_t iconv_open (__const char *__tocode, __const char *__fromcode); + +/* Convert at most *INBYTESLEFT bytes from *INBUF according to the + code conversion algorithm specified by CD and place up to + *OUTBYTESLEFT bytes in buffer at *OUTBUF. */ +extern size_t iconv (iconv_t __cd, char **__restrict __inbuf, + size_t *__restrict __inbytesleft, + char **__restrict __outbuf, + size_t *__restrict __outbytesleft); + +/* Free resources allocated for descriptor CD for code conversion. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +extern int iconv_close (iconv_t __cd); + +__END_DECLS + +#endif /* iconv.h */ diff --git a/conts/posix/libposix/include/posix/ieee754.h b/conts/posix/libposix/include/posix/ieee754.h new file mode 100644 index 0000000..7131e5d --- /dev/null +++ b/conts/posix/libposix/include/posix/ieee754.h @@ -0,0 +1,199 @@ +/* Copyright (C) 1992, 1995, 1996, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _IEEE754_H + +#define _IEEE754_H 1 +#include + +#include + +__BEGIN_DECLS + +union ieee754_float + { + float f; + + /* This is the IEEE 754 single-precision format. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:8; + unsigned int mantissa:23; +#endif /* Big endian. */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int mantissa:23; + unsigned int exponent:8; + unsigned int negative:1; +#endif /* Little endian. */ + } ieee; + + /* This format makes it easier to see if a NaN is a signalling NaN. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:8; + unsigned int quiet_nan:1; + unsigned int mantissa:22; +#endif /* Big endian. */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int mantissa:22; + unsigned int quiet_nan:1; + unsigned int exponent:8; + unsigned int negative:1; +#endif /* Little endian. */ + } ieee_nan; + }; + +#define IEEE754_FLOAT_BIAS 0x7f /* Added to exponent. */ + + +union ieee754_double + { + double d; + + /* This is the IEEE 754 double-precision format. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:11; + /* Together these comprise the mantissa. */ + unsigned int mantissa0:20; + unsigned int mantissa1:32; +#endif /* Big endian. */ +#if __BYTE_ORDER == __LITTLE_ENDIAN +# if __FLOAT_WORD_ORDER == BIG_ENDIAN + unsigned int mantissa0:20; + unsigned int exponent:11; + unsigned int negative:1; + unsigned int mantissa1:32; +# else + /* Together these comprise the mantissa. */ + unsigned int mantissa1:32; + unsigned int mantissa0:20; + unsigned int exponent:11; + unsigned int negative:1; +# endif +#endif /* Little endian. */ + } ieee; + + /* This format makes it easier to see if a NaN is a signalling NaN. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:11; + unsigned int quiet_nan:1; + /* Together these comprise the mantissa. */ + unsigned int mantissa0:19; + unsigned int mantissa1:32; +#else +# if __FLOAT_WORD_ORDER == BIG_ENDIAN + unsigned int mantissa0:19; + unsigned int quiet_nan:1; + unsigned int exponent:11; + unsigned int negative:1; + unsigned int mantissa1:32; +# else + /* Together these comprise the mantissa. */ + unsigned int mantissa1:32; + unsigned int mantissa0:19; + unsigned int quiet_nan:1; + unsigned int exponent:11; + unsigned int negative:1; +# endif +#endif + } ieee_nan; + }; + +#define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */ + + +union ieee854_long_double + { + long double d; + + /* This is the IEEE 854 double-extended-precision format. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:15; + unsigned int empty:16; + unsigned int mantissa0:32; + unsigned int mantissa1:32; +#endif +#if __BYTE_ORDER == __LITTLE_ENDIAN +# if __FLOAT_WORD_ORDER == BIG_ENDIAN + unsigned int exponent:15; + unsigned int negative:1; + unsigned int empty:16; + unsigned int mantissa0:32; + unsigned int mantissa1:32; +# else + unsigned int mantissa1:32; + unsigned int mantissa0:32; + unsigned int exponent:15; + unsigned int negative:1; + unsigned int empty:16; +# endif +#endif + } ieee; + + /* This is for NaNs in the IEEE 854 double-extended-precision format. */ + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:15; + unsigned int empty:16; + unsigned int one:1; + unsigned int quiet_nan:1; + unsigned int mantissa0:30; + unsigned int mantissa1:32; +#endif +#if __BYTE_ORDER == __LITTLE_ENDIAN +# if __FLOAT_WORD_ORDER == BIG_ENDIAN + unsigned int exponent:15; + unsigned int negative:1; + unsigned int empty:16; + unsigned int mantissa0:30; + unsigned int quiet_nan:1; + unsigned int one:1; + unsigned int mantissa1:32; +# else + unsigned int mantissa1:32; + unsigned int mantissa0:30; + unsigned int quiet_nan:1; + unsigned int one:1; + unsigned int exponent:15; + unsigned int negative:1; + unsigned int empty:16; +# endif +#endif + } ieee_nan; + }; + +#define IEEE854_LONG_DOUBLE_BIAS 0x3fff + +__END_DECLS + +#endif /* ieee754.h */ diff --git a/conts/posix/libposix/include/posix/inttypes.h b/conts/posix/libposix/include/posix/inttypes.h new file mode 100644 index 0000000..b1d4302 --- /dev/null +++ b/conts/posix/libposix/include/posix/inttypes.h @@ -0,0 +1,328 @@ +/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99: 7.8 Format conversion of integer types + */ + +#ifndef _INTTYPES_H +#define _INTTYPES_H 1 + +#include +/* Get the type definitions. */ +#include + +#ifdef __UCLIBC_HAS_WCHAR__ +/* Get a definition for wchar_t. But we must not define wchar_t itself. */ +#ifndef ____gwchar_t_defined +# ifdef __cplusplus +# define __gwchar_t wchar_t +# elif defined __WCHAR_TYPE__ +typedef __WCHAR_TYPE__ __gwchar_t; +# else +# define __need_wchar_t +# include +typedef wchar_t __gwchar_t; +# endif +# define ____gwchar_t_defined 1 +#endif +#endif + + +/* The ISO C99 standard specifies that these macros must only be + defined if explicitly requested. */ +#if !defined __cplusplus || defined __STDC_FORMAT_MACROS + +# if __WORDSIZE == 64 +# define __PRI64_PREFIX "l" +# define __PRIPTR_PREFIX "l" +# else +# define __PRI64_PREFIX "ll" +# define __PRIPTR_PREFIX +# endif + +/* Macros for printing format specifiers. */ + +/* Decimal notation. */ +# define PRId8 "d" +# define PRId16 "d" +# define PRId32 "d" +# define PRId64 __PRI64_PREFIX "d" + +# define PRIdLEAST8 "d" +# define PRIdLEAST16 "d" +# define PRIdLEAST32 "d" +# define PRIdLEAST64 __PRI64_PREFIX "d" + +# define PRIdFAST8 "d" +# define PRIdFAST16 "d" +# define PRIdFAST32 "d" +# define PRIdFAST64 __PRI64_PREFIX "d" + + +# define PRIi8 "i" +# define PRIi16 "i" +# define PRIi32 "i" +# define PRIi64 __PRI64_PREFIX "i" + +# define PRIiLEAST8 "i" +# define PRIiLEAST16 "i" +# define PRIiLEAST32 "i" +# define PRIiLEAST64 __PRI64_PREFIX "i" + +# define PRIiFAST8 "i" +# define PRIiFAST16 "i" +# define PRIiFAST32 "i" +# define PRIiFAST64 __PRI64_PREFIX "i" + +/* Octal notation. */ +# define PRIo8 "o" +# define PRIo16 "o" +# define PRIo32 "o" +# define PRIo64 __PRI64_PREFIX "o" + +# define PRIoLEAST8 "o" +# define PRIoLEAST16 "o" +# define PRIoLEAST32 "o" +# define PRIoLEAST64 __PRI64_PREFIX "o" + +# define PRIoFAST8 "o" +# define PRIoFAST16 "o" +# define PRIoFAST32 "o" +# define PRIoFAST64 __PRI64_PREFIX "o" + +/* Unsigned integers. */ +# define PRIu8 "u" +# define PRIu16 "u" +# define PRIu32 "u" +# define PRIu64 __PRI64_PREFIX "u" + +# define PRIuLEAST8 "u" +# define PRIuLEAST16 "u" +# define PRIuLEAST32 "u" +# define PRIuLEAST64 __PRI64_PREFIX "u" + +# define PRIuFAST8 "u" +# define PRIuFAST16 "u" +# define PRIuFAST32 "u" +# define PRIuFAST64 __PRI64_PREFIX "u" + +/* lowercase hexadecimal notation. */ +# define PRIx8 "x" +# define PRIx16 "x" +# define PRIx32 "x" +# define PRIx64 __PRI64_PREFIX "x" + +# define PRIxLEAST8 "x" +# define PRIxLEAST16 "x" +# define PRIxLEAST32 "x" +# define PRIxLEAST64 __PRI64_PREFIX "x" + +# define PRIxFAST8 "x" +# define PRIxFAST16 "x" +# define PRIxFAST32 "x" +# define PRIxFAST64 __PRI64_PREFIX "x" + +/* UPPERCASE hexadecimal notation. */ +# define PRIX8 "X" +# define PRIX16 "X" +# define PRIX32 "X" +# define PRIX64 __PRI64_PREFIX "X" + +# define PRIXLEAST8 "X" +# define PRIXLEAST16 "X" +# define PRIXLEAST32 "X" +# define PRIXLEAST64 __PRI64_PREFIX "X" + +# define PRIXFAST8 "X" +# define PRIXFAST16 "X" +# define PRIXFAST32 "X" +# define PRIXFAST64 __PRI64_PREFIX "X" + + +/* Macros for printing `intmax_t' and `uintmax_t'. */ +# define PRIdMAX __PRI64_PREFIX "d" +# define PRIiMAX __PRI64_PREFIX "i" +# define PRIoMAX __PRI64_PREFIX "o" +# define PRIuMAX __PRI64_PREFIX "u" +# define PRIxMAX __PRI64_PREFIX "x" +# define PRIXMAX __PRI64_PREFIX "X" + + +/* Macros for printing `intptr_t' and `uintptr_t'. */ +# define PRIdPTR __PRIPTR_PREFIX "d" +# define PRIiPTR __PRIPTR_PREFIX "i" +# define PRIoPTR __PRIPTR_PREFIX "o" +# define PRIuPTR __PRIPTR_PREFIX "u" +# define PRIxPTR __PRIPTR_PREFIX "x" +# define PRIXPTR __PRIPTR_PREFIX "X" + + +/* Macros for scanning format specifiers. */ + +/* Signed decimal notation. */ +# define SCNd8 "hhd" +# define SCNd16 "hd" +# define SCNd32 "d" +# define SCNd64 __PRI64_PREFIX "d" + +# define SCNdLEAST8 "hhd" +# define SCNdLEAST16 "hd" +# define SCNdLEAST32 "d" +# define SCNdLEAST64 __PRI64_PREFIX "d" + +# define SCNdFAST8 "hhd" +# define SCNdFAST16 __PRIPTR_PREFIX "d" +# define SCNdFAST32 __PRIPTR_PREFIX "d" +# define SCNdFAST64 __PRI64_PREFIX "d" + +/* Signed decimal notation. */ +# define SCNi8 "hhi" +# define SCNi16 "hi" +# define SCNi32 "i" +# define SCNi64 __PRI64_PREFIX "i" + +# define SCNiLEAST8 "hhi" +# define SCNiLEAST16 "hi" +# define SCNiLEAST32 "i" +# define SCNiLEAST64 __PRI64_PREFIX "i" + +# define SCNiFAST8 "hhi" +# define SCNiFAST16 __PRIPTR_PREFIX "i" +# define SCNiFAST32 __PRIPTR_PREFIX "i" +# define SCNiFAST64 __PRI64_PREFIX "i" + +/* Unsigned decimal notation. */ +# define SCNu8 "hhu" +# define SCNu16 "hu" +# define SCNu32 "u" +# define SCNu64 __PRI64_PREFIX "u" + +# define SCNuLEAST8 "hhu" +# define SCNuLEAST16 "hu" +# define SCNuLEAST32 "u" +# define SCNuLEAST64 __PRI64_PREFIX "u" + +# define SCNuFAST8 "hhu" +# define SCNuFAST16 __PRIPTR_PREFIX "u" +# define SCNuFAST32 __PRIPTR_PREFIX "u" +# define SCNuFAST64 __PRI64_PREFIX "u" + +/* Octal notation. */ +# define SCNo8 "hho" +# define SCNo16 "ho" +# define SCNo32 "o" +# define SCNo64 __PRI64_PREFIX "o" + +# define SCNoLEAST8 "hho" +# define SCNoLEAST16 "ho" +# define SCNoLEAST32 "o" +# define SCNoLEAST64 __PRI64_PREFIX "o" + +# define SCNoFAST8 "hho" +# define SCNoFAST16 __PRIPTR_PREFIX "o" +# define SCNoFAST32 __PRIPTR_PREFIX "o" +# define SCNoFAST64 __PRI64_PREFIX "o" + +/* Hexadecimal notation. */ +# define SCNx8 "hhx" +# define SCNx16 "hx" +# define SCNx32 "x" +# define SCNx64 __PRI64_PREFIX "x" + +# define SCNxLEAST8 "hhx" +# define SCNxLEAST16 "hx" +# define SCNxLEAST32 "x" +# define SCNxLEAST64 __PRI64_PREFIX "x" + +# define SCNxFAST8 "hhx" +# define SCNxFAST16 __PRIPTR_PREFIX "x" +# define SCNxFAST32 __PRIPTR_PREFIX "x" +# define SCNxFAST64 __PRI64_PREFIX "x" + + +/* Macros for scanning `intmax_t' and `uintmax_t'. */ +# define SCNdMAX __PRI64_PREFIX "d" +# define SCNiMAX __PRI64_PREFIX "i" +# define SCNoMAX __PRI64_PREFIX "o" +# define SCNuMAX __PRI64_PREFIX "u" +# define SCNxMAX __PRI64_PREFIX "x" + +/* Macros for scaning `intptr_t' and `uintptr_t'. */ +# define SCNdPTR __PRIPTR_PREFIX "d" +# define SCNiPTR __PRIPTR_PREFIX "i" +# define SCNoPTR __PRIPTR_PREFIX "o" +# define SCNuPTR __PRIPTR_PREFIX "u" +# define SCNxPTR __PRIPTR_PREFIX "x" + +#endif /* C++ && format macros */ + + +__BEGIN_DECLS + +#if __WORDSIZE == 64 + +/* We have to define the `uintmax_t' type using `ldiv_t'. */ +typedef struct + { + long int quot; /* Quotient. */ + long int rem; /* Remainder. */ + } imaxdiv_t; + +#else + +/* We have to define the `uintmax_t' type using `lldiv_t'. */ +typedef struct + { + long long int quot; /* Quotient. */ + long long int rem; /* Remainder. */ + } imaxdiv_t; + +#endif + + +/* Compute absolute value of N. */ +extern intmax_t imaxabs (intmax_t __n) __THROW __attribute__ ((__const__)); + +/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */ +extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom) + __THROW __attribute__ ((__const__)); + +/* Like `strtol' but convert to `intmax_t'. */ +extern intmax_t strtoimax (__const char *__restrict __nptr, + char **__restrict __endptr, int __base) __THROW; + +/* Like `strtoul' but convert to `uintmax_t'. */ +extern uintmax_t strtoumax (__const char *__restrict __nptr, + char ** __restrict __endptr, int __base) __THROW; + +#if defined __UCLIBC_HAS_WCHAR__ && __UCLIBC_HAS_WCHAR__ +/* Like `wcstol' but convert to `intmax_t'. */ +extern intmax_t wcstoimax (__const __gwchar_t *__restrict __nptr, + __gwchar_t **__restrict __endptr, int __base) + __THROW; + +/* Like `wcstoul' but convert to `uintmax_t'. */ +extern uintmax_t wcstoumax (__const __gwchar_t *__restrict __nptr, + __gwchar_t ** __restrict __endptr, int __base) + __THROW; +#endif + +__END_DECLS + +#endif /* inttypes.h */ diff --git a/conts/posix/libposix/include/posix/langinfo.h b/conts/posix/libposix/include/posix/langinfo.h new file mode 100644 index 0000000..837a87b --- /dev/null +++ b/conts/posix/libposix/include/posix/langinfo.h @@ -0,0 +1,623 @@ +/* Access to locale-dependent parameters. + Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _LANGINFO_H +#define _LANGINFO_H 1 + +/* Get the type definition. */ +#include + +#include /* Define the __LC_* category names. */ + + +__BEGIN_DECLS + +/* Construct an `nl_item' value for `nl_langinfo' from a locale category + (LC_*) and an item index within the category. Some code may depend on + the item values within a category increasing monotonically with the + indices. */ +#define _NL_ITEM(category, index) \ + (((category) << __NL_ITEM_CATEGORY_SHIFT) | (index)) + +/* Extract the category and item index from a constructed `nl_item' value. */ +#define _NL_ITEM_CATEGORY(item) ((int) (item) >> __NL_ITEM_CATEGORY_SHIFT) +#define _NL_ITEM_INDEX(item) ((int) (item) & __NL_ITEM_INDEX_MASK) + + +/* Enumeration of locale items that can be queried with `nl_langinfo'. */ +enum +{ + /* LC_TIME category: date and time formatting. */ + + /* Abbreviated days of the week. */ + ABDAY_1 = _NL_ITEM (__LC_TIME, 0), /* Sun */ +#define ABDAY_1 ABDAY_1 + ABDAY_2, +#define ABDAY_2 ABDAY_2 + ABDAY_3, +#define ABDAY_3 ABDAY_3 + ABDAY_4, +#define ABDAY_4 ABDAY_4 + ABDAY_5, +#define ABDAY_5 ABDAY_5 + ABDAY_6, +#define ABDAY_6 ABDAY_6 + ABDAY_7, +#define ABDAY_7 ABDAY_7 + + /* Long-named days of the week. */ + DAY_1, /* Sunday */ +#define DAY_1 DAY_1 + DAY_2, /* Monday */ +#define DAY_2 DAY_2 + DAY_3, /* Tuesday */ +#define DAY_3 DAY_3 + DAY_4, /* Wednesday */ +#define DAY_4 DAY_4 + DAY_5, /* Thursday */ +#define DAY_5 DAY_5 + DAY_6, /* Friday */ +#define DAY_6 DAY_6 + DAY_7, /* Saturday */ +#define DAY_7 DAY_7 + + /* Abbreviated month names. */ + ABMON_1, /* Jan */ +#define ABMON_1 ABMON_1 + ABMON_2, +#define ABMON_2 ABMON_2 + ABMON_3, +#define ABMON_3 ABMON_3 + ABMON_4, +#define ABMON_4 ABMON_4 + ABMON_5, +#define ABMON_5 ABMON_5 + ABMON_6, +#define ABMON_6 ABMON_6 + ABMON_7, +#define ABMON_7 ABMON_7 + ABMON_8, +#define ABMON_8 ABMON_8 + ABMON_9, +#define ABMON_9 ABMON_9 + ABMON_10, +#define ABMON_10 ABMON_10 + ABMON_11, +#define ABMON_11 ABMON_11 + ABMON_12, +#define ABMON_12 ABMON_12 + + /* Long month names. */ + MON_1, /* January */ +#define MON_1 MON_1 + MON_2, +#define MON_2 MON_2 + MON_3, +#define MON_3 MON_3 + MON_4, +#define MON_4 MON_4 + MON_5, +#define MON_5 MON_5 + MON_6, +#define MON_6 MON_6 + MON_7, +#define MON_7 MON_7 + MON_8, +#define MON_8 MON_8 + MON_9, +#define MON_9 MON_9 + MON_10, +#define MON_10 MON_10 + MON_11, +#define MON_11 MON_11 + MON_12, +#define MON_12 MON_12 + + AM_STR, /* Ante meridian string. */ +#define AM_STR AM_STR + PM_STR, /* Post meridian string. */ +#define PM_STR PM_STR + + D_T_FMT, /* Date and time format for strftime. */ +#define D_T_FMT D_T_FMT + D_FMT, /* Date format for strftime. */ +#define D_FMT D_FMT + T_FMT, /* Time format for strftime. */ +#define T_FMT T_FMT + T_FMT_AMPM, /* 12-hour time format for strftime. */ +#define T_FMT_AMPM T_FMT_AMPM + + ERA, /* Alternate era. */ +#define ERA ERA + __ERA_YEAR, /* Year in alternate era format. */ +#ifdef __USE_GNU +# define ERA_YEAR __ERA_YEAR +#endif + ERA_D_FMT, /* Date in alternate era format. */ +#define ERA_D_FMT ERA_D_FMT + ALT_DIGITS, /* Alternate symbols for digits. */ +#define ALT_DIGITS ALT_DIGITS + ERA_D_T_FMT, /* Date and time in alternate era format. */ +#define ERA_D_T_FMT ERA_D_T_FMT + ERA_T_FMT, /* Time in alternate era format. */ +#define ERA_T_FMT ERA_T_FMT + +#if 0 + _NL_TIME_ERA_NUM_ENTRIES, /* Number entries in the era arrays. */ + _NL_TIME_ERA_ENTRIES, /* Structure with era entries in usable form.*/ + + _NL_WABDAY_1, /* Sun */ + _NL_WABDAY_2, + _NL_WABDAY_3, + _NL_WABDAY_4, + _NL_WABDAY_5, + _NL_WABDAY_6, + _NL_WABDAY_7, + + /* Long-named days of the week. */ + _NL_WDAY_1, /* Sunday */ + _NL_WDAY_2, /* Monday */ + _NL_WDAY_3, /* Tuesday */ + _NL_WDAY_4, /* Wednesday */ + _NL_WDAY_5, /* Thursday */ + _NL_WDAY_6, /* Friday */ + _NL_WDAY_7, /* Saturday */ + + /* Abbreviated month names. */ + _NL_WABMON_1, /* Jan */ + _NL_WABMON_2, + _NL_WABMON_3, + _NL_WABMON_4, + _NL_WABMON_5, + _NL_WABMON_6, + _NL_WABMON_7, + _NL_WABMON_8, + _NL_WABMON_9, + _NL_WABMON_10, + _NL_WABMON_11, + _NL_WABMON_12, + + /* Long month names. */ + _NL_WMON_1, /* January */ + _NL_WMON_2, + _NL_WMON_3, + _NL_WMON_4, + _NL_WMON_5, + _NL_WMON_6, + _NL_WMON_7, + _NL_WMON_8, + _NL_WMON_9, + _NL_WMON_10, + _NL_WMON_11, + _NL_WMON_12, + + _NL_WAM_STR, /* Ante meridian string. */ + _NL_WPM_STR, /* Post meridian string. */ + + _NL_WD_T_FMT, /* Date and time format for strftime. */ + _NL_WD_FMT, /* Date format for strftime. */ + _NL_WT_FMT, /* Time format for strftime. */ + _NL_WT_FMT_AMPM, /* 12-hour time format for strftime. */ + + _NL_WERA_YEAR, /* Year in alternate era format. */ + _NL_WERA_D_FMT, /* Date in alternate era format. */ + _NL_WALT_DIGITS, /* Alternate symbols for digits. */ + _NL_WERA_D_T_FMT, /* Date and time in alternate era format. */ + _NL_WERA_T_FMT, /* Time in alternate era format. */ + + _NL_TIME_WEEK_NDAYS, + _NL_TIME_WEEK_1STDAY, + _NL_TIME_WEEK_1STWEEK, + _NL_TIME_FIRST_WEEKDAY, + _NL_TIME_FIRST_WORKDAY, + _NL_TIME_CAL_DIRECTION, + _NL_TIME_TIMEZONE, + + _DATE_FMT, /* strftime format for date. */ +#define _DATE_FMT _DATE_FMT + _NL_W_DATE_FMT, + + _NL_TIME_CODESET, +#endif /* 0 */ + + _NL_NUM_LC_TIME, /* Number of indices in LC_TIME category. */ + + /* LC_COLLATE category: text sorting. + This information is accessed by the strcoll and strxfrm functions. + These `nl_langinfo' names are used only internally. */ +#if 0 + _NL_COLLATE_NRULES = _NL_ITEM (__LC_COLLATE, 0), + _NL_COLLATE_RULESETS, + _NL_COLLATE_TABLEMB, + _NL_COLLATE_WEIGHTMB, + _NL_COLLATE_EXTRAMB, + _NL_COLLATE_INDIRECTMB, + _NL_COLLATE_GAP1, + _NL_COLLATE_GAP2, + _NL_COLLATE_GAP3, + _NL_COLLATE_TABLEWC, + _NL_COLLATE_WEIGHTWC, + _NL_COLLATE_EXTRAWC, + _NL_COLLATE_INDIRECTWC, + _NL_COLLATE_SYMB_HASH_SIZEMB, + _NL_COLLATE_SYMB_TABLEMB, + _NL_COLLATE_SYMB_EXTRAMB, + _NL_COLLATE_COLLSEQMB, + _NL_COLLATE_COLLSEQWC, + _NL_COLLATE_CODESET, + _NL_NUM_LC_COLLATE, +#endif + + /* LC_CTYPE category: character classification. + This information is accessed by the functions in . + These `nl_langinfo' names are used only internally. */ +#if 0 + _NL_CTYPE_CLASS = _NL_ITEM (__LC_CTYPE, 0), + _NL_CTYPE_TOUPPER, + _NL_CTYPE_GAP1, + _NL_CTYPE_TOLOWER, + _NL_CTYPE_GAP2, + _NL_CTYPE_CLASS32, + _NL_CTYPE_GAP3, + _NL_CTYPE_GAP4, + _NL_CTYPE_GAP5, + _NL_CTYPE_GAP6, + _NL_CTYPE_CLASS_NAMES, + _NL_CTYPE_MAP_NAMES, + _NL_CTYPE_WIDTH, + _NL_CTYPE_MB_CUR_MAX, + _NL_CTYPE_CODESET_NAME, + CODESET = _NL_CTYPE_CODESET_NAME, +#define CODESET CODESET + _NL_CTYPE_TOUPPER32, + _NL_CTYPE_TOLOWER32, + _NL_CTYPE_CLASS_OFFSET, + _NL_CTYPE_MAP_OFFSET, + _NL_CTYPE_INDIGITS_MB_LEN, + _NL_CTYPE_INDIGITS0_MB, + _NL_CTYPE_INDIGITS1_MB, + _NL_CTYPE_INDIGITS2_MB, + _NL_CTYPE_INDIGITS3_MB, + _NL_CTYPE_INDIGITS4_MB, + _NL_CTYPE_INDIGITS5_MB, + _NL_CTYPE_INDIGITS6_MB, + _NL_CTYPE_INDIGITS7_MB, + _NL_CTYPE_INDIGITS8_MB, + _NL_CTYPE_INDIGITS9_MB, + _NL_CTYPE_INDIGITS_WC_LEN, + _NL_CTYPE_INDIGITS0_WC, + _NL_CTYPE_INDIGITS1_WC, + _NL_CTYPE_INDIGITS2_WC, + _NL_CTYPE_INDIGITS3_WC, + _NL_CTYPE_INDIGITS4_WC, + _NL_CTYPE_INDIGITS5_WC, + _NL_CTYPE_INDIGITS6_WC, + _NL_CTYPE_INDIGITS7_WC, + _NL_CTYPE_INDIGITS8_WC, + _NL_CTYPE_INDIGITS9_WC, + _NL_CTYPE_OUTDIGIT0_MB, + _NL_CTYPE_OUTDIGIT1_MB, + _NL_CTYPE_OUTDIGIT2_MB, + _NL_CTYPE_OUTDIGIT3_MB, + _NL_CTYPE_OUTDIGIT4_MB, + _NL_CTYPE_OUTDIGIT5_MB, + _NL_CTYPE_OUTDIGIT6_MB, + _NL_CTYPE_OUTDIGIT7_MB, + _NL_CTYPE_OUTDIGIT8_MB, + _NL_CTYPE_OUTDIGIT9_MB, + _NL_CTYPE_OUTDIGIT0_WC, + _NL_CTYPE_OUTDIGIT1_WC, + _NL_CTYPE_OUTDIGIT2_WC, + _NL_CTYPE_OUTDIGIT3_WC, + _NL_CTYPE_OUTDIGIT4_WC, + _NL_CTYPE_OUTDIGIT5_WC, + _NL_CTYPE_OUTDIGIT6_WC, + _NL_CTYPE_OUTDIGIT7_WC, + _NL_CTYPE_OUTDIGIT8_WC, + _NL_CTYPE_OUTDIGIT9_WC, + _NL_CTYPE_TRANSLIT_TAB_SIZE, + _NL_CTYPE_TRANSLIT_FROM_IDX, + _NL_CTYPE_TRANSLIT_FROM_TBL, + _NL_CTYPE_TRANSLIT_TO_IDX, + _NL_CTYPE_TRANSLIT_TO_TBL, + _NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN, + _NL_CTYPE_TRANSLIT_DEFAULT_MISSING, + _NL_CTYPE_TRANSLIT_IGNORE_LEN, + _NL_CTYPE_TRANSLIT_IGNORE, + _NL_CTYPE_EXTRA_MAP_1, + _NL_CTYPE_EXTRA_MAP_2, + _NL_CTYPE_EXTRA_MAP_3, + _NL_CTYPE_EXTRA_MAP_4, + _NL_CTYPE_EXTRA_MAP_5, + _NL_CTYPE_EXTRA_MAP_6, + _NL_CTYPE_EXTRA_MAP_7, + _NL_CTYPE_EXTRA_MAP_8, + _NL_CTYPE_EXTRA_MAP_9, + _NL_CTYPE_EXTRA_MAP_10, + _NL_CTYPE_EXTRA_MAP_11, + _NL_CTYPE_EXTRA_MAP_12, + _NL_CTYPE_EXTRA_MAP_13, + _NL_CTYPE_EXTRA_MAP_14, + _NL_NUM_LC_CTYPE, +#else /* 0 */ + _NL_CTYPE_OUTDIGIT0_MB = _NL_ITEM (__LC_CTYPE, 0), + _NL_CTYPE_OUTDIGIT1_MB, + _NL_CTYPE_OUTDIGIT2_MB, + _NL_CTYPE_OUTDIGIT3_MB, + _NL_CTYPE_OUTDIGIT4_MB, + _NL_CTYPE_OUTDIGIT5_MB, + _NL_CTYPE_OUTDIGIT6_MB, + _NL_CTYPE_OUTDIGIT7_MB, + _NL_CTYPE_OUTDIGIT8_MB, + _NL_CTYPE_OUTDIGIT9_MB, + _NL_CTYPE_CODESET_NAME, /* uClibc note: MUST BE LAST ENTRY!!! */ + CODESET = _NL_CTYPE_CODESET_NAME, +#define CODESET CODESET +#endif /* 0 */ + + /* LC_MONETARY category: formatting of monetary quantities. + These items each correspond to a member of `struct lconv', + defined in . */ + __INT_CURR_SYMBOL = _NL_ITEM (__LC_MONETARY, 0), +#ifdef __USE_GNU +# define INT_CURR_SYMBOL __INT_CURR_SYMBOL +#endif + __CURRENCY_SYMBOL, +#ifdef __USE_GNU +# define CURRENCY_SYMBOL __CURRENCY_SYMBOL +#endif + __MON_DECIMAL_POINT, +#ifdef __USE_GNU +# define MON_DECIMAL_POINT __MON_DECIMAL_POINT +#endif + __MON_THOUSANDS_SEP, +#ifdef __USE_GNU +# define MON_THOUSANDS_SEP __MON_THOUSANDS_SEP +#endif + __MON_GROUPING, +#ifdef __USE_GNU +# define MON_GROUPING __MON_GROUPING +#endif + __POSITIVE_SIGN, +#ifdef __USE_GNU +# define POSITIVE_SIGN __POSITIVE_SIGN +#endif + __NEGATIVE_SIGN, +#ifdef __USE_GNU +# define NEGATIVE_SIGN __NEGATIVE_SIGN +#endif + __INT_FRAC_DIGITS, +#ifdef __USE_GNU +# define INT_FRAC_DIGITS __INT_FRAC_DIGITS +#endif + __FRAC_DIGITS, +#ifdef __USE_GNU +# define FRAC_DIGITS __FRAC_DIGITS +#endif + __P_CS_PRECEDES, +#ifdef __USE_GNU +# define P_CS_PRECEDES __P_CS_PRECEDES +#endif + __P_SEP_BY_SPACE, +#ifdef __USE_GNU +# define P_SEP_BY_SPACE __P_SEP_BY_SPACE +#endif + __N_CS_PRECEDES, +#ifdef __USE_GNU +# define N_CS_PRECEDES __N_CS_PRECEDES +#endif + __N_SEP_BY_SPACE, +#ifdef __USE_GNU +# define N_SEP_BY_SPACE __N_SEP_BY_SPACE +#endif + __P_SIGN_POSN, +#ifdef __USE_GNU +# define P_SIGN_POSN __P_SIGN_POSN +#endif + __N_SIGN_POSN, +#ifdef __USE_GNU +# define N_SIGN_POSN __N_SIGN_POSN +#endif + __INT_P_CS_PRECEDES, +#ifdef __USE_GNU +# define INT_P_CS_PRECEDES __INT_P_CS_PRECEDES +#endif + __INT_P_SEP_BY_SPACE, +#ifdef __USE_GNU +# define INT_P_SEP_BY_SPACE __INT_P_SEP_BY_SPACE +#endif + __INT_N_CS_PRECEDES, +#ifdef __USE_GNU +# define INT_N_CS_PRECEDES __INT_N_CS_PRECEDES +#endif + __INT_N_SEP_BY_SPACE, +#ifdef __USE_GNU +# define INT_N_SEP_BY_SPACE __INT_N_SEP_BY_SPACE +#endif + __INT_P_SIGN_POSN, +#ifdef __USE_GNU +# define INT_P_SIGN_POSN __INT_P_SIGN_POSN +#endif + __INT_N_SIGN_POSN, +#ifdef __USE_GNU +# define INT_N_SIGN_POSN __INT_N_SIGN_POSN +#endif + + _NL_MONETARY_CRNCYSTR, +#define CRNCYSTR _NL_MONETARY_CRNCYSTR + +#if 0 + _NL_MONETARY_DUO_INT_CURR_SYMBOL, + _NL_MONETARY_DUO_CURRENCY_SYMBOL, + _NL_MONETARY_DUO_INT_FRAC_DIGITS, + _NL_MONETARY_DUO_FRAC_DIGITS, + _NL_MONETARY_DUO_P_CS_PRECEDES, + _NL_MONETARY_DUO_P_SEP_BY_SPACE, + _NL_MONETARY_DUO_N_CS_PRECEDES, + _NL_MONETARY_DUO_N_SEP_BY_SPACE, + _NL_MONETARY_DUO_INT_P_CS_PRECEDES, + _NL_MONETARY_DUO_INT_P_SEP_BY_SPACE, + _NL_MONETARY_DUO_INT_N_CS_PRECEDES, + _NL_MONETARY_DUO_INT_N_SEP_BY_SPACE, + _NL_MONETARY_DUO_P_SIGN_POSN, + _NL_MONETARY_DUO_N_SIGN_POSN, + _NL_MONETARY_DUO_INT_P_SIGN_POSN, + _NL_MONETARY_DUO_INT_N_SIGN_POSN, + _NL_MONETARY_UNO_VALID_FROM, + _NL_MONETARY_UNO_VALID_TO, + _NL_MONETARY_DUO_VALID_FROM, + _NL_MONETARY_DUO_VALID_TO, + _NL_MONETARY_CONVERSION_RATE, + _NL_MONETARY_DECIMAL_POINT_WC, + _NL_MONETARY_THOUSANDS_SEP_WC, + _NL_MONETARY_CODESET, +#endif /* 0 */ + _NL_NUM_LC_MONETARY, + + /* LC_NUMERIC category: formatting of numbers. + These also correspond to members of `struct lconv'; see . */ + __DECIMAL_POINT = _NL_ITEM (__LC_NUMERIC, 0), +#ifdef __USE_GNU +# define DECIMAL_POINT __DECIMAL_POINT +#endif + RADIXCHAR = __DECIMAL_POINT, +#define RADIXCHAR RADIXCHAR + __THOUSANDS_SEP, +#ifdef __USE_GNU +# define THOUSANDS_SEP __THOUSANDS_SEP +#endif + THOUSEP = __THOUSANDS_SEP, +#define THOUSEP THOUSEP + __GROUPING, +#ifdef __USE_GNU +# define GROUPING __GROUPING +#endif +#if 0 + _NL_NUMERIC_DECIMAL_POINT_WC, + _NL_NUMERIC_THOUSANDS_SEP_WC, + _NL_NUMERIC_CODESET, +#endif + _NL_NUM_LC_NUMERIC, + + __YESEXPR = _NL_ITEM (__LC_MESSAGES, 0), /* Regex matching ``yes'' input. */ +#define YESEXPR __YESEXPR + __NOEXPR, /* Regex matching ``no'' input. */ +#define NOEXPR __NOEXPR + __YESSTR, /* Output string for ``yes''. */ +#if defined __USE_GNU || (defined __USE_XOPEN && !defined __USE_XOPEN2K) +# define YESSTR __YESSTR +#endif + __NOSTR, /* Output string for ``no''. */ +#if defined __USE_GNU || (defined __USE_XOPEN && !defined __USE_XOPEN2K) +# define NOSTR __NOSTR +#endif +#if 0 + _NL_MESSAGES_CODESET, +#endif + _NL_NUM_LC_MESSAGES, + +#if 0 + _NL_PAPER_HEIGHT = _NL_ITEM (__LC_PAPER, 0), + _NL_PAPER_WIDTH, + _NL_PAPER_CODESET, + _NL_NUM_LC_PAPER, + + _NL_NAME_NAME_FMT = _NL_ITEM (__LC_NAME, 0), + _NL_NAME_NAME_GEN, + _NL_NAME_NAME_MR, + _NL_NAME_NAME_MRS, + _NL_NAME_NAME_MISS, + _NL_NAME_NAME_MS, + _NL_NAME_CODESET, + _NL_NUM_LC_NAME, + + _NL_ADDRESS_POSTAL_FMT = _NL_ITEM (__LC_ADDRESS, 0), + _NL_ADDRESS_COUNTRY_NAME, + _NL_ADDRESS_COUNTRY_POST, + _NL_ADDRESS_COUNTRY_AB2, + _NL_ADDRESS_COUNTRY_AB3, + _NL_ADDRESS_COUNTRY_CAR, + _NL_ADDRESS_COUNTRY_NUM, + _NL_ADDRESS_COUNTRY_ISBN, + _NL_ADDRESS_LANG_NAME, + _NL_ADDRESS_LANG_AB, + _NL_ADDRESS_LANG_TERM, + _NL_ADDRESS_LANG_LIB, + _NL_ADDRESS_CODESET, + _NL_NUM_LC_ADDRESS, + + _NL_TELEPHONE_TEL_INT_FMT = _NL_ITEM (__LC_TELEPHONE, 0), + _NL_TELEPHONE_TEL_DOM_FMT, + _NL_TELEPHONE_INT_SELECT, + _NL_TELEPHONE_INT_PREFIX, + _NL_TELEPHONE_CODESET, + _NL_NUM_LC_TELEPHONE, + + _NL_MEASUREMENT_MEASUREMENT = _NL_ITEM (__LC_MEASUREMENT, 0), + _NL_MEASUREMENT_CODESET, + _NL_NUM_LC_MEASUREMENT, + + _NL_IDENTIFICATION_TITLE = _NL_ITEM (__LC_IDENTIFICATION, 0), + _NL_IDENTIFICATION_SOURCE, + _NL_IDENTIFICATION_ADDRESS, + _NL_IDENTIFICATION_CONTACT, + _NL_IDENTIFICATION_EMAIL, + _NL_IDENTIFICATION_TEL, + _NL_IDENTIFICATION_FAX, + _NL_IDENTIFICATION_LANGUAGE, + _NL_IDENTIFICATION_TERRITORY, + _NL_IDENTIFICATION_AUDIENCE, + _NL_IDENTIFICATION_APPLICATION, + _NL_IDENTIFICATION_ABBREVIATION, + _NL_IDENTIFICATION_REVISION, + _NL_IDENTIFICATION_DATE, + _NL_IDENTIFICATION_CATEGORY, + _NL_IDENTIFICATION_CODESET, + _NL_NUM_LC_IDENTIFICATION, +#endif + /* This marks the highest value used. */ + _NL_NUM +}; + + +/* Return the current locale's value for ITEM. + If ITEM is invalid, an empty string is returned. + + The string returned will not change until `setlocale' is called; + it is usually in read-only memory and cannot be modified. */ + +extern char *nl_langinfo (nl_item __item) __THROW; + + +#ifdef __UCLIBC_HAS_XLOCALE__ +#ifdef __USE_GNU +/* This interface is for the extended locale model. See for + more information. */ + +/* Get locale datatype definition. */ +# include + +/* Just like nl_langinfo but get the information from the locale object L. */ +extern char *nl_langinfo_l (nl_item __item, __locale_t l); +#endif +#endif + +__END_DECLS + +#endif /* langinfo.h */ diff --git a/conts/posix/libposix/include/posix/lastlog.h b/conts/posix/libposix/include/posix/lastlog.h new file mode 100644 index 0000000..8cc4254 --- /dev/null +++ b/conts/posix/libposix/include/posix/lastlog.h @@ -0,0 +1,4 @@ +/* This header file is used in 4.3BSD to define `struct lastlog', + which we define in . */ + +#include diff --git a/conts/posix/libposix/include/posix/libc-internal.h b/conts/posix/libposix/include/posix/libc-internal.h new file mode 100644 index 0000000..7b2566f --- /dev/null +++ b/conts/posix/libposix/include/posix/libc-internal.h @@ -0,0 +1,100 @@ +/* Copyright (C) 1991,92,93,95,96,97,98,99,2000,2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _LIBC_INTERNAL_H +#define _LIBC_INTERNAL_H 1 + +#include + +#ifdef __UCLIBC_BUILD_RELRO__ +# define attribute_relro __attribute__ ((section (".data.rel.ro"))) +#else +# define attribute_relro +#endif + +#ifdef __UCLIBC_HAS_THREADS_NATIVE__ +# define attribute_tls_model_ie __attribute__ ((tls_model ("initial-exec"))) +#endif + +/* Pull in things like __attribute_used__ */ +#include + +/* --- this is added to integrate linuxthreads */ +/*#define __USE_UNIX98 1*/ + +#ifndef __ASSEMBLER__ +# ifdef IS_IN_libc + +# define __need_size_t +# include + +/* sources are built w/ _GNU_SOURCE, this gets undefined */ +#ifdef __USE_GNU +extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen); +#else +extern char *__glibc_strerror_r (int __errnum, char *__buf, size_t __buflen); +#endif + +/* #include */ +# ifndef __UCLIBC_HAS_THREADS__ +# define __pthread_mutex_init(mutex, mutexattr) ((void)0) +# define __pthread_mutex_lock(mutex) ((void)0) +# define __pthread_mutex_trylock(mutex) ((void)0) +# define __pthread_mutex_unlock(mutex) ((void)0) +# define _pthread_cleanup_push_defer(mutex) ((void)0) +# define _pthread_cleanup_pop_restore(mutex) ((void)0) +# endif + +/* internal access to program name */ +extern const char *__uclibc_progname attribute_hidden; + +# endif /* IS_IN_libc */ + +/* #include */ +#include +#if defined(_STACK_GROWS_DOWN) +# define extend_alloca(buf, len, newlen) \ + (__typeof (buf)) ({ size_t __newlen = (newlen); \ + char *__newbuf = alloca (__newlen); \ + if (__newbuf + __newlen == (char *) buf) \ + len += __newlen; \ + else \ + len = __newlen; \ + __newbuf; }) +#elif defined(_STACK_GROWS_UP) +# define extend_alloca(buf, len, newlen) \ + (__typeof (buf)) ({ size_t __newlen = (newlen); \ + char *__newbuf = alloca (__newlen); \ + char *__buf = (buf); \ + if (__buf + __newlen == __newbuf) \ + { \ + len += __newlen; \ + __newbuf = __buf; \ + } \ + else \ + len = __newlen; \ + __newbuf; }) +#else +# warning unknown stack +# define extend_alloca(buf, len, newlen) \ + alloca (((len) = (newlen))) +#endif + +#endif /* __ASSEMBLER__ */ + +#endif /* _LIBC_INTERNAL_H */ diff --git a/conts/posix/libposix/include/posix/libc-symbols.h b/conts/posix/libposix/include/posix/libc-symbols.h new file mode 100644 index 0000000..2933431 --- /dev/null +++ b/conts/posix/libposix/include/posix/libc-symbols.h @@ -0,0 +1,726 @@ +/* Support macros for making weak and strong aliases for symbols, + and for using symbol sets and linker warnings with GNU ld. + Copyright (C) 1995-1998,2000-2003,2004,2005,2006 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _LIBC_SYMBOLS_H +#define _LIBC_SYMBOLS_H 1 + +/* This is defined for the compilation of all C library code. features.h + tests this to avoid inclusion of stubs.h while compiling the library, + before stubs.h has been generated. Some library code that is shared + with other packages also tests this symbol to see if it is being + compiled as part of the C library. We must define this before including + config.h, because it makes some definitions conditional on whether libc + itself is being compiled, or just some generator program. */ +#define _LIBC 1 + + +/* This file's macros are included implicitly in the compilation of every + file in the C library by -imacros. + + We include uClibc_arch_features.h which is defined by arch devs. + It should define for us the following symbols: + + * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'. + * ASM_GLOBAL_DIRECTIVE with `.globl' or `.global'. + * ASM_TYPE_DIRECTIVE_PREFIX with `@' or `#' or whatever for .type, + or leave it undefined if there is no .type directive. + * HAVE_ELF if using ELF, which supports weak symbols using `.weak'. + * HAVE_ASM_WEAK_DIRECTIVE if we have weak symbols using `.weak'. + * HAVE_ASM_WEAKEXT_DIRECTIVE if we have weak symbols using `.weakext'. + + */ + +#include + +/* Enable declarations of GNU extensions, since we are compiling them. */ +#define _GNU_SOURCE 1 + +/* Prepare for the case that `__builtin_expect' is not available. */ +#if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ < 96 +# define __builtin_expect(x, expected_value) (x) +#endif +#ifndef likely +# define likely(x) __builtin_expect((!!(x)),1) +#endif +#ifndef unlikely +# define unlikely(x) __builtin_expect((!!(x)),0) +#endif +#ifndef __LINUX_COMPILER_H +# define __LINUX_COMPILER_H +#endif +#ifndef __cast__ +# define __cast__(_to) +#endif + +#define attribute_unused __attribute__ ((unused)) + +#if defined __GNUC__ || defined __ICC +# define attribute_noreturn __attribute__ ((__noreturn__)) +#else +# define attribute_noreturn +#endif + +#ifndef NOT_IN_libc +# define IS_IN_libc 1 +#endif + +#ifdef __UCLIBC_NO_UNDERSCORES__ +# define NO_UNDERSCORES +#else +# undef NO_UNDERSCORES +#endif + +#ifdef __UCLIBC_HAVE_ASM_SET_DIRECTIVE__ +# define HAVE_ASM_SET_DIRECTIVE +#else +# undef HAVE_ASM_SET_DIRECTIVE +#endif + +#ifdef __UCLIBC_ASM_GLOBAL_DIRECTIVE__ +# define ASM_GLOBAL_DIRECTIVE __UCLIBC_ASM_GLOBAL_DIRECTIVE__ +#else +# define ASM_GLOBAL_DIRECTIVE .global +#endif + +#ifdef __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__ +# define HAVE_ASM_WEAK_DIRECTIVE +#else +# undef HAVE_ASM_WEAK_DIRECTIVE +#endif + +#ifdef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__ +# define HAVE_ASM_WEAKEXT_DIRECTIVE +#else +# undef HAVE_ASM_WEAKEXT_DIRECTIVE +#endif + +#ifdef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__ +# define HAVE_ASM_GLOBAL_DOT_NAME +#else +# undef HAVE_ASM_GLOBAL_DOT_NAME +#endif + +#if defined HAVE_ASM_WEAK_DIRECTIVE || defined HAVE_ASM_WEAKEXT_DIRECTIVE +# define HAVE_WEAK_SYMBOLS +#endif + +#undef C_SYMBOL_NAME +#ifndef C_SYMBOL_NAME +# ifdef NO_UNDERSCORES +# define C_SYMBOL_NAME(name) name +# else +# define C_SYMBOL_NAME(name) _##name +# endif +#endif + +#ifdef __UCLIBC_ASM_LINE_SEP__ +# define ASM_LINE_SEP __UCLIBC_ASM_LINE_SEP__ +#else +# define ASM_LINE_SEP ; +#endif + +#ifdef HAVE_ASM_GLOBAL_DOT_NAME +# ifndef C_SYMBOL_DOT_NAME +# if defined __GNUC__ && defined __GNUC_MINOR__ \ + && (__GNUC__ << 16) + __GNUC_MINOR__ >= (3 << 16) + 1 +# define C_SYMBOL_DOT_NAME(name) .name +# else +# define C_SYMBOL_DOT_NAME(name) .##name +# endif +# endif +#endif + +#ifndef __ASSEMBLER__ +/* GCC understands weak symbols and aliases; use its interface where + possible, instead of embedded assembly language. */ + +/* Define ALIASNAME as a strong alias for NAME. */ +# define strong_alias(name, aliasname) _strong_alias(name, aliasname) +# define _strong_alias(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((alias (#name))); + +/* This comes between the return type and function name in + a function definition to make that definition weak. */ +# define weak_function __attribute__ ((weak)) +# define weak_const_function __attribute__ ((weak, __const__)) + +# ifdef HAVE_WEAK_SYMBOLS + +/* Define ALIASNAME as a weak alias for NAME. + If weak aliases are not available, this defines a strong alias. */ +# define weak_alias(name, aliasname) _weak_alias (name, aliasname) +# define _weak_alias(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))); + +/* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */ +# define weak_extern(symbol) _weak_extern (weak symbol) +# define _weak_extern(expr) _Pragma (#expr) + +# else + +# define weak_alias(name, aliasname) strong_alias(name, aliasname) +# define weak_extern(symbol) /* Nothing. */ + +# endif + +#else /* __ASSEMBLER__ */ + +# ifdef HAVE_ASM_SET_DIRECTIVE +# ifdef HAVE_ASM_GLOBAL_DOT_NAME +# define strong_alias(original, alias) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \ + .set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original) +# define strong_data_alias(original, alias) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) +# else +# define strong_alias(original, alias) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) +# define strong_data_alias(original, alias) strong_alias(original, alias) +# endif +# else +# ifdef HAVE_ASM_GLOBAL_DOT_NAME +# define strong_alias(original, alias) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \ + C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original) +# define strong_data_alias(original, alias) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) +# else +# define strong_alias(original, alias) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) +# define strong_data_alias(original, alias) strong_alias(original, alias) +# endif +# endif + +# ifdef HAVE_WEAK_SYMBOLS +# ifdef HAVE_ASM_WEAKEXT_DIRECTIVE +# ifdef HAVE_ASM_GLOBAL_DOT_NAME +# define weak_alias(original, alias) \ + .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \ + .weakext C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original) +# else +# define weak_alias(original, alias) \ + .weakext C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) +# endif +# define weak_extern(symbol) \ + .weakext C_SYMBOL_NAME (symbol) + +# else /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */ + +# ifdef HAVE_ASM_SET_DIRECTIVE +# ifdef HAVE_ASM_GLOBAL_DOT_NAME +# define weak_alias(original, alias) \ + .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + .set C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) ASM_LINE_SEP \ + .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \ + .set C_SYMBOL_DOT_NAME (alias), C_SYMBOL_DOT_NAME (original) +# else +# define weak_alias(original, alias) \ + .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + .set C_SYMBOL_NAME (alias), C_SYMBOL_NAME (original) +# endif +# else /* ! HAVE_ASM_SET_DIRECTIVE */ +# ifdef HAVE_ASM_GLOBAL_DOT_NAME +# define weak_alias(original, alias) \ + .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \ + .weak C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \ + C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original) +# else +# define weak_alias(original, alias) \ + .weak C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) +# endif +# endif +# define weak_extern(symbol) \ + .weak C_SYMBOL_NAME (symbol) + +# endif /* ! HAVE_ASM_WEAKEXT_DIRECTIVE */ + +# else /* ! HAVE_WEAK_SYMBOLS */ + +# define weak_alias(original, alias) strong_alias(original, alias) +# define weak_extern(symbol) /* Nothing */ +# endif /* ! HAVE_WEAK_SYMBOLS */ + +#endif /* __ASSEMBLER__ */ + +/* On some platforms we can make internal function calls (i.e., calls of + functions not exported) a bit faster by using a different calling + convention. */ +#ifndef internal_function +# define internal_function /* empty */ +#endif + +/* We want the .gnu.warning.SYMBOL section to be unallocated. */ +#define __make_section_unallocated(section_string) \ + __asm__ (".section " section_string "\n\t.previous"); + +/* Tacking on "\n#APP\n\t#" to the section name makes gcc put it's bogus + section attributes on what looks like a comment to the assembler. */ +#ifdef __sparc__ //HAVE_SECTION_QUOTES +# define __sec_comment "\"\n#APP\n\t#\"" +#else +# define __sec_comment "\n#APP\n\t#" +#endif + +/* When a reference to SYMBOL is encountered, the linker will emit a + warning message MSG. */ +#define link_warning(symbol, msg) \ + __make_section_unallocated (".gnu.warning." #symbol) \ + static const char __evoke_link_warning_##symbol[] \ + __attribute__ ((used, section (".gnu.warning." #symbol __sec_comment))) \ + = msg; + +/* Handling on non-exported internal names. We have to do this only + for shared code. */ +#ifdef SHARED +# define INTUSE(name) name##_internal +# define INTDEF(name) strong_alias (name, name##_internal) +# define INTVARDEF(name) \ + _INTVARDEF (name, name##_internal) +# if defined HAVE_VISIBILITY_ATTRIBUTE +# define _INTVARDEF(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((alias (#name), \ + visibility ("hidden"))); +# else +# define _INTVARDEF(name, aliasname) \ + extern __typeof (name) aliasname __attribute__ ((alias (#name))); +# endif +# define INTDEF2(name, newname) strong_alias (name, newname##_internal) +# define INTVARDEF2(name, newname) _INTVARDEF (name, newname##_internal) +#else +# define INTUSE(name) name +# define INTDEF(name) +# define INTVARDEF(name) +# define INTDEF2(name, newname) +# define INTVARDEF2(name, newname) +#endif + +/* The following macros are used for PLT bypassing within libc.so + (and if needed other libraries similarly). + First of all, you need to have the function prototyped somewhere, + say in foo/foo.h: + + int foo (int __bar); + + If calls to foo within libc.so should always go to foo defined in libc.so, + then in include/foo.h you add: + + libc_hidden_proto (foo) + + line and after the foo function definition: + + int foo (int __bar) + { + return __bar; + } + libc_hidden_def (foo) + + or + + int foo (int __bar) + { + return __bar; + } + libc_hidden_weak (foo) + + Similarly for global data. If references to foo within libc.so should + always go to foo defined in libc.so, then in include/foo.h you add: + + libc_hidden_proto (foo) + + line and after foo's definition: + + int foo = INITIAL_FOO_VALUE; + libc_hidden_data_def (foo) + + or + + int foo = INITIAL_FOO_VALUE; + libc_hidden_data_weak (foo) + + If foo is normally just an alias (strong or weak) to some other function, + you should use the normal strong_alias first, then add libc_hidden_def + or libc_hidden_weak: + + int baz (int __bar) + { + return __bar; + } + strong_alias (baz, foo) + libc_hidden_weak (foo) + + If the function should be internal to multiple objects, say ld.so and + libc.so, the best way is to use: + + #if !defined NOT_IN_libc || defined IS_IN_rtld + hidden_proto (foo) + #endif + + in include/foo.h and the normal macros at all function definitions + depending on what DSO they belong to. + + If versioned_symbol macro is used to define foo, + libc_hidden_ver macro should be used, as in: + + int __real_foo (int __bar) + { + return __bar; + } + versioned_symbol (libc, __real_foo, foo, GLIBC_2_1); + libc_hidden_ver (__real_foo, foo) */ + +/* uClibc specific (the above comment was copied from glibc): + * a. when ppc64 will be supported, we need changes to support: + * strong_data_alias (used by asm hidden_data_def) + * b. libc_hidden_proto(foo) should be added after the header having foo's prototype + * or after extern foo... to all source files that should use the internal version + * of foo within libc, even to the file defining foo itself, libc_hidden_def does + * not hide __GI_foo itself, although the name suggests it (hiding is done exclusively + * by libc_hidden_proto). The reasoning to have it after the header w/ foo's prototype is + * to get first the __REDIRECT from original header and then create the __GI_foo alias + * c. no versioning support, hidden[_data]_ver are noop + * d. hidden_def() in asm is _hidden_strong_alias (not strong_alias) */ + +/* Arrange to hide uClibc internals */ +#if (defined __GNUC__ && \ + (defined __GNUC_MINOR__ && ( __GNUC__ >= 3 && __GNUC_MINOR__ >= 3 ) \ + || __GNUC__ >= 4)) || defined __ICC +# define attribute_hidden __attribute__ ((visibility ("hidden"))) +# define __hidden_proto_hiddenattr(attrs...) __attribute__ ((visibility ("hidden"), ##attrs)) +#else +# define attribute_hidden +# define __hidden_proto_hiddenattr(attrs...) +#endif + +#if /*!defined STATIC &&*/ !defined __BCC__ +# ifndef __ASSEMBLER__ +# define hidden_proto(name, attrs...) __hidden_proto (name, __GI_##name, ##attrs) +# define __hidden_proto(name, internal, attrs...) \ + extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \ + __hidden_proto_hiddenattr (attrs); +# define __hidden_asmname(name) __hidden_asmname1 (__USER_LABEL_PREFIX__, name) +# define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name) +# define __hidden_asmname2(prefix, name) #prefix name +# define __hidden_ver1(local, internal, name) \ + extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \ + extern __typeof (name) __EI_##name __attribute__((alias (__hidden_asmname1 (,#local)))) +# define hidden_ver(local, name) __hidden_ver1(local, __GI_##name, name); +# define hidden_data_ver(local, name) hidden_ver(local, name) +# define hidden_def(name) __hidden_ver1(__GI_##name, name, name); +# define hidden_data_def(name) hidden_def(name) +# define hidden_weak(name) \ + __hidden_ver1(__GI_##name, name, name) __attribute__((weak)); +# define hidden_data_weak(name) hidden_weak(name) + +# else /* __ASSEMBLER__ */ +# ifdef HAVE_ASM_SET_DIRECTIVE +# ifdef HAVE_ASM_GLOBAL_DOT_NAME +# define _hidden_strong_alias(original, alias) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) ASM_LINE_SEP \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \ + .hidden C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \ + .set C_SYMBOL_DOT_NAME (alias),C_SYMBOL_DOT_NAME (original) +# else +# define _hidden_strong_alias(original, alias) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + .set C_SYMBOL_NAME (alias),C_SYMBOL_NAME (original) +# endif +# else +# ifdef HAVE_ASM_GLOBAL_DOT_NAME +# define _hidden_strong_alias(original, alias) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) ASM_LINE_SEP \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \ + .hidden C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \ + C_SYMBOL_DOT_NAME (alias) = C_SYMBOL_DOT_NAME (original) +# else +# define _hidden_strong_alias(original, alias) \ + ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + C_SYMBOL_NAME (alias) = C_SYMBOL_NAME (original) +# endif +# endif + +# ifdef HAVE_ASM_GLOBAL_DOT_NAME +# define _hidden_weak_alias(original, alias) \ + .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + .hidden C_SYMBOL_DOT_NAME (alias) ASM_LINE_SEP \ + weak_alias(original, alias) +# else +# define _hidden_weak_alias(original, alias) \ + .hidden C_SYMBOL_NAME (alias) ASM_LINE_SEP \ + weak_alias(original, alias) +# endif + +/* For assembly, we need to do the opposite of what we do in C: + in assembly gcc __REDIRECT stuff is not in place, so functions + are defined by its normal name and we need to create the + __GI_* alias to it, in C __REDIRECT causes the function definition + to use __GI_* name and we need to add alias to the real name. + There is no reason to use hidden_weak over hidden_def in assembly, + but we provide it for consistency with the C usage. + hidden_proto doesn't make sense for assembly but the equivalent + is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET. */ +# define hidden_def(name) _hidden_strong_alias (name, __GI_##name) +# define hidden_weak(name) _hidden_weak_alias (name, __GI_##name) +# define hidden_ver(local, name) strong_alias (local, __GI_##name) +# define hidden_data_def(name) _hidden_strong_alias (name, __GI_##name) +# define hidden_data_weak(name) _hidden_weak_alias (name, __GI_##name) +# define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name) +# ifdef HAVE_ASM_GLOBAL_DOT_NAME +# define HIDDEN_JUMPTARGET(name) .__GI_##name +# else +# define HIDDEN_JUMPTARGET(name) __GI_##name +# endif +# endif /* __ASSEMBLER__ */ +#else /* SHARED */ +# ifndef __ASSEMBLER__ +# define hidden_proto(name, attrs...) +# else +# define HIDDEN_JUMPTARGET(name) name +# endif /* Not __ASSEMBLER__ */ +# define hidden_weak(name) +# define hidden_def(name) +# define hidden_ver(local, name) +# define hidden_data_weak(name) +# define hidden_data_def(name) +# define hidden_data_ver(local, name) +#endif /* SHARED */ + +/* uClibc does not support versioning yet. */ +#define versioned_symbol(lib, local, symbol, version) /* weak_alias(local, symbol) */ +#undef hidden_ver +#define hidden_ver(local, name) /* strong_alias(local, __GI_##name) */ +#undef hidden_data_ver +#define hidden_data_ver(local, name) /* strong_alias(local,__GI_##name) */ + +#if !defined NOT_IN_libc +# define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) +# define libc_hidden_def(name) hidden_def (name) +# define libc_hidden_weak(name) hidden_weak (name) +# define libc_hidden_ver(local, name) hidden_ver (local, name) +# define libc_hidden_data_def(name) hidden_data_def (name) +# define libc_hidden_data_weak(name) hidden_data_weak (name) +# define libc_hidden_data_ver(local, name) hidden_data_ver (local, name) +#else +# define libc_hidden_proto(name, attrs...) +# define libc_hidden_def(name) +# define libc_hidden_weak(name) +# define libc_hidden_ver(local, name) +# define libc_hidden_data_def(name) +# define libc_hidden_data_weak(name) +# define libc_hidden_data_ver(local, name) +#endif + +#if defined NOT_IN_libc && defined IS_IN_rtld +# define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) +# define rtld_hidden_def(name) hidden_def (name) +# define rtld_hidden_weak(name) hidden_weak (name) +# define rtld_hidden_ver(local, name) hidden_ver (local, name) +# define rtld_hidden_data_def(name) hidden_data_def (name) +# define rtld_hidden_data_weak(name) hidden_data_weak (name) +# define rtld_hidden_data_ver(local, name) hidden_data_ver (local, name) +#else +# define rtld_hidden_proto(name, attrs...) +# define rtld_hidden_def(name) +# define rtld_hidden_weak(name) +# define rtld_hidden_ver(local, name) +# define rtld_hidden_data_def(name) +# define rtld_hidden_data_weak(name) +# define rtld_hidden_data_ver(local, name) +#endif + +#if defined NOT_IN_libc && defined IS_IN_libm +# define libm_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) +# define libm_hidden_def(name) hidden_def (name) +# define libm_hidden_weak(name) hidden_weak (name) +# define libm_hidden_ver(local, name) hidden_ver (local, name) +# define libm_hidden_data_def(name) hidden_data_def (name) +# define libm_hidden_data_weak(name) hidden_data_weak (name) +# define libm_hidden_data_ver(local, name) hidden_data_ver (local, name) +#else +# define libm_hidden_proto(name, attrs...) +# define libm_hidden_def(name) +# define libm_hidden_weak(name) +# define libm_hidden_ver(local, name) +# define libm_hidden_data_def(name) +# define libm_hidden_data_weak(name) +# define libm_hidden_data_ver(local, name) +#endif + +#if defined NOT_IN_libc && defined IS_IN_libresolv +# define libresolv_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) +# define libresolv_hidden_def(name) hidden_def (name) +# define libresolv_hidden_weak(name) hidden_weak (name) +# define libresolv_hidden_ver(local, name) hidden_ver (local, name) +# define libresolv_hidden_data_def(name) hidden_data_def (name) +# define libresolv_hidden_data_weak(name) hidden_data_weak (name) +# define libresolv_hidden_data_ver(local, name) hidden_data_ver (local, name) +#else +# define libresolv_hidden_proto(name, attrs...) +# define libresolv_hidden_def(name) +# define libresolv_hidden_weak(name) +# define libresolv_hidden_ver(local, name) +# define libresolv_hidden_data_def(name) +# define libresolv_hidden_data_weak(name) +# define libresolv_hidden_data_ver(local, name) +#endif + +#if defined NOT_IN_libc && defined IS_IN_librt +# define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) +# define librt_hidden_def(name) hidden_def (name) +# define librt_hidden_weak(name) hidden_weak (name) +# define librt_hidden_ver(local, name) hidden_ver (local, name) +# define librt_hidden_data_def(name) hidden_data_def (name) +# define librt_hidden_data_weak(name) hidden_data_weak (name) +# define librt_hidden_data_ver(local, name) hidden_data_ver (local, name) +#else +# define librt_hidden_proto(name, attrs...) +# define librt_hidden_def(name) +# define librt_hidden_weak(name) +# define librt_hidden_ver(local, name) +# define librt_hidden_data_def(name) +# define librt_hidden_data_weak(name) +# define librt_hidden_data_ver(local, name) +#endif + +#if defined NOT_IN_libc && defined IS_IN_libdl +# define libdl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) +# define libdl_hidden_def(name) hidden_def (name) +# define libdl_hidden_weak(name) hidden_weak (name) +# define libdl_hidden_ver(local, name) hidden_ver (local, name) +# define libdl_hidden_data_def(name) hidden_data_def (name) +# define libdl_hidden_data_weak(name) hidden_data_weak (name) +# define libdl_hidden_data_ver(local, name) hidden_data_ver (local, name) +#else +# define libdl_hidden_proto(name, attrs...) +# define libdl_hidden_def(name) +# define libdl_hidden_weak(name) +# define libdl_hidden_ver(local, name) +# define libdl_hidden_data_def(name) +# define libdl_hidden_data_weak(name) +# define libdl_hidden_data_ver(local, name) +#endif + +#if defined NOT_IN_libc && defined IS_IN_libintl +# define libintl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) +# define libintl_hidden_def(name) hidden_def (name) +# define libintl_hidden_weak(name) hidden_weak (name) +# define libintl_hidden_ver(local, name) hidden_ver (local, name) +# define libintl_hidden_data_def(name) hidden_data_def (name) +# define libintl_hidden_data_weak(name) hidden_data_weak (name) +# define libintl_hidden_data_ver(local, name) hidden_data_ver(local, name) +#else +# define libintl_hidden_proto(name, attrs...) +# define libintl_hidden_def(name) +# define libintl_hidden_weak(name) +# define libintl_hidden_ver(local, name) +# define libintl_hidden_data_def(name) +# define libintl_hidden_data_weak(name) +# define libintl_hidden_data_ver(local, name) +#endif + +#if defined NOT_IN_libc && defined IS_IN_libnsl +# define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) +# define libnsl_hidden_def(name) hidden_def (name) +# define libnsl_hidden_weak(name) hidden_weak (name) +# define libnsl_hidden_ver(local, name) hidden_ver (local, name) +# define libnsl_hidden_data_def(name) hidden_data_def (name) +# define libnsl_hidden_data_weak(name) hidden_data_weak (name) +# define libnsl_hidden_data_ver(local, name) hidden_data_ver (local, name) +#else +# define libnsl_hidden_proto(name, attrs...) +# define libnsl_hidden_def(name) +# define libnsl_hidden_weak(name) +# define libnsl_hidden_ver(local, name) +# define libnsl_hidden_data_def(name) +# define libnsl_hidden_data_weak(name) +# define libnsl_hidden_data_ver(local, name) +#endif + +#if defined NOT_IN_libc && defined IS_IN_libutil +# define libutil_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) +# define libutil_hidden_def(name) hidden_def (name) +# define libutil_hidden_weak(name) hidden_weak (name) +# define libutil_hidden_ver(local, name) hidden_ver (local, name) +# define libutil_hidden_data_def(name) hidden_data_def (name) +# define libutil_hidden_data_weak(name) hidden_data_weak (name) +# define libutil_hidden_data_ver(local, name) hidden_data_ver (local, name) +#else +# define libutil_hidden_proto(name, attrs...) +# define libutil_hidden_def(name) +# define libutil_hidden_weak(name) +# define libutil_hidden_ver(local, name) +# define libutil_hidden_data_def(name) +# define libutil_hidden_data_weak(name) +# define libutil_hidden_data_ver(local, name) +#endif + +#if defined NOT_IN_libc && defined IS_IN_libcrypt +# define libcrypt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) +# define libcrypt_hidden_def(name) hidden_def (name) +# define libcrypt_hidden_weak(name) hidden_weak (name) +# define libcrypt_hidden_ver(local, name) hidden_ver (local, name) +# define libcrypt_hidden_data_def(name) hidden_data_def (name) +# define libcrypt_hidden_data_weak(name) hidden_data_weak (name) +# define libcrypt_hidden_data_ver(local, name) hidden_data_ver (local, name) +#else +# define libcrypt_hidden_proto(name, attrs...) +# define libcrypt_hidden_def(name) +# define libcrypt_hidden_weak(name) +# define libcrypt_hidden_ver(local, name) +# define libcrypt_hidden_data_def(name) +# define libcrypt_hidden_data_weak(name) +# define libcrypt_hidden_data_ver(local, name) +#endif + +#if defined NOT_IN_libc && defined IS_IN_libpthread +# define libpthread_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) +# define libpthread_hidden_def(name) hidden_def (name) +# define libpthread_hidden_weak(name) hidden_weak (name) +# define libpthread_hidden_ver(local, name) hidden_ver (local, name) +# define libpthread_hidden_data_def(name) hidden_data_def (name) +# define libpthread_hidden_data_weak(name) hidden_data_weak (name) +# define libpthread_hidden_data_ver(local, name) hidden_data_ver (local, name) +#else +# define libpthread_hidden_proto(name, attrs...) +# define libpthread_hidden_def(name) +# define libpthread_hidden_weak(name) +# define libpthread_hidden_ver(local, name) +# define libpthread_hidden_data_def(name) +# define libpthread_hidden_data_weak(name) +# define libpthread_hidden_data_ver(local, name) +#endif + +#endif /* libc-symbols.h */ diff --git a/conts/posix/libposix/include/posix/libgen.h b/conts/posix/libposix/include/posix/libgen.h new file mode 100644 index 0000000..b252543 --- /dev/null +++ b/conts/posix/libposix/include/posix/libgen.h @@ -0,0 +1,40 @@ +/* Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _LIBGEN_H +#define _LIBGEN_H 1 + +#include + +__BEGIN_DECLS + +/* Return directory part of PATH or "." if none is available. */ +extern char *dirname (char *__path) __THROW; + +/* Return final component of PATH. + + This is the weird XPG version of this function. It sometimes will + modify its argument. Therefore we normally use the GNU version (in + ) and only if this header is included make the XPG + version available under the real name. */ +extern char *__xpg_basename (char *__path) __THROW; +#define basename __xpg_basename + +__END_DECLS + +#endif /* libgen.h */ diff --git a/conts/posix/libposix/include/posix/libintl.h b/conts/posix/libposix/include/posix/libintl.h new file mode 100644 index 0000000..ba57f16 --- /dev/null +++ b/conts/posix/libposix/include/posix/libintl.h @@ -0,0 +1,133 @@ +/* Message catalogs for internationalization. + Copyright (C) 1995-2002, 2004, 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + This file is derived from the file libgettext.h in the GNU gettext package. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _LIBINTL_H +#define _LIBINTL_H 1 + +#include + +/* We define an additional symbol to signal that we use the GNU + implementation of gettext. */ +#define __USE_GNU_GETTEXT 1 + +/* Provide information about the supported file formats. Returns the + maximum minor revision number supported for a given major revision. */ +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \ + ((major) == 0 ? 1 : -1) + +__BEGIN_DECLS + +#ifdef __UCLIBC_MJN3_ONLY__ +#warning "mjn3 FIXME: gettext has a prototype but isn't defined." +#warning "mjn3 FIXME: __OPTIMIZE__ is never defined." +#endif + +/* Look up MSGID in the current default message catalog for the current + LC_MESSAGES locale. If not found, returns MSGID itself (the default + text). */ +extern char *gettext (__const char *__msgid) + __THROW __attribute_format_arg__ (1); + +/* Look up MSGID in the DOMAINNAME message catalog for the current + LC_MESSAGES locale. */ +extern char *dgettext (__const char *__domainname, __const char *__msgid) + __THROW __attribute_format_arg__ (2); +#if 0 /* uClibc: disabled */ +extern char *__dgettext (__const char *__domainname, __const char *__msgid) + __THROW __attribute_format_arg__ (2); +#endif + +/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY + locale. */ +extern char *dcgettext (__const char *__domainname, + __const char *__msgid, int __category) + __THROW __attribute_format_arg__ (2); +#if 0 /* uClibc: disabled */ +extern char *__dcgettext (__const char *__domainname, + __const char *__msgid, int __category) + __THROW __attribute_format_arg__ (2); +#endif + + +/* Similar to `gettext' but select the plural form corresponding to the + number N. */ +extern char *ngettext (__const char *__msgid1, __const char *__msgid2, + unsigned long int __n) + __THROW __attribute_format_arg__ (1) __attribute_format_arg__ (2); + +/* Similar to `dgettext' but select the plural form corresponding to the + number N. */ +extern char *dngettext (__const char *__domainname, __const char *__msgid1, + __const char *__msgid2, unsigned long int __n) + __THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3); + +/* Similar to `dcgettext' but select the plural form corresponding to the + number N. */ +extern char *dcngettext (__const char *__domainname, __const char *__msgid1, + __const char *__msgid2, unsigned long int __n, + int __category) + __THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3); + + +/* Set the current default message catalog to DOMAINNAME. + If DOMAINNAME is null, return the current default. + If DOMAINNAME is "", reset to the default of "messages". */ +extern char *textdomain (__const char *__domainname) __THROW; + +/* Specify that the DOMAINNAME message catalog will be found + in DIRNAME rather than in the system locale data base. */ +extern char *bindtextdomain (__const char *__domainname, + __const char *__dirname) __THROW; + +/* Specify the character encoding in which the messages from the + DOMAINNAME message catalog will be returned. */ +extern char *bind_textdomain_codeset (__const char *__domainname, + __const char *__codeset) __THROW; + + +/* Optimized version of the function above. */ +#if defined __OPTIMIZE__ && !defined __cplusplus + +/* We need NULL for `gettext'. */ +# define __need_NULL +# include + +/* We need LC_MESSAGES for `dgettext'. */ +# include + +/* These must be macros. Inlined functions are useless because the + `__builtin_constant_p' predicate in dcgettext would always return + false. */ + +# define gettext(msgid) dgettext (NULL, msgid) + +# define dgettext(domainname, msgid) \ + dcgettext (domainname, msgid, LC_MESSAGES) + +# define ngettext(msgid1, msgid2, n) dngettext (NULL, msgid1, msgid2, n) + +# define dngettext(domainname, msgid1, msgid2, n) \ + dcngettext (domainname, msgid1, msgid2, n, LC_MESSAGES) + +#endif /* Optimizing. */ + +__END_DECLS + +#endif /* libintl.h */ diff --git a/conts/posix/libposix/include/posix/limits.h b/conts/posix/libposix/include/posix/limits.h new file mode 100644 index 0000000..45cd6f2 --- /dev/null +++ b/conts/posix/libposix/include/posix/limits.h @@ -0,0 +1,153 @@ +/* Copyright (C) 1991, 92, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types + */ + +#ifndef _LIBC_LIMITS_H_ +#define _LIBC_LIMITS_H_ 1 + +#include + + +/* Maximum length of any multibyte character in any locale. + We define this value here since the gcc header does not define + the correct value. */ +#define MB_LEN_MAX 16 + + +/* If we are not using GNU CC we have to define all the symbols ourself. + Otherwise use gcc's definitions (see below). */ +#if !defined __GNUC__ || __GNUC__ < 2 + +/* We only protect from multiple inclusion here, because all the other + #include's protect themselves, and in GCC 2 we may #include_next through + multiple copies of this file before we get to GCC's. */ +# ifndef _LIMITS_H +# define _LIMITS_H 1 + +#include + +/* We don't have #include_next. + Define ANSI for standard 32-bit words. */ + +/* These assume 8-bit `char's, 16-bit `short int's, + and 32-bit `int's and `long int's. */ + +/* Number of bits in a `char'. */ +# define CHAR_BIT 8 + +/* Minimum and maximum values a `signed char' can hold. */ +# define SCHAR_MIN (-128) +# define SCHAR_MAX 127 + +/* Maximum value an `unsigned char' can hold. (Minimum is 0.) */ +# define UCHAR_MAX 255 + +/* Minimum and maximum values a `char' can hold. */ +# ifdef __CHAR_UNSIGNED__ +# define CHAR_MIN 0 +# define CHAR_MAX UCHAR_MAX +# else +# define CHAR_MIN SCHAR_MIN +# define CHAR_MAX SCHAR_MAX +# endif + +/* Minimum and maximum values a `signed short int' can hold. */ +# define SHRT_MIN (-32768) +# define SHRT_MAX 32767 + +/* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */ +# define USHRT_MAX 65535 + +/* Minimum and maximum values a `signed int' can hold. */ +# define INT_MIN (-INT_MAX - 1) +# define INT_MAX 2147483647 + +/* Maximum value an `unsigned int' can hold. (Minimum is 0.) */ +# define UINT_MAX 4294967295U + +/* Minimum and maximum values a `signed long int' can hold. */ +# if __WORDSIZE == 64 +# define LONG_MAX 9223372036854775807L +# else +# define LONG_MAX 2147483647L +# endif +# define LONG_MIN (-LONG_MAX - 1L) + +/* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */ +# if __WORDSIZE == 64 +# define ULONG_MAX 18446744073709551615UL +# else +# define ULONG_MAX 4294967295UL +# endif + +# ifdef __USE_ISOC99 + +/* Minimum and maximum values a `signed long long int' can hold. */ +# define LLONG_MAX 9223372036854775807LL +# define LLONG_MIN (-LLONG_MAX - 1LL) + +/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */ +# define ULLONG_MAX 18446744073709551615ULL + +# endif /* ISO C99 */ + +# endif /* limits.h */ +#endif /* GCC 2. */ + +#endif /* !_LIBC_LIMITS_H_ */ + + /* Get the compiler's limits.h, which defines almost all the ISO constants. + + We put this #include_next outside the double inclusion check because + it should be possible to include this file more than once and still get + the definitions from gcc's header. */ +#if defined __GNUC__ && !defined _GCC_LIMITS_H_ +/* `_GCC_LIMITS_H_' is what GCC's file defines. */ +# include_next + +/* The files in some gcc versions don't define LLONG_MIN, + LLONG_MAX, and ULLONG_MAX. Instead only the values gcc defined for + ages are available. */ +# ifdef __USE_ISOC99 +# ifndef LLONG_MIN +# define LLONG_MIN LONG_LONG_MIN +# endif +# ifndef LLONG_MAX +# define LLONG_MAX LONG_LONG_MAX +# endif +# ifndef ULLONG_MAX +# define ULLONG_MAX ULONG_LONG_MAX +# endif +# endif +#endif + +#ifdef __USE_POSIX +/* POSIX adds things to . */ +# include +#endif + +#ifdef __USE_POSIX2 +# include +#endif + +#ifdef __USE_XOPEN +# include +#endif diff --git a/conts/posix/libposix/include/posix/link.h b/conts/posix/libposix/include/posix/link.h new file mode 100644 index 0000000..b69dcda --- /dev/null +++ b/conts/posix/libposix/include/posix/link.h @@ -0,0 +1,238 @@ +/* Data structure for communication from the run-time dynamic linker for + loaded ELF shared objects. + Copyright (C) 1995-2001, 2004, 2005, 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _LINK_H +#define _LINK_H 1 + +#include +#include +#include +#include +#if defined _LIBC && defined __UCLIBC_HAS_THREADS_NATIVE__ +#include +#endif + +/* We use this macro to refer to ELF types independent of the native wordsize. + `ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */ +#define ElfW(type) _ElfW (Elf, __ELF_NATIVE_CLASS, type) +#define _ElfW(e,w,t) _ElfW_1 (e, w, _##t) +#define _ElfW_1(e,w,t) e##w##t + +#include /* Defines __ELF_NATIVE_CLASS. */ + +/* Rendezvous structure used by the run-time dynamic linker to communicate + details of shared object loading to the debugger. If the executable's + dynamic section has a DT_DEBUG element, the run-time linker sets that + element's value to the address where this structure can be found. */ + +struct r_debug + { + int r_version; /* Version number for this protocol. */ + + struct link_map *r_map; /* Head of the chain of loaded objects. */ + + /* This is the address of a function internal to the run-time linker, + that will always be called when the linker begins to map in a + library or unmap it, and again when the mapping change is complete. + The debugger can set a breakpoint at this address if it wants to + notice shared object mapping changes. */ + ElfW(Addr) r_brk; + enum + { + /* This state value describes the mapping change taking place when + the `r_brk' address is called. */ + RT_CONSISTENT, /* Mapping change is complete. */ + RT_ADD, /* Beginning to add a new object. */ + RT_DELETE /* Beginning to remove an object mapping. */ + } r_state; + + ElfW(Addr) r_ldbase; /* Base address the linker is loaded at. */ + }; + +/* This is the instance of that structure used by the dynamic linker. */ +extern struct r_debug _r_debug; + +/* This symbol refers to the "dynamic structure" in the `.dynamic' section + of whatever module refers to `_DYNAMIC'. So, to find its own + `struct r_debug', a program could do: + for (dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) + if (dyn->d_tag == DT_DEBUG) + r_debug = (struct r_debug *) dyn->d_un.d_ptr; + */ +extern ElfW(Dyn) _DYNAMIC[]; + +#ifdef __FDPIC__ +# include +#endif + +/* Structure describing a loaded shared object. The `l_next' and `l_prev' + members form a chain of all the shared objects loaded at startup. + + These data structures exist in space used by the run-time dynamic linker; + modifying them may have disastrous results. */ + +struct link_map + { + /* These first few members are part of the protocol with the debugger. + This is the same format used in SVR4. */ + +#ifdef __FDPIC__ + struct elf32_fdpic_loadaddr l_addr; +#else + ElfW(Addr) l_addr; /* Base address shared object is loaded at. */ +#endif + char *l_name; /* Absolute file name object was found in. */ + ElfW(Dyn) *l_ld; /* Dynamic section of the shared object. */ + struct link_map *l_next, *l_prev; /* Chain of loaded objects. */ + +#ifdef USE_TLS + /* Thread-local storage related info. */ + + /* Start of the initialization image. */ + void *l_tls_initimage; + /* Size of the initialization image. */ + size_t l_tls_initimage_size; + /* Size of the TLS block. */ + size_t l_tls_blocksize; + /* Alignment requirement of the TLS block. */ + size_t l_tls_align; + /* Offset of first byte module alignment. */ + size_t l_tls_firstbyte_offset; +# ifndef NO_TLS_OFFSET +# define NO_TLS_OFFSET 0 +# endif + /* For objects present at startup time: offset in the static TLS block. */ + ptrdiff_t l_tls_offset; + /* Index of the module in the dtv array. */ + size_t l_tls_modid; + /* Nonzero if _dl_init_static_tls should be called for this module */ + unsigned int l_need_tls_init:1; +#endif + }; + +#ifdef __USE_GNU + +#if 0 +/* Version numbers for la_version handshake interface. */ +#define LAV_CURRENT 1 + +/* Activity types signaled through la_activity. */ +enum + { + LA_ACT_CONSISTENT, /* Link map consistent again. */ + LA_ACT_ADD, /* New object will be added. */ + LA_ACT_DELETE /* Objects will be removed. */ + }; + +/* Values representing origin of name for dynamic loading. */ +enum + { + LA_SER_ORIG = 0x01, /* Original name. */ + LA_SER_LIBPATH = 0x02, /* Directory from LD_LIBRARY_PATH. */ + LA_SER_RUNPATH = 0x04, /* Directory from RPATH/RUNPATH. */ + LA_SER_CONFIG = 0x08, /* Found through ldconfig. */ + LA_SER_DEFAULT = 0x40, /* Default directory. */ + LA_SER_SECURE = 0x80 /* Unused. */ + }; + +/* Values for la_objopen return value. */ +enum + { + LA_FLG_BINDTO = 0x01, /* Audit symbols bound to this object. */ + LA_FLG_BINDFROM = 0x02 /* Audit symbols bound from this object. */ + }; + +/* Values for la_symbind flags parameter. */ +enum + { + LA_SYMB_NOPLTENTER = 0x01, /* la_pltenter will not be called. */ + LA_SYMB_NOPLTEXIT = 0x02, /* la_pltexit will not be called. */ + LA_SYMB_STRUCTCALL = 0x04, /* Return value is a structure. */ + LA_SYMB_DLSYM = 0x08, /* Binding due to dlsym call. */ + LA_SYMB_ALTVALUE = 0x10 /* Value has been changed by a previous + la_symbind call. */ + }; +#endif + +struct dl_phdr_info + { +#ifdef __FDPIC__ + struct elf32_fdpic_loadaddr dlpi_addr; +#else + ElfW(Addr) dlpi_addr; +#endif + const char *dlpi_name; + const ElfW(Phdr) *dlpi_phdr; + ElfW(Half) dlpi_phnum; + +#if 0 + /* Note: Following members were introduced after the first + version of this structure was available. Check the SIZE + argument passed to the dl_iterate_phdr callback to determine + whether or not each later member is available. */ + + /* Incremented when a new object may have been added. */ + unsigned long long int dlpi_adds; + /* Incremented when an object may have been removed. */ + unsigned long long int dlpi_subs; + + /* If there is a PT_TLS segment, its module ID as used in + TLS relocations, else zero. */ + size_t dlpi_tls_modid; + + /* The address of the calling thread's instance of this module's + PT_TLS segment, if it has one and it has been allocated + in the calling thread, otherwise a null pointer. */ + void *dlpi_tls_data; +#endif + }; + +__BEGIN_DECLS + +extern int dl_iterate_phdr (int (*__callback) (struct dl_phdr_info *, + size_t, void *), + void *__data); + + +#if 0 +/* Prototypes for the ld.so auditing interfaces. These are not + defined anywhere in ld.so but instead have to be provided by the + auditing DSO. */ +extern unsigned int la_version (unsigned int __version); +extern void la_activity (uintptr_t *__cookie, unsigned int __flag); +extern char *la_objsearch (const char *__name, uintptr_t *__cookie, + unsigned int __flag); +extern unsigned int la_objopen (struct link_map *__map, Lmid_t __lmid, + uintptr_t *__cookie); +extern void la_preinit (uintptr_t *__cookie); +extern uintptr_t la_symbind32 (Elf32_Sym *__sym, unsigned int __ndx, + uintptr_t *__refcook, uintptr_t *__defcook, + unsigned int *__flags, const char *__symname); +extern uintptr_t la_symbind64 (Elf64_Sym *__sym, unsigned int __ndx, + uintptr_t *__refcook, uintptr_t *__defcook, + unsigned int *__flags, const char *__symname); +extern unsigned int la_objclose (uintptr_t *__cookie); +#endif + +__END_DECLS + +#endif + +#endif /* link.h */ diff --git a/conts/posix/libposix/include/posix/locale.h b/conts/posix/libposix/include/posix/locale.h new file mode 100644 index 0000000..02d33a0 --- /dev/null +++ b/conts/posix/libposix/include/posix/locale.h @@ -0,0 +1,225 @@ +/* Copyright (C) 1991,92,95-99,2000,01,02 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard: 7.11 Localization + */ + +#ifndef _LOCALE_H +#define _LOCALE_H 1 + +#include + +#define __need_NULL +#include +#include + +__BEGIN_DECLS + +/* These are the possibilities for the first argument to setlocale. + The code assumes that the lowest LC_* symbol has the value zero. */ +#define LC_CTYPE __LC_CTYPE +#define LC_NUMERIC __LC_NUMERIC +#define LC_TIME __LC_TIME +#define LC_COLLATE __LC_COLLATE +#define LC_MONETARY __LC_MONETARY +#define LC_MESSAGES __LC_MESSAGES +#if 0 +#define LC_PAPER __LC_PAPER +#define LC_NAME __LC_NAME +#define LC_ADDRESS __LC_ADDRESS +#define LC_TELEPHONE __LC_TELEPHONE +#define LC_MEASUREMENT __LC_MEASUREMENT +#define LC_IDENTIFICATION __LC_IDENTIFICATION +#endif +#define LC_ALL __LC_ALL + + +/* Structure giving information about numeric and monetary notation. */ +struct lconv +{ + /* Numeric (non-monetary) information. */ + + char *decimal_point; /* Decimal point character. */ + char *thousands_sep; /* Thousands separator. */ + /* Each element is the number of digits in each group; + elements with higher indices are farther left. + An element with value CHAR_MAX means that no further grouping is done. + An element with value 0 means that the previous element is used + for all groups farther left. */ + char *grouping; + + /* Monetary information. */ + + /* First three chars are a currency symbol from ISO 4217. + Fourth char is the separator. Fifth char is '\0'. */ + char *int_curr_symbol; + char *currency_symbol; /* Local currency symbol. */ + char *mon_decimal_point; /* Decimal point character. */ + char *mon_thousands_sep; /* Thousands separator. */ + char *mon_grouping; /* Like `grouping' element (above). */ + char *positive_sign; /* Sign for positive values. */ + char *negative_sign; /* Sign for negative values. */ + char int_frac_digits; /* Int'l fractional digits. */ + char frac_digits; /* Local fractional digits. */ + /* 1 if currency_symbol precedes a positive value, 0 if succeeds. */ + char p_cs_precedes; + /* 1 iff a space separates currency_symbol from a positive value. */ + char p_sep_by_space; + /* 1 if currency_symbol precedes a negative value, 0 if succeeds. */ + char n_cs_precedes; + /* 1 iff a space separates currency_symbol from a negative value. */ + char n_sep_by_space; + /* Positive and negative sign positions: + 0 Parentheses surround the quantity and currency_symbol. + 1 The sign string precedes the quantity and currency_symbol. + 2 The sign string follows the quantity and currency_symbol. + 3 The sign string immediately precedes the currency_symbol. + 4 The sign string immediately follows the currency_symbol. */ + char p_sign_posn; + char n_sign_posn; +#ifdef __USE_ISOC99 + /* 1 if int_curr_symbol precedes a positive value, 0 if succeeds. */ + char int_p_cs_precedes; + /* 1 iff a space separates int_curr_symbol from a positive value. */ + char int_p_sep_by_space; + /* 1 if int_curr_symbol precedes a negative value, 0 if succeeds. */ + char int_n_cs_precedes; + /* 1 iff a space separates int_curr_symbol from a negative value. */ + char int_n_sep_by_space; + /* Positive and negative sign positions: + 0 Parentheses surround the quantity and int_curr_symbol. + 1 The sign string precedes the quantity and int_curr_symbol. + 2 The sign string follows the quantity and int_curr_symbol. + 3 The sign string immediately precedes the int_curr_symbol. + 4 The sign string immediately follows the int_curr_symbol. */ + char int_p_sign_posn; + char int_n_sign_posn; +#else + char __int_p_cs_precedes; + char __int_p_sep_by_space; + char __int_n_cs_precedes; + char __int_n_sep_by_space; + char __int_p_sign_posn; + char __int_n_sign_posn; +#endif +}; + + +__BEGIN_NAMESPACE_STD + +/* Set and/or return the current locale. */ +extern char *setlocale (int __category, __const char *__locale) __THROW; + +/* Return the numeric/monetary information for the current locale. */ +extern struct lconv *localeconv (void) __THROW; + +__END_NAMESPACE_STD + + +#if defined(__USE_GNU) && defined(__UCLIBC_HAS_XLOCALE__) +/* The concept of one static locale per category is not very well + thought out. Many applications will need to process its data using + information from several different locales. Another application is + the implementation of the internationalization handling in the + upcoming ISO C++ standard library. To support this another set of + the functions using locale data exist which have an additional + argument. + + Attention: all these functions are *not* standardized in any form. + This is a proof-of-concept implementation. */ + +/* Get locale datatype definition. */ +# include + +typedef __locale_t locale_t; + +/* Return a reference to a data structure representing a set of locale + datasets. Unlike for the CATEGORY parameter for `setlocale' the + CATEGORY_MASK parameter here uses a single bit for each category, + made by OR'ing together LC_*_MASK bits above. */ +extern __locale_t newlocale (int __category_mask, __const char *__locale, + __locale_t __base) __THROW; + +/* These are the bits that can be set in the CATEGORY_MASK argument to + `newlocale'. In the GNU implementation, LC_FOO_MASK has the value + of (1 << LC_FOO), but this is not a part of the interface that + callers can assume will be true. */ +# define LC_CTYPE_MASK (1 << __LC_CTYPE) +# define LC_NUMERIC_MASK (1 << __LC_NUMERIC) +# define LC_TIME_MASK (1 << __LC_TIME) +# define LC_COLLATE_MASK (1 << __LC_COLLATE) +# define LC_MONETARY_MASK (1 << __LC_MONETARY) +# define LC_MESSAGES_MASK (1 << __LC_MESSAGES) +#ifdef L_newlocale +#warning mask defines for extra locale categories +#endif /* L_newlocale - uClibc note */ +#ifdef LC_PAPER +# define LC_PAPER_MASK (1 << __LC_PAPER) +# define LC_NAME_MASK (1 << __LC_NAME) +# define LC_ADDRESS_MASK (1 << __LC_ADDRESS) +# define LC_TELEPHONE_MASK (1 << __LC_TELEPHONE) +# define LC_MEASUREMENT_MASK (1 << __LC_MEASUREMENT) +# define LC_IDENTIFICATION_MASK (1 << __LC_IDENTIFICATION) +# define LC_ALL_MASK (LC_CTYPE_MASK \ + | LC_NUMERIC_MASK \ + | LC_TIME_MASK \ + | LC_COLLATE_MASK \ + | LC_MONETARY_MASK \ + | LC_MESSAGES_MASK \ + | LC_PAPER_MASK \ + | LC_NAME_MASK \ + | LC_ADDRESS_MASK \ + | LC_TELEPHONE_MASK \ + | LC_MEASUREMENT_MASK \ + | LC_IDENTIFICATION_MASK \ + ) +#else /* LC_PAPER */ +# define LC_ALL_MASK (LC_CTYPE_MASK \ + | LC_NUMERIC_MASK \ + | LC_TIME_MASK \ + | LC_COLLATE_MASK \ + | LC_MONETARY_MASK \ + | LC_MESSAGES_MASK \ + ) +#endif /* LC_PAPER */ + +/* Return a duplicate of the set of locale in DATASET. All usage + counters are increased if necessary. */ +extern __locale_t duplocale (__locale_t __dataset) __THROW; + +/* Free the data associated with a locale dataset previously returned + by a call to `setlocale_r'. */ +extern void freelocale (__locale_t __dataset) __THROW; + +/* Switch the current thread's locale to DATASET. + If DATASET is null, instead just return the current setting. + The special value LC_GLOBAL_LOCALE is the initial setting + for all threads and can also be installed any time, meaning + the thread uses the global settings controlled by `setlocale'. */ +extern __locale_t uselocale (__locale_t __dataset) __THROW; + +/* This value can be passed to `uselocale' and may be returned by it. + Passing this value to any other function has undefined behavior. */ +# define LC_GLOBAL_LOCALE ((__locale_t) -1L) + +#endif + +__END_DECLS + +#endif /* locale.h */ diff --git a/conts/posix/libposix/include/posix/malloc.h b/conts/posix/libposix/include/posix/malloc.h new file mode 100644 index 0000000..354f153 --- /dev/null +++ b/conts/posix/libposix/include/posix/malloc.h @@ -0,0 +1,191 @@ +/* Prototypes and definition for malloc implementation. + Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _MALLOC_H +#define _MALLOC_H 1 + +#include + +/* + `ptmalloc', a malloc implementation for multiple threads without + lock contention, by Wolfram Gloger . + See the files `ptmalloc.c' or `COPYRIGHT' for copying conditions. + + VERSION 2.6.4-pt Wed Dec 4 00:35:54 MET 1996 + + This work is mainly derived from malloc-2.6.4 by Doug Lea + , which is available from: + + ftp://g.oswego.edu/pub/misc/malloc.c + + This trimmed-down header file only provides function prototypes and + the exported data structures. For more detailed function + descriptions and compile-time options, see the source file + `ptmalloc.c'. +*/ + +#if defined(__STDC__) || defined (__cplusplus) +# include +# define __malloc_ptr_t void * +#else +# undef size_t +# define size_t unsigned int +# undef ptrdiff_t +# define ptrdiff_t int +# define __malloc_ptr_t char * +#endif + +#ifdef _LIBC +/* Used by GNU libc internals. */ +# define __malloc_size_t size_t +# define __malloc_ptrdiff_t ptrdiff_t +#elif !defined __attribute_malloc__ +# define __attribute_malloc__ +#endif + +#ifdef __GNUC__ + +/* GCC can always grok prototypes. For C++ programs we add throw() + to help it optimize the function calls. But this works only with + gcc 2.8.x and egcs. */ +#ifndef __THROW +# if defined __cplusplus && (__GNUC__ >= 3 || __GNUC_MINOR__ >= 8) +# define __THROW throw () +# else +# define __THROW +# endif +#endif +# define __MALLOC_P(args) args __THROW +/* This macro will be used for functions which might take C++ callback + functions. */ +# define __MALLOC_PMT(args) args + +#else /* Not GCC. */ + +# define __THROW + +# if (defined __STDC__ && __STDC__) || defined __cplusplus + +# define __MALLOC_P(args) args +# define __MALLOC_PMT(args) args + +# else /* Not ANSI C or C++. */ + +# define __MALLOC_P(args) () /* No prototypes. */ +# define __MALLOC_PMT(args) () + +# endif /* ANSI C or C++. */ + +#endif /* GCC. */ + +#ifndef NULL +# ifdef __cplusplus +# define NULL 0 +# else +# define NULL ((__malloc_ptr_t) 0) +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Allocate SIZE bytes of memory. */ +extern __malloc_ptr_t malloc __MALLOC_P ((size_t __size)) __attribute_malloc__; + +/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ +extern __malloc_ptr_t calloc __MALLOC_P ((size_t __nmemb, size_t __size)) + __attribute_malloc__; + +/* Re-allocate the previously allocated block in __ptr, making the new + block SIZE bytes long. */ +extern __malloc_ptr_t realloc __MALLOC_P ((__malloc_ptr_t __ptr, + size_t __size)) + __attribute_malloc__; + +/* Free a block allocated by `malloc', `realloc' or `calloc'. */ +extern void free __MALLOC_P ((__malloc_ptr_t __ptr)); + +/* Allocate SIZE bytes allocated to ALIGNMENT bytes. */ +extern __malloc_ptr_t memalign __MALLOC_P ((size_t __alignment, size_t __size)); + +/* Allocate SIZE bytes on a page boundary. */ +extern __malloc_ptr_t valloc __MALLOC_P ((size_t __size)) __attribute_malloc__; + +#ifdef __MALLOC_STANDARD__ + +/* SVID2/XPG mallinfo structure */ +struct mallinfo { + int arena; /* total space allocated from system */ + int ordblks; /* number of non-inuse chunks */ + int smblks; /* unused -- always zero */ + int hblks; /* number of mmapped regions */ + int hblkhd; /* total space in mmapped regions */ + int usmblks; /* unused -- always zero */ + int fsmblks; /* unused -- always zero */ + int uordblks; /* total allocated space */ + int fordblks; /* total non-inuse space */ + int keepcost; /* top-most, releasable (via malloc_trim) space */ +}; + +/* Returns a copy of the updated current mallinfo. */ +extern struct mallinfo mallinfo __MALLOC_P ((void)); + +/* Release all but __pad bytes of freed top-most memory back to the + system. Return 1 if successful, else 0. */ +extern int malloc_trim(size_t pad); + +#include +/* Prints brief summary statistics to the specified file. + * Writes to stderr if file is NULL. */ +extern void malloc_stats(FILE *file); + +/* SVID2/XPG mallopt options */ +#ifndef M_MXFAST +# define M_MXFAST 1 /* UNUSED in this malloc */ +#endif +#ifndef M_NLBLKS +# define M_NLBLKS 2 /* UNUSED in this malloc */ +#endif +#ifndef M_GRAIN +# define M_GRAIN 3 /* UNUSED in this malloc */ +#endif +#ifndef M_KEEP +# define M_KEEP 4 /* UNUSED in this malloc */ +#endif + +/* mallopt options that actually do something */ +#define M_TRIM_THRESHOLD -1 +#define M_TOP_PAD -2 +#define M_MMAP_THRESHOLD -3 +#define M_MMAP_MAX -4 +#define M_CHECK_ACTION -5 +#define M_PERTURB -6 + +/* General SVID/XPG interface to tunable parameters. */ +extern int mallopt __MALLOC_P ((int __param, int __val)); + +#endif /* __MALLOC_STANDARD__ */ + + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + +#endif /* malloc.h */ diff --git a/conts/posix/libposix/include/posix/math.h b/conts/posix/libposix/include/posix/math.h new file mode 100644 index 0000000..c50b2e7 --- /dev/null +++ b/conts/posix/libposix/include/posix/math.h @@ -0,0 +1,468 @@ +/* Declarations for math functions. + Copyright (C) 1991-1993, 1995-1999, 2001, 2002, 2004, 2006 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard: 7.12 Mathematics + */ + +#ifndef _MATH_H +#define _MATH_H 1 + +#include + +__BEGIN_DECLS + +/* Get machine-dependent HUGE_VAL value (returned on overflow). + On all IEEE754 machines, this is +Infinity. */ +#include +#ifdef __USE_ISOC99 +# include +# include + +/* Get machine-dependent INFINITY value. */ +# include + +/* Get machine-dependent NAN value (returned for some domain errors). */ +# include +#endif /* __USE_ISOC99 */ + +/* Get general and ISO C99 specific information. */ +#include + +/* The file contains the prototypes for all the + actual math functions. These macros are used for those prototypes, + so we can easily declare each function as both `name' and `__name', + and can declare the float versions `namef' and `__namef'. */ + +#define __MATHCALL(function,suffix, args) \ + __MATHDECL (_Mdouble_,function,suffix, args) +#define __MATHDECL(type, function,suffix, args) \ + __MATHDECL_1(type, function,suffix, args); \ + __MATHDECL_1(type, __CONCAT(__,function),suffix, args) +#define __MATHCALLX(function,suffix, args, attrib) \ + __MATHDECLX (_Mdouble_,function,suffix, args, attrib) +#define __MATHDECLX(type, function,suffix, args, attrib) \ + __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \ + __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib) +#define __MATHDECL_1(type, function,suffix, args) \ + extern type __MATH_PRECNAME(function,suffix) args __THROW + +#define _Mdouble_ double +#define __MATH_PRECNAME(name,r) __CONCAT(name,r) +# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD +# define _Mdouble_END_NAMESPACE __END_NAMESPACE_STD +#include +#undef _Mdouble_ +#undef _Mdouble_BEGIN_NAMESPACE +#undef _Mdouble_END_NAMESPACE +#undef __MATH_PRECNAME + +#if defined __USE_MISC || defined __USE_ISOC99 + + +/* Include the file of declarations again, this time using `float' + instead of `double' and appending f to each function name. */ + +# ifndef _Mfloat_ +# define _Mfloat_ float +# endif +# define _Mdouble_ _Mfloat_ +# ifdef __STDC__ +# define __MATH_PRECNAME(name,r) name##f##r +# else +# define __MATH_PRECNAME(name,r) name/**/f/**/r +# endif +# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99 +# define _Mdouble_END_NAMESPACE __END_NAMESPACE_C99 +# include +# undef _Mdouble_ +# undef _Mdouble_BEGIN_NAMESPACE +# undef _Mdouble_END_NAMESPACE +# undef __MATH_PRECNAME + +# if (__STDC__ - 0 || __GNUC__ - 0) \ + && (!defined __NO_LONG_DOUBLE_MATH || defined __LDBL_COMPAT) +# ifdef __LDBL_COMPAT + +# ifdef __USE_ISOC99 +extern float __nldbl_nexttowardf (float __x, long double __y) + __THROW __attribute__ ((__const__)); +# ifdef __REDIRECT_NTH +extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y), + __nldbl_nexttowardf) + __attribute__ ((__const__)); +extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y), + nextafter) __attribute__ ((__const__)); +extern long double __REDIRECT_NTH (nexttowardl, + (long double __x, long double __y), + nextafter) __attribute__ ((__const__)); +# endif +# endif + +/* Include the file of declarations again, this time using `long double' + instead of `double' and appending l to each function name. */ + +# undef __MATHDECL_1 +# define __MATHDECL_2(type, function,suffix, args, alias) \ + extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \ + args, alias) +# define __MATHDECL_1(type, function,suffix, args) \ + __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix)) +# endif + +# ifndef _Mlong_double_ +# define _Mlong_double_ long double +# endif +# define _Mdouble_ _Mlong_double_ +# ifdef __STDC__ +# define __MATH_PRECNAME(name,r) name##l##r +# else +# define __MATH_PRECNAME(name,r) name/**/l/**/r +# endif +# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99 +# define _Mdouble_END_NAMESPACE __END_NAMESPACE_C99 +# include +# undef _Mdouble_ +# undef _Mdouble_BEGIN_NAMESPACE +# undef _Mdouble_END_NAMESPACE +# undef __MATH_PRECNAME + +# endif /* __STDC__ || __GNUC__ */ + +#endif /* Use misc or ISO C99. */ +#undef __MATHDECL_1 +#undef __MATHDECL +#undef __MATHCALL + + +#if defined __USE_MISC || defined __USE_XOPEN +/* This variable is used by `gamma' and `lgamma'. */ +extern int signgam; +#endif + + +/* ISO C99 defines some generic macros which work on any data type. */ +#ifdef __USE_ISOC99 + +/* Get the architecture specific values describing the floating-point + evaluation. The following symbols will get defined: + + float_t floating-point type at least as wide as `float' used + to evaluate `float' expressions + double_t floating-point type at least as wide as `double' used + to evaluate `double' expressions + + FLT_EVAL_METHOD + Defined to + 0 if `float_t' is `float' and `double_t' is `double' + 1 if `float_t' and `double_t' are `double' + 2 if `float_t' and `double_t' are `long double' + else `float_t' and `double_t' are unspecified + + INFINITY representation of the infinity value of type `float' + + FP_FAST_FMA + FP_FAST_FMAF + FP_FAST_FMAL + If defined it indicates that the `fma' function + generally executes about as fast as a multiply and an add. + This macro is defined only iff the `fma' function is + implemented directly with a hardware multiply-add instructions. + + FP_ILOGB0 Expands to a value returned by `ilogb (0.0)'. + FP_ILOGBNAN Expands to a value returned by `ilogb (NAN)'. + + DECIMAL_DIG Number of decimal digits supported by conversion between + decimal and all internal floating-point formats. + +*/ + +/* All floating-point numbers can be put in one of these categories. */ +enum + { + FP_NAN, +# define FP_NAN FP_NAN + FP_INFINITE, +# define FP_INFINITE FP_INFINITE + FP_ZERO, +# define FP_ZERO FP_ZERO + FP_SUBNORMAL, +# define FP_SUBNORMAL FP_SUBNORMAL + FP_NORMAL +# define FP_NORMAL FP_NORMAL + }; + +/* Return number of classification appropriate for X. */ +# ifdef __NO_LONG_DOUBLE_MATH +# define fpclassify(x) \ + (sizeof (x) == sizeof (float) ? __fpclassifyf (x) : __fpclassify (x)) +# else +# define fpclassify(x) \ + (sizeof (x) == sizeof (float) \ + ? __fpclassifyf (x) \ + : sizeof (x) == sizeof (double) \ + ? __fpclassify (x) : __fpclassifyl (x)) +# endif + +/* Return nonzero value if sign of X is negative. */ +# ifdef __NO_LONG_DOUBLE_MATH +# define signbit(x) \ + (sizeof (x) == sizeof (float) ? __signbitf (x) : __signbit (x)) +# else +# define signbit(x) \ + (sizeof (x) == sizeof (float) \ + ? __signbitf (x) \ + : sizeof (x) == sizeof (double) \ + ? __signbit (x) : __signbitl (x)) +# endif + +/* Return nonzero value if X is not +-Inf or NaN. */ +# ifdef __NO_LONG_DOUBLE_MATH +# define isfinite(x) \ + (sizeof (x) == sizeof (float) ? __finitef (x) : __finite (x)) +# else +# define isfinite(x) \ + (sizeof (x) == sizeof (float) \ + ? __finitef (x) \ + : sizeof (x) == sizeof (double) \ + ? __finite (x) : __finitel (x)) +# endif + +/* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN. */ +# define isnormal(x) (fpclassify (x) == FP_NORMAL) + +/* Return nonzero value if X is a NaN. We could use `fpclassify' but + we already have this functions `__isnan' and it is faster. */ +# ifdef __NO_LONG_DOUBLE_MATH +# define isnan(x) \ + (sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x)) +# else +# define isnan(x) \ + (sizeof (x) == sizeof (float) \ + ? __isnanf (x) \ + : sizeof (x) == sizeof (double) \ + ? __isnan (x) : __isnanl (x)) +# endif + +/* Return nonzero value is X is positive or negative infinity. */ +# ifdef __NO_LONG_DOUBLE_MATH +# define isinf(x) \ + (sizeof (x) == sizeof (float) ? __isinff (x) : __isinf (x)) +# else +# define isinf(x) \ + (sizeof (x) == sizeof (float) \ + ? __isinff (x) \ + : sizeof (x) == sizeof (double) \ + ? __isinf (x) : __isinfl (x)) +# endif + +/* Bitmasks for the math_errhandling macro. */ +# define MATH_ERRNO 1 /* errno set by math functions. */ +# define MATH_ERREXCEPT 2 /* Exceptions raised by math functions. */ + +#endif /* Use ISO C99. */ + +#ifdef __USE_MISC +/* Support for various different standard error handling behaviors. */ +typedef enum +{ + _IEEE_ = -1, /* According to IEEE 754/IEEE 854. */ + _SVID_, /* According to System V, release 4. */ + _XOPEN_, /* Nowadays also Unix98. */ + _POSIX_, + _ISOC_ /* Actually this is ISO C99. */ +} _LIB_VERSION_TYPE; + +/* This variable can be changed at run-time to any of the values above to + affect floating point error handling behavior (it may also be necessary + to change the hardware FPU exception settings). */ +extern _LIB_VERSION_TYPE _LIB_VERSION; +#endif + + +#ifdef __USE_SVID +/* In SVID error handling, `matherr' is called with this description + of the exceptional condition. + + We have a problem when using C++ since `exception' is a reserved + name in C++. */ +# ifdef __cplusplus +struct __exception +# else +struct exception +# endif + { + int type; + char *name; + double arg1; + double arg2; + double retval; + }; + +# ifdef __cplusplus +extern int matherr (struct __exception *__exc) throw (); +# else +extern int matherr (struct exception *__exc); +# endif + +# define X_TLOSS 1.41484755040568800000e+16 + +/* Types of exceptions in the `type' field. */ +# define DOMAIN 1 +# define SING 2 +# define OVERFLOW 3 +# define UNDERFLOW 4 +# define TLOSS 5 +# define PLOSS 6 + +/* SVID mode specifies returning this large value instead of infinity. */ +# define HUGE 3.40282347e+38F + +#else /* !SVID */ + +# ifdef __USE_XOPEN +/* X/Open wants another strange constant. */ +# define MAXFLOAT 3.40282347e+38F +# endif + +#endif /* SVID */ + + +/* Some useful constants. */ +#if defined __USE_BSD || defined __USE_XOPEN +# define M_E 2.7182818284590452354 /* e */ +# define M_LOG2E 1.4426950408889634074 /* log_2 e */ +# define M_LOG10E 0.43429448190325182765 /* log_10 e */ +# define M_LN2 0.69314718055994530942 /* log_e 2 */ +# define M_LN10 2.30258509299404568402 /* log_e 10 */ +# define M_PI 3.14159265358979323846 /* pi */ +# define M_PI_2 1.57079632679489661923 /* pi/2 */ +# define M_PI_4 0.78539816339744830962 /* pi/4 */ +# define M_1_PI 0.31830988618379067154 /* 1/pi */ +# define M_2_PI 0.63661977236758134308 /* 2/pi */ +# define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ +# define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ +# define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ +#endif + +/* The above constants are not adequate for computation using `long double's. + Therefore we provide as an extension constants with similar names as a + GNU extension. Provide enough digits for the 128-bit IEEE quad. */ +#ifdef __USE_GNU +# define M_El 2.7182818284590452353602874713526625L /* e */ +# define M_LOG2El 1.4426950408889634073599246810018921L /* log_2 e */ +# define M_LOG10El 0.4342944819032518276511289189166051L /* log_10 e */ +# define M_LN2l 0.6931471805599453094172321214581766L /* log_e 2 */ +# define M_LN10l 2.3025850929940456840179914546843642L /* log_e 10 */ +# define M_PIl 3.1415926535897932384626433832795029L /* pi */ +# define M_PI_2l 1.5707963267948966192313216916397514L /* pi/2 */ +# define M_PI_4l 0.7853981633974483096156608458198757L /* pi/4 */ +# define M_1_PIl 0.3183098861837906715377675267450287L /* 1/pi */ +# define M_2_PIl 0.6366197723675813430755350534900574L /* 2/pi */ +# define M_2_SQRTPIl 1.1283791670955125738961589031215452L /* 2/sqrt(pi) */ +# define M_SQRT2l 1.4142135623730950488016887242096981L /* sqrt(2) */ +# define M_SQRT1_2l 0.7071067811865475244008443621048490L /* 1/sqrt(2) */ +#endif + + +/* When compiling in strict ISO C compatible mode we must not use the + inline functions since they, among other things, do not set the + `errno' variable correctly. */ +#if defined __STRICT_ANSI__ && !defined __NO_MATH_INLINES +# define __NO_MATH_INLINES 1 +#endif + +#if defined __USE_ISOC99 && __GNUC_PREREQ(2,97) +/* ISO C99 defines some macros to compare number while taking care for + unordered numbers. Many FPUs provide special instructions to support + these operations. Generic support in GCC for these as builtins went + in before 3.0.0, but not all cpus added their patterns. We define + versions that use the builtins here, and will + undef/redefine as appropriate for the specific GCC version in use. */ +# define isgreater(x, y) __builtin_isgreater(x, y) +# define isgreaterequal(x, y) __builtin_isgreaterequal(x, y) +# define isless(x, y) __builtin_isless(x, y) +# define islessequal(x, y) __builtin_islessequal(x, y) +# define islessgreater(x, y) __builtin_islessgreater(x, y) +# define isunordered(u, v) __builtin_isunordered(u, v) +#endif + +/* Get machine-dependent inline versions (if there are any). */ +#ifdef __USE_EXTERN_INLINES +# include +#endif + +#ifdef __USE_ISOC99 +/* If we've still got undefined comparison macros, provide defaults. */ + +/* Return nonzero value if X is greater than Y. */ +# ifndef isgreater +# define isgreater(x, y) \ + (__extension__ \ + ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \ + !isunordered (__x, __y) && __x > __y; })) +# endif + +/* Return nonzero value if X is greater than or equal to Y. */ +# ifndef isgreaterequal +# define isgreaterequal(x, y) \ + (__extension__ \ + ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \ + !isunordered (__x, __y) && __x >= __y; })) +# endif + +/* Return nonzero value if X is less than Y. */ +# ifndef isless +# define isless(x, y) \ + (__extension__ \ + ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \ + !isunordered (__x, __y) && __x < __y; })) +# endif + +/* Return nonzero value if X is less than or equal to Y. */ +# ifndef islessequal +# define islessequal(x, y) \ + (__extension__ \ + ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \ + !isunordered (__x, __y) && __x <= __y; })) +# endif + +/* Return nonzero value if either X is less than Y or Y is less than X. */ +# ifndef islessgreater +# define islessgreater(x, y) \ + (__extension__ \ + ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \ + !isunordered (__x, __y) && (__x < __y || __y < __x); })) +# endif + +/* Return nonzero value if arguments are unordered. */ +# ifndef isunordered +# define isunordered(u, v) \ + (__extension__ \ + ({ __typeof__(u) __u = (u); __typeof__(v) __v = (v); \ + fpclassify (__u) == FP_NAN || fpclassify (__v) == FP_NAN; })) +# endif + +#endif + +__END_DECLS + + +#endif /* math.h */ diff --git a/conts/posix/libposix/include/posix/memory.h b/conts/posix/libposix/include/posix/memory.h new file mode 100644 index 0000000..743fa6a --- /dev/null +++ b/conts/posix/libposix/include/posix/memory.h @@ -0,0 +1,34 @@ +/* Copyright (C) 1991, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * SVID + */ + +#ifndef _MEMORY_H +#define _MEMORY_H 1 + +#include + + +#ifndef _STRING_H +# include +#endif /* string.h */ + + +#endif /* memory.h */ diff --git a/conts/posix/libposix/include/posix/mntent.h b/conts/posix/libposix/include/posix/mntent.h new file mode 100644 index 0000000..a82e953 --- /dev/null +++ b/conts/posix/libposix/include/posix/mntent.h @@ -0,0 +1,98 @@ +/* Utilities for reading/writing fstab, mtab, etc. + Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _MNTENT_H +#define _MNTENT_H 1 + +#include +#define __need_FILE +#include +#include + + +/* File listing canonical interesting mount points. */ +#define MNTTAB _PATH_MNTTAB /* Deprecated alias. */ + +/* File listing currently active mount points. */ +#define MOUNTED _PATH_MOUNTED /* Deprecated alias. */ + + +/* General filesystem types. */ +#define MNTTYPE_IGNORE "ignore" /* Ignore this entry. */ +#define MNTTYPE_NFS "nfs" /* Network file system. */ +#define MNTTYPE_SWAP "swap" /* Swap device. */ + + +/* Generic mount options. */ +#define MNTOPT_DEFAULTS "defaults" /* Use all default options. */ +#define MNTOPT_RO "ro" /* Read only. */ +#define MNTOPT_RW "rw" /* Read/write. */ +#define MNTOPT_SUID "suid" /* Set uid allowed. */ +#define MNTOPT_NOSUID "nosuid" /* No set uid allowed. */ +#define MNTOPT_NOAUTO "noauto" /* Do not auto mount. */ + + +__BEGIN_DECLS + +/* Structure describing a mount table entry. */ +struct mntent + { + char *mnt_fsname; /* Device or server for filesystem. */ + char *mnt_dir; /* Directory mounted on. */ + char *mnt_type; /* Type of filesystem: ufs, nfs, etc. */ + char *mnt_opts; /* Comma-separated options for fs. */ + int mnt_freq; /* Dump frequency (in days). */ + int mnt_passno; /* Pass number for `fsck'. */ + }; + + +/* Prepare to begin reading and/or writing mount table entries from the + beginning of FILE. MODE is as for `fopen'. */ +extern FILE *setmntent (__const char *__file, __const char *__mode) __THROW; + +/* Read one mount table entry from STREAM. Returns a pointer to storage + reused on the next call, or null for EOF or error (use feof/ferror to + check). */ +extern struct mntent *getmntent (FILE *__stream) __THROW; + +#ifdef __USE_MISC +/* Reentrant version of the above function. */ +extern struct mntent *getmntent_r (FILE *__restrict __stream, + struct mntent *__restrict __result, + char *__restrict __buffer, + int __bufsize) __THROW; +#endif + +/* Write the mount table entry described by MNT to STREAM. + Return zero on success, nonzero on failure. */ +extern int addmntent (FILE *__restrict __stream, + __const struct mntent *__restrict __mnt) __THROW; + +/* Close a stream opened with `setmntent'. */ +extern int endmntent (FILE *__stream) __THROW; + +/* Search MNT->mnt_opts for an option matching OPT. + Returns the address of the substring, or null if none found. */ +extern char *hasmntopt (__const struct mntent *__mnt, + __const char *__opt) __THROW; + + +__END_DECLS + +#endif /* mntent.h */ diff --git a/conts/posix/libposix/include/posix/mqueue.h b/conts/posix/libposix/include/posix/mqueue.h new file mode 100644 index 0000000..1ccad5b --- /dev/null +++ b/conts/posix/libposix/include/posix/mqueue.h @@ -0,0 +1,90 @@ +/* Copyright (C) 2004, 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _MQUEUE_H +#define _MQUEUE_H 1 + +#include +#include +#include +#define __need_sigevent_t +#include +#define __need_timespec +#include +/* Get the definition of mqd_t and struct mq_attr. */ +#include + +__BEGIN_DECLS + +/* Establish connection between a process and a message queue NAME and + return message queue descriptor or (mqd_t) -1 on error. OFLAG determines + the type of access used. If O_CREAT is on OFLAG, the third argument is + taken as a `mode_t', the mode of the created message queue, and the fourth + argument is taken as `struct mq_attr *', pointer to message queue + attributes. If the fourth argument is NULL, default attributes are + used. */ +extern mqd_t mq_open (const char *__name, int __oflag, ...) __THROW; + +/* Removes the association between message queue descriptor MQDES and its + message queue. */ +extern int mq_close (mqd_t __mqdes) __THROW; + +/* Query status and attributes of message queue MQDES. */ +extern int mq_getattr (mqd_t __mqdes, struct mq_attr *__mqstat) __THROW; + +/* Set attributes associated with message queue MQDES and if OMQSTAT is + not NULL also query its old attributes. */ +extern int mq_setattr (mqd_t __mqdes, + const struct mq_attr *__restrict __mqstat, + struct mq_attr *__restrict __omqstat) __THROW; + +/* Remove message queue named NAME. */ +extern int mq_unlink (const char *__name) __THROW; + +/* Register notification issued upon message arrival to an empty + message queue MQDES. */ +extern int mq_notify (mqd_t __mqdes, const struct sigevent *__notification) + __THROW; + +/* Receive the oldest from highest priority messages in message queue + MQDES. */ +extern ssize_t mq_receive (mqd_t __mqdes, char *__msg_ptr, size_t __msg_len, + unsigned int *__msg_prio); + +/* Add message pointed by MSG_PTR to message queue MQDES. */ +extern int mq_send (mqd_t __mqdes, const char *__msg_ptr, size_t __msg_len, + unsigned int __msg_prio); + +#ifdef __USE_XOPEN2K +/* Receive the oldest from highest priority messages in message queue + MQDES, stop waiting if ABS_TIMEOUT expires. */ +extern ssize_t mq_timedreceive (mqd_t __mqdes, char *__restrict __msg_ptr, + size_t __msg_len, + unsigned int *__restrict __msg_prio, + const struct timespec *__restrict __abs_timeout); + +/* Add message pointed by MSG_PTR to message queue MQDES, stop blocking + on full message queue if ABS_TIMEOUT expires. */ +extern int mq_timedsend (mqd_t __mqdes, const char *__msg_ptr, + size_t __msg_len, unsigned int __msg_prio, + const struct timespec *__abs_timeout); +#endif + +__END_DECLS + +#endif /* mqueue.h */ diff --git a/conts/posix/libposix/include/posix/net/ethernet.h b/conts/posix/libposix/include/posix/net/ethernet.h new file mode 100644 index 0000000..7ca8e83 --- /dev/null +++ b/conts/posix/libposix/include/posix/net/ethernet.h @@ -0,0 +1,76 @@ +/* Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Based on the FreeBSD version of this file. Curiously, that file + lacks a copyright in the header. */ + +#ifndef __NET_ETHERNET_H +#define __NET_ETHERNET_H 1 + +#include +#include +#include /* IEEE 802.3 Ethernet constants */ + +__BEGIN_DECLS + +/* This is a name for the 48 bit ethernet address available on many + systems. */ +struct ether_addr +{ + u_int8_t ether_addr_octet[ETH_ALEN]; +} __attribute__ ((__packed__)); + +/* 10Mb/s ethernet header */ +struct ether_header +{ + u_int8_t ether_dhost[ETH_ALEN]; /* destination eth addr */ + u_int8_t ether_shost[ETH_ALEN]; /* source ether addr */ + u_int16_t ether_type; /* packet type ID field */ +} __attribute__ ((__packed__)); + +/* Ethernet protocol ID's */ +#define ETHERTYPE_PUP 0x0200 /* Xerox PUP */ +#define ETHERTYPE_IP 0x0800 /* IP */ +#define ETHERTYPE_ARP 0x0806 /* Address resolution */ +#define ETHERTYPE_REVARP 0x8035 /* Reverse ARP */ + +#define ETHER_ADDR_LEN ETH_ALEN /* size of ethernet addr */ +#define ETHER_TYPE_LEN 2 /* bytes in type field */ +#define ETHER_CRC_LEN 4 /* bytes in CRC field */ +#define ETHER_HDR_LEN ETH_HLEN /* total octets in header */ +#define ETHER_MIN_LEN (ETH_ZLEN + ETHER_CRC_LEN) /* min packet length */ +#define ETHER_MAX_LEN (ETH_FRAME_LEN + ETHER_CRC_LEN) /* max packet length */ + +/* make sure ethenet length is valid */ +#define ETHER_IS_VALID_LEN(foo) \ + ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN) + +/* + * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have + * (type-ETHERTYPE_TRAIL)*512 bytes of data followed + * by an ETHER type (as given above) and then the (variable-length) header. + */ +#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */ +#define ETHERTYPE_NTRAILER 16 + +#define ETHERMTU ETH_DATA_LEN +#define ETHERMIN (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN) + +__END_DECLS + +#endif /* net/ethernet.h */ diff --git a/conts/posix/libposix/include/posix/net/if.h b/conts/posix/libposix/include/posix/net/if.h new file mode 100644 index 0000000..ebb3e9f --- /dev/null +++ b/conts/posix/libposix/include/posix/net/if.h @@ -0,0 +1,205 @@ +/* net/if.h -- declarations for inquiring about network interfaces + Copyright (C) 1997,98,99,2000,2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NET_IF_H +#define _NET_IF_H 1 + +#include + +#ifdef __USE_MISC +# include +# include +#endif + + +/* Length of interface name. */ +#define IF_NAMESIZE 16 + +struct if_nameindex + { + unsigned int if_index; /* 1, 2, ... */ + char *if_name; /* null terminated name: "eth0", ... */ + }; + + +#ifdef __USE_MISC +/* Standard interface flags. */ +enum + { + IFF_UP = 0x1, /* Interface is up. */ +# define IFF_UP IFF_UP + IFF_BROADCAST = 0x2, /* Broadcast address valid. */ +# define IFF_BROADCAST IFF_BROADCAST + IFF_DEBUG = 0x4, /* Turn on debugging. */ +# define IFF_DEBUG IFF_DEBUG + IFF_LOOPBACK = 0x8, /* Is a loopback net. */ +# define IFF_LOOPBACK IFF_LOOPBACK + IFF_POINTOPOINT = 0x10, /* Interface is point-to-point link. */ +# define IFF_POINTOPOINT IFF_POINTOPOINT + IFF_NOTRAILERS = 0x20, /* Avoid use of trailers. */ +# define IFF_NOTRAILERS IFF_NOTRAILERS + IFF_RUNNING = 0x40, /* Resources allocated. */ +# define IFF_RUNNING IFF_RUNNING + IFF_NOARP = 0x80, /* No address resolution protocol. */ +# define IFF_NOARP IFF_NOARP + IFF_PROMISC = 0x100, /* Receive all packets. */ +# define IFF_PROMISC IFF_PROMISC + + /* Not supported */ + IFF_ALLMULTI = 0x200, /* Receive all multicast packets. */ +# define IFF_ALLMULTI IFF_ALLMULTI + + IFF_MASTER = 0x400, /* Master of a load balancer. */ +# define IFF_MASTER IFF_MASTER + IFF_SLAVE = 0x800, /* Slave of a load balancer. */ +# define IFF_SLAVE IFF_SLAVE + + IFF_MULTICAST = 0x1000, /* Supports multicast. */ +# define IFF_MULTICAST IFF_MULTICAST + + IFF_PORTSEL = 0x2000, /* Can set media type. */ +# define IFF_PORTSEL IFF_PORTSEL + IFF_AUTOMEDIA = 0x4000, /* Auto media select active. */ +# define IFF_AUTOMEDIA IFF_AUTOMEDIA + IFF_DYNAMIC = 0x8000 /* Dialup device with changing addresses. */ +# define IFF_DYNAMIC IFF_DYNAMIC + }; + +/* The ifaddr structure contains information about one address of an + interface. They are maintained by the different address families, + are allocated and attached when an address is set, and are linked + together so all addresses for an interface can be located. */ + +struct ifaddr + { + struct sockaddr ifa_addr; /* Address of interface. */ + union + { + struct sockaddr ifu_broadaddr; + struct sockaddr ifu_dstaddr; + } ifa_ifu; + struct iface *ifa_ifp; /* Back-pointer to interface. */ + struct ifaddr *ifa_next; /* Next address for interface. */ + }; + +# define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */ +# define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of link */ + +/* Device mapping structure. I'd just gone off and designed a + beautiful scheme using only loadable modules with arguments for + driver options and along come the PCMCIA people 8) + + Ah well. The get() side of this is good for WDSETUP, and it'll be + handy for debugging things. The set side is fine for now and being + very small might be worth keeping for clean configuration. */ + +struct ifmap + { + unsigned long int mem_start; + unsigned long int mem_end; + unsigned short int base_addr; + unsigned char irq; + unsigned char dma; + unsigned char port; + /* 3 bytes spare */ + }; + +/* Interface request structure used for socket ioctl's. All interface + ioctl's must have parameter definitions which begin with ifr_name. + The remainder may be interface specific. */ + +struct ifreq + { +# define IFHWADDRLEN 6 +# define IFNAMSIZ IF_NAMESIZE + union + { + char ifrn_name[IFNAMSIZ]; /* Interface name, e.g. "en0". */ + } ifr_ifrn; + + union + { + struct sockaddr ifru_addr; + struct sockaddr ifru_dstaddr; + struct sockaddr ifru_broadaddr; + struct sockaddr ifru_netmask; + struct sockaddr ifru_hwaddr; + short int ifru_flags; + int ifru_ivalue; + int ifru_mtu; + struct ifmap ifru_map; + char ifru_slave[IFNAMSIZ]; /* Just fits the size */ + char ifru_newname[IFNAMSIZ]; + __caddr_t ifru_data; + } ifr_ifru; + }; +# define ifr_name ifr_ifrn.ifrn_name /* interface name */ +# define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ +# define ifr_addr ifr_ifru.ifru_addr /* address */ +# define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */ +# define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ +# define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ +# define ifr_flags ifr_ifru.ifru_flags /* flags */ +# define ifr_metric ifr_ifru.ifru_ivalue /* metric */ +# define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ +# define ifr_map ifr_ifru.ifru_map /* device map */ +# define ifr_slave ifr_ifru.ifru_slave /* slave device */ +# define ifr_data ifr_ifru.ifru_data /* for use by interface */ +# define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */ +# define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */ +# define ifr_qlen ifr_ifru.ifru_ivalue /* queue length */ +# define ifr_newname ifr_ifru.ifru_newname /* New name */ +# define _IOT_ifreq _IOT(_IOTS(char),IFNAMSIZ,_IOTS(char),16,0,0) +# define _IOT_ifreq_short _IOT(_IOTS(char),IFNAMSIZ,_IOTS(short),1,0,0) +# define _IOT_ifreq_int _IOT(_IOTS(char),IFNAMSIZ,_IOTS(int),1,0,0) + + +/* Structure used in SIOCGIFCONF request. Used to retrieve interface + configuration for machine (useful for programs which must know all + networks accessible). */ + +struct ifconf + { + int ifc_len; /* Size of buffer. */ + union + { + __caddr_t ifcu_buf; + struct ifreq *ifcu_req; + } ifc_ifcu; + }; +# define ifc_buf ifc_ifcu.ifcu_buf /* Buffer address. */ +# define ifc_req ifc_ifcu.ifcu_req /* Array of structures. */ +# define _IOT_ifconf _IOT(_IOTS(struct ifconf),1,0,0,0,0) /* not right */ +#endif /* Misc. */ + +__BEGIN_DECLS + +/* Convert an interface name to an index, and vice versa. */ +extern unsigned int if_nametoindex (__const char *__ifname) __THROW; +extern char *if_indextoname (unsigned int __ifindex, char *__ifname) __THROW; + +/* Return a list of all interfaces and their indices. */ +extern struct if_nameindex *if_nameindex (void) __THROW; + +/* Free the data returned from if_nameindex. */ +extern void if_freenameindex (struct if_nameindex *__ptr) __THROW; + +__END_DECLS + +#endif /* net/if.h */ diff --git a/conts/posix/libposix/include/posix/net/if_arp.h b/conts/posix/libposix/include/posix/net/if_arp.h new file mode 100644 index 0000000..46f035b --- /dev/null +++ b/conts/posix/libposix/include/posix/net/if_arp.h @@ -0,0 +1,176 @@ +/* Definitions for Address Resolution Protocol. + Copyright (C) 1997, 1999, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Based on the 4.4BSD and Linux version of this file. */ + +#ifndef _NET_IF_ARP_H + +#define _NET_IF_ARP_H 1 +#include + +#include +#include + +__BEGIN_DECLS + +/* Some internals from deep down in the kernel. */ +#define MAX_ADDR_LEN 7 + + +/* This structure defines an ethernet arp header. */ + +/* ARP protocol opcodes. */ +#define ARPOP_REQUEST 1 /* ARP request. */ +#define ARPOP_REPLY 2 /* ARP reply. */ +#define ARPOP_RREQUEST 3 /* RARP request. */ +#define ARPOP_RREPLY 4 /* RARP reply. */ +#define ARPOP_InREQUEST 8 /* InARP request. */ +#define ARPOP_InREPLY 9 /* InARP reply. */ +#define ARPOP_NAK 10 /* (ATM)ARP NAK. */ + +/* See RFC 826 for protocol description. ARP packets are variable + in size; the arphdr structure defines the fixed-length portion. + Protocol type values are the same as those for 10 Mb/s Ethernet. + It is followed by the variable-sized fields ar_sha, arp_spa, + arp_tha and arp_tpa in that order, according to the lengths + specified. Field names used correspond to RFC 826. */ + +struct arphdr + { + unsigned short int ar_hrd; /* Format of hardware address. */ + unsigned short int ar_pro; /* Format of protocol address. */ + unsigned char ar_hln; /* Length of hardware address. */ + unsigned char ar_pln; /* Length of protocol address. */ + unsigned short int ar_op; /* ARP opcode (command). */ +#if 0 + /* Ethernet looks like this : This bit is variable sized + however... */ + unsigned char __ar_sha[ETH_ALEN]; /* Sender hardware address. */ + unsigned char __ar_sip[4]; /* Sender IP address. */ + unsigned char __ar_tha[ETH_ALEN]; /* Target hardware address. */ + unsigned char __ar_tip[4]; /* Target IP address. */ +#endif + }; + + +/* ARP protocol HARDWARE identifiers. */ +#define ARPHRD_NETROM 0 /* From KA9Q: NET/ROM pseudo. */ +#define ARPHRD_ETHER 1 /* Ethernet 10/100Mbps. */ +#define ARPHRD_EETHER 2 /* Experimental Ethernet. */ +#define ARPHRD_AX25 3 /* AX.25 Level 2. */ +#define ARPHRD_PRONET 4 /* PROnet token ring. */ +#define ARPHRD_CHAOS 5 /* Chaosnet. */ +#define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB. */ +#define ARPHRD_ARCNET 7 /* ARCnet. */ +#define ARPHRD_APPLETLK 8 /* APPLEtalk. */ +#define ARPHRD_DLCI 15 /* Frame Relay DLCI. */ +#define ARPHRD_ATM 19 /* ATM. */ +#define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id). */ +#define ARPHRD_IEEE1394 24 /* IEEE 1394 IPv4 - RFC 2734. */ +#define ARPHRD_EUI64 27 /* EUI-64. */ +#define ARPHRD_INFINIBAND 32 /* InfiniBand. */ + +/* Dummy types for non ARP hardware */ +#define ARPHRD_SLIP 256 +#define ARPHRD_CSLIP 257 +#define ARPHRD_SLIP6 258 +#define ARPHRD_CSLIP6 259 +#define ARPHRD_RSRVD 260 /* Notional KISS type. */ +#define ARPHRD_ADAPT 264 +#define ARPHRD_ROSE 270 +#define ARPHRD_X25 271 /* CCITT X.25. */ +#define ARPHDR_HWX25 272 /* Boards with X.25 in firmware. */ +#define ARPHRD_PPP 512 +#define ARPHRD_CISCO 513 /* Cisco HDLC. */ +#define ARPHRD_HDLC ARPHRD_CISCO +#define ARPHRD_LAPB 516 /* LAPB. */ +#define ARPHRD_DDCMP 517 /* Digital's DDCMP. */ +#define ARPHRD_RAWHDLC 518 /* Raw HDLC. */ + +#define ARPHRD_TUNNEL 768 /* IPIP tunnel. */ +#define ARPHRD_TUNNEL6 769 /* IPIP6 tunnel. */ +#define ARPHRD_FRAD 770 /* Frame Relay Access Device. */ +#define ARPHRD_SKIP 771 /* SKIP vif. */ +#define ARPHRD_LOOPBACK 772 /* Loopback device. */ +#define ARPHRD_LOCALTLK 773 /* Localtalk device. */ +#define ARPHRD_FDDI 774 /* Fiber Distributed Data Interface. */ +#define ARPHRD_BIF 775 /* AP1000 BIF. */ +#define ARPHRD_SIT 776 /* sit0 device - IPv6-in-IPv4. */ +#define ARPHRD_IPDDP 777 /* IP-in-DDP tunnel. */ +#define ARPHRD_IPGRE 778 /* GRE over IP. */ +#define ARPHRD_PIMREG 779 /* PIMSM register interface. */ +#define ARPHRD_HIPPI 780 /* High Performance Parallel I'face. */ +#define ARPHRD_ASH 781 /* (Nexus Electronics) Ash. */ +#define ARPHRD_ECONET 782 /* Acorn Econet. */ +#define ARPHRD_IRDA 783 /* Linux-IrDA. */ +#define ARPHRD_FCPP 784 /* Point to point fibrechanel. */ +#define ARPHRD_FCAL 785 /* Fibrechanel arbitrated loop. */ +#define ARPHRD_FCPL 786 /* Fibrechanel public loop. */ +#define ARPHRD_FCFABRIC 787 /* Fibrechanel fabric. */ +#define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR. */ +#define ARPHRD_IEEE80211 801 /* IEEE 802.11. */ + +/* ARP ioctl request. */ +struct arpreq + { + struct sockaddr arp_pa; /* Protocol address. */ + struct sockaddr arp_ha; /* Hardware address. */ + int arp_flags; /* Flags. */ + struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */ + char arp_dev[16]; + }; + +struct arpreq_old + { + struct sockaddr arp_pa; /* Protocol address. */ + struct sockaddr arp_ha; /* Hardware address. */ + int arp_flags; /* Flags. */ + struct sockaddr arp_netmask; /* Netmask (only for proxy arps). */ + }; + +/* ARP Flag values. */ +#define ATF_COM 0x02 /* Completed entry (ha valid). */ +#define ATF_PERM 0x04 /* Permanent entry. */ +#define ATF_PUBL 0x08 /* Publish entry. */ +#define ATF_USETRAILERS 0x10 /* Has requested trailers. */ +#define ATF_NETMASK 0x20 /* Want to use a netmask (only + for proxy entries). */ +#define ATF_DONTPUB 0x40 /* Don't answer this addresses. */ +#define ATF_MAGIC 0x80 /* Automatically added entry. */ + + +/* Support for the user space arp daemon, arpd. */ +#define ARPD_UPDATE 0x01 +#define ARPD_LOOKUP 0x02 +#define ARPD_FLUSH 0x03 + +struct arpd_request + { + unsigned short int req; /* Request type. */ + u_int32_t ip; /* IP address of entry. */ + unsigned long int dev; /* Device entry is tied to. */ + unsigned long int stamp; + unsigned long int updated; + unsigned char ha[MAX_ADDR_LEN]; /* Hardware address. */ + }; + +__END_DECLS + +#endif /* net/if_arp.h */ diff --git a/conts/posix/libposix/include/posix/net/if_packet.h b/conts/posix/libposix/include/posix/net/if_packet.h new file mode 100644 index 0000000..e5184e7 --- /dev/null +++ b/conts/posix/libposix/include/posix/net/if_packet.h @@ -0,0 +1,37 @@ +/* Definitions for use with Linux SOCK_PACKET sockets. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef __IF_PACKET_H +#define __IF_PACKET_H + +#include +#include + +/* This is the SOCK_PACKET address structure as used in Linux 2.0. + From Linux 2.1 the AF_PACKET interface is preferred and you should + consider using it in place of this one. */ + +struct sockaddr_pkt + { + __SOCKADDR_COMMON (spkt_); + unsigned char spkt_device[14]; + unsigned short spkt_protocol; + }; + +#endif diff --git a/conts/posix/libposix/include/posix/net/if_ppp.h b/conts/posix/libposix/include/posix/net/if_ppp.h new file mode 100644 index 0000000..bf5ec83 --- /dev/null +++ b/conts/posix/libposix/include/posix/net/if_ppp.h @@ -0,0 +1,169 @@ +/* From: if_ppp.h,v 1.3 1995/06/12 11:36:50 paulus Exp */ + +/* + * if_ppp.h - Point-to-Point Protocol definitions. + * + * Copyright (c) 1989 Carnegie Mellon University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* + * ==FILEVERSION 960926== + * + * NOTE TO MAINTAINERS: + * If you modify this file at all, please set the above date. + * if_ppp.h is shipped with a PPP distribution as well as with the kernel; + * if everyone increases the FILEVERSION number above, then scripts + * can do the right thing when deciding whether to install a new if_ppp.h + * file. Don't change the format of that line otherwise, so the + * installation script can recognize it. + */ + + +#ifndef __NET_IF_PPP_H +#define __NET_IF_PPP_H 1 + +#include +#include + +#include +#include +#include + +__BEGIN_DECLS + +/* + * Packet sizes + */ + +#define PPP_MTU 1500 /* Default MTU (size of Info field) */ +#define PPP_MAXMRU 65000 /* Largest MRU we allow */ +#define PPP_VERSION "2.2.0" +#define PPP_MAGIC 0x5002 /* Magic value for the ppp structure */ +#define PROTO_IPX 0x002b /* protocol numbers */ +#define PROTO_DNA_RT 0x0027 /* DNA Routing */ + + +/* + * Bit definitions for flags. + */ + +#define SC_COMP_PROT 0x00000001 /* protocol compression (output) */ +#define SC_COMP_AC 0x00000002 /* header compression (output) */ +#define SC_COMP_TCP 0x00000004 /* TCP (VJ) compression (output) */ +#define SC_NO_TCP_CCID 0x00000008 /* disable VJ connection-id comp. */ +#define SC_REJ_COMP_AC 0x00000010 /* reject adrs/ctrl comp. on input */ +#define SC_REJ_COMP_TCP 0x00000020 /* reject TCP (VJ) comp. on input */ +#define SC_CCP_OPEN 0x00000040 /* Look at CCP packets */ +#define SC_CCP_UP 0x00000080 /* May send/recv compressed packets */ +#define SC_ENABLE_IP 0x00000100 /* IP packets may be exchanged */ +#define SC_COMP_RUN 0x00001000 /* compressor has been inited */ +#define SC_DECOMP_RUN 0x00002000 /* decompressor has been inited */ +#define SC_DEBUG 0x00010000 /* enable debug messages */ +#define SC_LOG_INPKT 0x00020000 /* log contents of good pkts recvd */ +#define SC_LOG_OUTPKT 0x00040000 /* log contents of pkts sent */ +#define SC_LOG_RAWIN 0x00080000 /* log all chars received */ +#define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */ +#define SC_MASK 0x0fE0ffff /* bits that user can change */ + +/* state bits */ +#define SC_ESCAPED 0x80000000 /* saw a PPP_ESCAPE */ +#define SC_FLUSH 0x40000000 /* flush input until next PPP_FLAG */ +#define SC_VJ_RESET 0x20000000 /* Need to reset the VJ decompressor */ +#define SC_XMIT_BUSY 0x10000000 /* ppp_write_wakeup is active */ +#define SC_RCV_ODDP 0x08000000 /* have rcvd char with odd parity */ +#define SC_RCV_EVNP 0x04000000 /* have rcvd char with even parity */ +#define SC_RCV_B7_1 0x02000000 /* have rcvd char with bit 7 = 1 */ +#define SC_RCV_B7_0 0x01000000 /* have rcvd char with bit 7 = 0 */ +#define SC_DC_FERROR 0x00800000 /* fatal decomp error detected */ +#define SC_DC_ERROR 0x00400000 /* non-fatal decomp error detected */ + +/* + * Ioctl definitions. + */ + +struct npioctl { + int protocol; /* PPP protocol, e.g. PPP_IP */ + enum NPmode mode; +}; + +/* Structure describing a CCP configuration option, for PPPIOCSCOMPRESS */ +struct ppp_option_data { + u_int8_t *ptr; + u_int32_t length; + int transmit; +}; + +struct ifpppstatsreq { + struct ifreq b; + struct ppp_stats stats; /* statistic information */ +}; + +struct ifpppcstatsreq { + struct ifreq b; + struct ppp_comp_stats stats; +}; + +#define ifr__name b.ifr_ifrn.ifrn_name +#define stats_ptr b.ifr_ifru.ifru_data + +/* + * Ioctl definitions. + */ + +#define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */ +#define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */ +#define PPPIOCGASYNCMAP _IOR('t', 88, int) /* get async map */ +#define PPPIOCSASYNCMAP _IOW('t', 87, int) /* set async map */ +#define PPPIOCGUNIT _IOR('t', 86, int) /* get ppp unit number */ +#define PPPIOCGRASYNCMAP _IOR('t', 85, int) /* get receive async map */ +#define PPPIOCSRASYNCMAP _IOW('t', 84, int) /* set receive async map */ +#define PPPIOCGMRU _IOR('t', 83, int) /* get max receive unit */ +#define PPPIOCSMRU _IOW('t', 82, int) /* set max receive unit */ +#define PPPIOCSMAXCID _IOW('t', 81, int) /* set VJ max slot ID */ +#define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm) /* get extended ACCM */ +#define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm) /* set extended ACCM */ +#define PPPIOCXFERUNIT _IO('t', 78) /* transfer PPP unit */ +#define PPPIOCSCOMPRESS _IOW('t', 77, struct ppp_option_data) +#define PPPIOCGNPMODE _IOWR('t', 76, struct npioctl) /* get NP mode */ +#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) /* set NP mode */ +#define PPPIOCGDEBUG _IOR('t', 65, int) /* Read debug level */ +#define PPPIOCSDEBUG _IOW('t', 64, int) /* Set debug level */ +#define PPPIOCGIDLE _IOR('t', 63, struct ppp_idle) /* get idle time */ + +#define SIOCGPPPSTATS (SIOCDEVPRIVATE + 0) +#define SIOCGPPPVER (SIOCDEVPRIVATE + 1) /* NEVER change this!! */ +#define SIOCGPPPCSTATS (SIOCDEVPRIVATE + 2) + +#if !defined(ifr_mtu) +#define ifr_mtu ifr_ifru.ifru_metric +#endif + +__END_DECLS + +#endif /* net/if_ppp.h */ diff --git a/conts/posix/libposix/include/posix/net/if_shaper.h b/conts/posix/libposix/include/posix/net/if_shaper.h new file mode 100644 index 0000000..7060af3 --- /dev/null +++ b/conts/posix/libposix/include/posix/net/if_shaper.h @@ -0,0 +1,59 @@ +/* Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NET_IF_SHAPER_H +#define _NET_IF_SHAPER_H 1 + +#include +#include +#include +#include + +__BEGIN_DECLS + +#define SHAPER_QLEN 10 +/* + * This is a bit speed dependant (read it shouldnt be a constant!) + * + * 5 is about right for 28.8 upwards. Below that double for every + * halving of speed or so. - ie about 20 for 9600 baud. + */ +#define SHAPER_LATENCY (5 * HZ) +#define SHAPER_MAXSLIP 2 +#define SHAPER_BURST (HZ / 50) /* Good for >128K then */ + +#define SHAPER_SET_DEV 0x0001 +#define SHAPER_SET_SPEED 0x0002 +#define SHAPER_GET_DEV 0x0003 +#define SHAPER_GET_SPEED 0x0004 + +struct shaperconf +{ + u_int16_t ss_cmd; + union + { + char ssu_name[14]; + u_int32_t ssu_speed; + } ss_u; +#define ss_speed ss_u.ssu_speed +#define ss_name ss_u.ssu_name +}; + +__END_DECLS + +#endif /* net/if_shaper.h */ diff --git a/conts/posix/libposix/include/posix/net/if_slip.h b/conts/posix/libposix/include/posix/net/if_slip.h new file mode 100644 index 0000000..66bd7f3 --- /dev/null +++ b/conts/posix/libposix/include/posix/net/if_slip.h @@ -0,0 +1,25 @@ +/* Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NET_IF_SLIP_H +#define _NET_IF_SLIP_H 1 + +/* We can use the kernel header. */ +#include + +#endif /* net/if_slip.h. */ diff --git a/conts/posix/libposix/include/posix/net/ppp-comp.h b/conts/posix/libposix/include/posix/net/ppp-comp.h new file mode 100644 index 0000000..4a992d5 --- /dev/null +++ b/conts/posix/libposix/include/posix/net/ppp-comp.h @@ -0,0 +1 @@ +#include diff --git a/conts/posix/libposix/include/posix/net/ppp_defs.h b/conts/posix/libposix/include/posix/net/ppp_defs.h new file mode 100644 index 0000000..f8924c4 --- /dev/null +++ b/conts/posix/libposix/include/posix/net/ppp_defs.h @@ -0,0 +1,10 @@ +#ifndef _NET_PPP_DEFS_H +#define _NET_PPP_DEFS_H 1 + +#define __need_time_t +#include + +#include +#include + +#endif /* net/ppp_defs.h */ diff --git a/conts/posix/libposix/include/posix/net/route.h b/conts/posix/libposix/include/posix/net/route.h new file mode 100644 index 0000000..da5c810 --- /dev/null +++ b/conts/posix/libposix/include/posix/net/route.h @@ -0,0 +1,145 @@ +/* Copyright (C) 1997, 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Based on the 4.4BSD and Linux version of this file. */ + +#ifndef _NET_ROUTE_H +#define _NET_ROUTE_H 1 + +#include +#include +#include +#include +#include + + +/* This structure gets passed by the SIOCADDRT and SIOCDELRT calls. */ +struct rtentry + { + unsigned long int rt_pad1; + struct sockaddr rt_dst; /* Target address. */ + struct sockaddr rt_gateway; /* Gateway addr (RTF_GATEWAY). */ + struct sockaddr rt_genmask; /* Target network mask (IP). */ + unsigned short int rt_flags; + short int rt_pad2; + unsigned long int rt_pad3; + unsigned char rt_tos; + unsigned char rt_class; +#if __WORDSIZE == 64 + short int rt_pad4[3]; +#else + short int rt_pad4; +#endif + short int rt_metric; /* +1 for binary compatibility! */ + char *rt_dev; /* Forcing the device at add. */ + unsigned long int rt_mtu; /* Per route MTU/Window. */ + unsigned long int rt_window; /* Window clamping. */ + unsigned short int rt_irtt; /* Initial RTT. */ + }; +/* Compatibility hack. */ +#define rt_mss rt_mtu + + +struct in6_rtmsg + { + struct in6_addr rtmsg_dst; + struct in6_addr rtmsg_src; + struct in6_addr rtmsg_gateway; + u_int32_t rtmsg_type; + u_int16_t rtmsg_dst_len; + u_int16_t rtmsg_src_len; + u_int32_t rtmsg_metric; + unsigned long int rtmsg_info; + u_int32_t rtmsg_flags; + int rtmsg_ifindex; + }; + + +#define RTF_UP 0x0001 /* Route usable. */ +#define RTF_GATEWAY 0x0002 /* Destination is a gateway. */ + +#define RTF_HOST 0x0004 /* Host entry (net otherwise). */ +#define RTF_REINSTATE 0x0008 /* Reinstate route after timeout. */ +#define RTF_DYNAMIC 0x0010 /* Created dyn. (by redirect). */ +#define RTF_MODIFIED 0x0020 /* Modified dyn. (by redirect). */ +#define RTF_MTU 0x0040 /* Specific MTU for this route. */ +#define RTF_MSS RTF_MTU /* Compatibility. */ +#define RTF_WINDOW 0x0080 /* Per route window clamping. */ +#define RTF_IRTT 0x0100 /* Initial round trip time. */ +#define RTF_REJECT 0x0200 /* Reject route. */ +#define RTF_STATIC 0x0400 /* Manually injected route. */ +#define RTF_XRESOLVE 0x0800 /* External resolver. */ +#define RTF_NOFORWARD 0x1000 /* Forwarding inhibited. */ +#define RTF_THROW 0x2000 /* Go to next class. */ +#define RTF_NOPMTUDISC 0x4000 /* Do not send packets with DF. */ + +/* for IPv6 */ +#define RTF_DEFAULT 0x00010000 /* default - learned via ND */ +#define RTF_ALLONLINK 0x00020000 /* fallback, no routers on link */ +#define RTF_ADDRCONF 0x00040000 /* addrconf route - RA */ + +#define RTF_LINKRT 0x00100000 /* link specific - device match */ +#define RTF_NONEXTHOP 0x00200000 /* route with no nexthop */ + +#define RTF_CACHE 0x01000000 /* cache entry */ +#define RTF_FLOW 0x02000000 /* flow significant route */ +#define RTF_POLICY 0x04000000 /* policy route */ + +#define RTCF_VALVE 0x00200000 +#define RTCF_MASQ 0x00400000 +#define RTCF_NAT 0x00800000 +#define RTCF_DOREDIRECT 0x01000000 +#define RTCF_LOG 0x02000000 +#define RTCF_DIRECTSRC 0x04000000 + +#define RTF_LOCAL 0x80000000 +#define RTF_INTERFACE 0x40000000 +#define RTF_MULTICAST 0x20000000 +#define RTF_BROADCAST 0x10000000 +#define RTF_NAT 0x08000000 + +#define RTF_ADDRCLASSMASK 0xF8000000 +#define RT_ADDRCLASS(flags) ((__u_int32_t) flags >> 23) + +#define RT_TOS(tos) ((tos) & IPTOS_TOS_MASK) + +#define RT_LOCALADDR(flags) ((flags & RTF_ADDRCLASSMASK) \ + == (RTF_LOCAL|RTF_INTERFACE)) + +#define RT_CLASS_UNSPEC 0 +#define RT_CLASS_DEFAULT 253 + +#define RT_CLASS_MAIN 254 +#define RT_CLASS_LOCAL 255 +#define RT_CLASS_MAX 255 + + +#define RTMSG_ACK NLMSG_ACK +#define RTMSG_OVERRUN NLMSG_OVERRUN + +#define RTMSG_NEWDEVICE 0x11 +#define RTMSG_DELDEVICE 0x12 +#define RTMSG_NEWROUTE 0x21 +#define RTMSG_DELROUTE 0x22 +#define RTMSG_NEWRULE 0x31 +#define RTMSG_DELRULE 0x32 +#define RTMSG_CONTROL 0x40 + +#define RTMSG_AR_FAILED 0x51 /* Address Resolution failed. */ + +#endif /* net/route.h */ diff --git a/conts/posix/libposix/include/posix/netax25/ax25.h b/conts/posix/libposix/include/posix/netax25/ax25.h new file mode 100644 index 0000000..ce3c7ab --- /dev/null +++ b/conts/posix/libposix/include/posix/netax25/ax25.h @@ -0,0 +1,171 @@ +/* Copyright (C) 1997, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NETAX25_AX25_H +#define _NETAX25_AX25_H 1 + +#include +#include + +/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx. */ +#define SOL_AX25 257 + +/* AX.25 flags: */ +#define AX25_WINDOW 1 +#define AX25_T1 2 +#define AX25_T2 5 +#define AX25_T3 4 +#define AX25_N2 3 +#define AX25_BACKOFF 6 +#define AX25_EXTSEQ 7 +#define AX25_PIDINCL 8 +#define AX25_IDLE 9 +#define AX25_PACLEN 10 +#define AX25_IPMAXQUEUE 11 +#define AX25_IAMDIGI 12 +#define AX25_KILL 99 + +/* AX.25 socket ioctls: */ +#define SIOCAX25GETUID (SIOCPROTOPRIVATE) +#define SIOCAX25ADDUID (SIOCPROTOPRIVATE+1) +#define SIOCAX25DELUID (SIOCPROTOPRIVATE+2) +#define SIOCAX25NOUID (SIOCPROTOPRIVATE+3) +#define SIOCAX25BPQADDR (SIOCPROTOPRIVATE+4) +#define SIOCAX25GETPARMS (SIOCPROTOPRIVATE+5) +#define SIOCAX25SETPARMS (SIOCPROTOPRIVATE+6) +#define SIOCAX25OPTRT (SIOCPROTOPRIVATE+7) +#define SIOCAX25CTLCON (SIOCPROTOPRIVATE+8) +#define SIOCAX25GETINFO (SIOCPROTOPRIVATE+9) +#define SIOCAX25ADDFWD (SIOCPROTOPRIVATE+10) +#define SIOCAX25DELFWD (SIOCPROTOPRIVATE+11) + +/* unknown: */ +#define AX25_NOUID_DEFAULT 0 +#define AX25_NOUID_BLOCK 1 +#define AX25_SET_RT_IPMODE 2 + +/* Digipeating flags: */ +#define AX25_DIGI_INBAND 0x01 /* Allow digipeating within port */ +#define AX25_DIGI_XBAND 0x02 /* Allow digipeating across ports */ + +/* Maximim number of digipeaters: */ +#define AX25_MAX_DIGIS 8 + + +typedef struct + { + char ax25_call[7]; /* 6 call + SSID (shifted ascii) */ + } +ax25_address; + +struct sockaddr_ax25 + { + sa_family_t sax25_family; + ax25_address sax25_call; + int sax25_ndigis; + }; + +/* + * The sockaddr struct with the digipeater adresses: + */ +struct full_sockaddr_ax25 + { + struct sockaddr_ax25 fsa_ax25; + ax25_address fsa_digipeater[AX25_MAX_DIGIS]; + }; +#define sax25_uid sax25_ndigis + +struct ax25_routes_struct + { + ax25_address port_addr; + ax25_address dest_addr; + unsigned char digi_count; + ax25_address digi_addr[AX25_MAX_DIGIS]; + }; + +/* The AX.25 ioctl structure: */ +struct ax25_ctl_struct + { + ax25_address port_addr; + ax25_address source_addr; + ax25_address dest_addr; + unsigned int cmd; + unsigned long arg; + unsigned char digi_count; + ax25_address digi_addr[AX25_MAX_DIGIS]; + }; + +struct ax25_info_struct + { + unsigned int n2, n2count; + unsigned int t1, t1timer; + unsigned int t2, t2timer; + unsigned int t3, t3timer; + unsigned int idle, idletimer; + unsigned int state; + unsigned int rcv_q, snd_q; + }; + +struct ax25_fwd_struct + { + ax25_address port_from; + ax25_address port_to; + }; + +/* AX.25 route structure: */ +struct ax25_route_opt_struct + { + ax25_address port_addr; + ax25_address dest_addr; + int cmd; + int arg; + }; + +/* AX.25 BPQ stuff: */ +struct ax25_bpqaddr_struct + { + char dev[16]; + ax25_address addr; + }; + +/* Definitions for the AX.25 `values' fields: */ +#define AX25_VALUES_IPDEFMODE 0 /* 'D'=DG 'V'=VC */ +#define AX25_VALUES_AXDEFMODE 1 /* 8=Normal 128=Extended Seq Nos */ +#define AX25_VALUES_NETROM 2 /* Allow NET/ROM - 0=No 1=Yes */ +#define AX25_VALUES_TEXT 3 /* Allow PID=Text - 0=No 1=Yes */ +#define AX25_VALUES_BACKOFF 4 /* 'E'=Exponential 'L'=Linear */ +#define AX25_VALUES_CONMODE 5 /* Allow connected modes - 0=No 1=Yes */ +#define AX25_VALUES_WINDOW 6 /* Default window size for standard AX.25 */ +#define AX25_VALUES_EWINDOW 7 /* Default window size for extended AX.25 */ +#define AX25_VALUES_T1 8 /* Default T1 timeout value */ +#define AX25_VALUES_T2 9 /* Default T2 timeout value */ +#define AX25_VALUES_T3 10 /* Default T3 timeout value */ +#define AX25_VALUES_N2 11 /* Default N2 value */ +#define AX25_VALUES_DIGI 12 /* Digipeat mode */ +#define AX25_VALUES_IDLE 13 /* mode vc idle timer */ +#define AX25_VALUES_PACLEN 14 /* AX.25 MTU */ +#define AX25_VALUES_IPMAXQUEUE 15 /* Maximum number of buffers enqueued */ +#define AX25_MAX_VALUES 20 + +struct ax25_parms_struct + { + ax25_address port_addr; + unsigned short values[AX25_MAX_VALUES]; + }; + +#endif /* netax25/ax25.h */ diff --git a/conts/posix/libposix/include/posix/netdb.h b/conts/posix/libposix/include/posix/netdb.h new file mode 100644 index 0000000..fe3da82 --- /dev/null +++ b/conts/posix/libposix/include/posix/netdb.h @@ -0,0 +1,658 @@ +/* Copyright (C) 1996-2002, 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* All data returned by the network data base library are supplied in + host order and returned in network order (suitable for use in + system calls). */ + +#ifndef _NETDB_H +#define _NETDB_H 1 + +#include + +#include +#include +#ifdef __USE_MISC +/* This is necessary to make this include file properly replace the + Sun version. */ +# include +#endif + +#ifdef __USE_GNU +# define __need_sigevent_t +# include +# define __need_timespec +# include +#endif + +#include + +/* Absolute file name for network data base files. */ +#define _PATH_HEQUIV "/etc/hosts.equiv" +#define _PATH_HOSTS "/etc/hosts" +#define _PATH_NETWORKS "/etc/networks" +#define _PATH_NSSWITCH_CONF "/etc/nsswitch.conf" +#define _PATH_PROTOCOLS "/etc/protocols" +#define _PATH_SERVICES "/etc/services" + + +__BEGIN_DECLS + +/* Error status for non-reentrant lookup functions. + We use a macro to access always the thread-specific `h_errno' variable. + We always need the extern int here in case internal libc code undefines + the macro because it needs access to the underlying storage. */ +extern int h_errno; +#ifdef __UCLIBC_HAS_THREADS__ +# define h_errno (*__h_errno_location ()) +#endif + +/* Function to get address of global `h_errno' variable. */ +extern int *__h_errno_location (void) __THROW __attribute__ ((__const__)); + +#ifdef _LIBC +# define __set_h_errno(x) (h_errno = (x)) +#endif + +/* Possible values left in `h_errno'. */ +#define NETDB_INTERNAL -1 /* See errno. */ +#define NETDB_SUCCESS 0 /* No problem. */ +#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found. */ +#define TRY_AGAIN 2 /* Non-Authoritative Host not found, + or SERVERFAIL. */ +#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, + NOTIMP. */ +#define NO_DATA 4 /* Valid name, no data record of requested + type. */ +#define NO_ADDRESS NO_DATA /* No address, look for MX record. */ + +#ifdef __USE_XOPEN2K +/* Highest reserved Internet port number. */ +# define IPPORT_RESERVED 1024 +#endif + +#ifdef __USE_GNU +/* Scope delimiter for getaddrinfo(), getnameinfo(). */ +# define SCOPE_DELIMITER '%' +#endif + +/* Print error indicated by `h_errno' variable on standard error. STR + if non-null is printed before the error string. */ +extern void herror (__const char *__str) __THROW; + +/* Return string associated with error ERR_NUM. */ +extern __const char *hstrerror (int __err_num) __THROW; + + + +/* Description of data base entry for a single host. */ +struct hostent +{ + char *h_name; /* Official name of host. */ + char **h_aliases; /* Alias list. */ + int h_addrtype; /* Host address type. */ + int h_length; /* Length of address. */ + char **h_addr_list; /* List of addresses from name server. */ +#define h_addr h_addr_list[0] /* Address, for backward compatibility. */ +}; + +/* Open host data base files and mark them as staying open even after + a later search if STAY_OPEN is non-zero. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void sethostent (int __stay_open); + +/* Close host data base files and clear `stay open' flag. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void endhostent (void); + +/* Get next entry from host data base file. Open data base if + necessary. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct hostent *gethostent (void); + +/* Return entry from host data base which address match ADDR with + length LEN and type TYPE. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct hostent *gethostbyaddr (__const void *__addr, __socklen_t __len, + int __type); + +/* Return entry from host data base for host with NAME. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct hostent *gethostbyname (__const char *__name); + +#ifdef __USE_MISC +/* Return entry from host data base for host with NAME. AF must be + set to the address type which is `AF_INET' for IPv4 or `AF_INET6' + for IPv6. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern struct hostent *gethostbyname2 (__const char *__name, int __af); + +/* Reentrant versions of the functions above. The additional + arguments specify a buffer of BUFLEN starting at BUF. The last + argument is a pointer to a variable which gets the value which + would be stored in the global variable `herrno' by the + non-reentrant functions. + + These functions are not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation they are cancellation points and + therefore not marked with __THROW. */ +extern int gethostent_r (struct hostent *__restrict __result_buf, + char *__restrict __buf, size_t __buflen, + struct hostent **__restrict __result, + int *__restrict __h_errnop); + +extern int gethostbyaddr_r (__const void *__restrict __addr, __socklen_t __len, + int __type, + struct hostent *__restrict __result_buf, + char *__restrict __buf, size_t __buflen, + struct hostent **__restrict __result, + int *__restrict __h_errnop); + +extern int gethostbyname_r (__const char *__restrict __name, + struct hostent *__restrict __result_buf, + char *__restrict __buf, size_t __buflen, + struct hostent **__restrict __result, + int *__restrict __h_errnop); + +extern int gethostbyname2_r (__const char *__restrict __name, int __af, + struct hostent *__restrict __result_buf, + char *__restrict __buf, size_t __buflen, + struct hostent **__restrict __result, + int *__restrict __h_errnop); +#endif /* misc */ + + +/* Open network data base files and mark them as staying open even + after a later search if STAY_OPEN is non-zero. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void setnetent (int __stay_open); + +/* Close network data base files and clear `stay open' flag. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void endnetent (void); + +/* Get next entry from network data base file. Open data base if + necessary. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct netent *getnetent (void); + +/* Return entry from network data base which address match NET and + type TYPE. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct netent *getnetbyaddr (uint32_t __net, int __type); + +/* Return entry from network data base for network with NAME. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct netent *getnetbyname (__const char *__name); + +#if 0 +/* FIXME */ +#ifdef __USE_MISC +/* Reentrant versions of the functions above. The additional + arguments specify a buffer of BUFLEN starting at BUF. The last + argument is a pointer to a variable which gets the value which + would be stored in the global variable `herrno' by the + non-reentrant functions. + + These functions are not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation they are cancellation points and + therefore not marked with __THROW. */ +extern int getnetent_r (struct netent *__restrict __result_buf, + char *__restrict __buf, size_t __buflen, + struct netent **__restrict __result, + int *__restrict __h_errnop); + +extern int getnetbyaddr_r (uint32_t __net, int __type, + struct netent *__restrict __result_buf, + char *__restrict __buf, size_t __buflen, + struct netent **__restrict __result, + int *__restrict __h_errnop); + +extern int getnetbyname_r (__const char *__restrict __name, + struct netent *__restrict __result_buf, + char *__restrict __buf, size_t __buflen, + struct netent **__restrict __result, + int *__restrict __h_errnop); +#endif /* misc */ +#endif + + +/* Description of data base entry for a single service. */ +struct servent +{ + char *s_name; /* Official service name. */ + char **s_aliases; /* Alias list. */ + int s_port; /* Port number. */ + char *s_proto; /* Protocol to use. */ +}; + +/* Open service data base files and mark them as staying open even + after a later search if STAY_OPEN is non-zero. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void setservent (int __stay_open); + +/* Close service data base files and clear `stay open' flag. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void endservent (void); + +/* Get next entry from service data base file. Open data base if + necessary. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct servent *getservent (void); + +/* Return entry from network data base for network with NAME and + protocol PROTO. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct servent *getservbyname (__const char *__name, + __const char *__proto); + +/* Return entry from service data base which matches port PORT and + protocol PROTO. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct servent *getservbyport (int __port, __const char *__proto); + + +#ifdef __USE_MISC +/* Reentrant versions of the functions above. The additional + arguments specify a buffer of BUFLEN starting at BUF. + + These functions are not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation they are cancellation points and + therefore not marked with __THROW. */ +extern int getservent_r (struct servent *__restrict __result_buf, + char *__restrict __buf, size_t __buflen, + struct servent **__restrict __result); + +extern int getservbyname_r (__const char *__restrict __name, + __const char *__restrict __proto, + struct servent *__restrict __result_buf, + char *__restrict __buf, size_t __buflen, + struct servent **__restrict __result); + +extern int getservbyport_r (int __port, __const char *__restrict __proto, + struct servent *__restrict __result_buf, + char *__restrict __buf, size_t __buflen, + struct servent **__restrict __result); +#endif /* misc */ + + +/* Description of data base entry for a single service. */ +struct protoent +{ + char *p_name; /* Official protocol name. */ + char **p_aliases; /* Alias list. */ + int p_proto; /* Protocol number. */ +}; + +/* Open protocol data base files and mark them as staying open even + after a later search if STAY_OPEN is non-zero. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void setprotoent (int __stay_open); + +/* Close protocol data base files and clear `stay open' flag. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void endprotoent (void); + +/* Get next entry from protocol data base file. Open data base if + necessary. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct protoent *getprotoent (void); + +/* Return entry from protocol data base for network with NAME. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct protoent *getprotobyname (__const char *__name); + +/* Return entry from protocol data base which number is PROTO. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct protoent *getprotobynumber (int __proto); + + +#ifdef __USE_MISC +/* Reentrant versions of the functions above. The additional + arguments specify a buffer of BUFLEN starting at BUF. + + These functions are not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation they are cancellation points and + therefore not marked with __THROW. */ +extern int getprotoent_r (struct protoent *__restrict __result_buf, + char *__restrict __buf, size_t __buflen, + struct protoent **__restrict __result); + +extern int getprotobyname_r (__const char *__restrict __name, + struct protoent *__restrict __result_buf, + char *__restrict __buf, size_t __buflen, + struct protoent **__restrict __result); + +extern int getprotobynumber_r (int __proto, + struct protoent *__restrict __result_buf, + char *__restrict __buf, size_t __buflen, + struct protoent **__restrict __result); + + +#ifdef __UCLIBC_HAS_NETGROUP__ +/* Establish network group NETGROUP for enumeration. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int setnetgrent (__const char *__netgroup); + +/* Free all space allocated by previous `setnetgrent' call. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern void endnetgrent (void); + +/* Get next member of netgroup established by last `setnetgrent' call + and return pointers to elements in HOSTP, USERP, and DOMAINP. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int getnetgrent (char **__restrict __hostp, + char **__restrict __userp, + char **__restrict __domainp); + + +/* Test whether NETGROUP contains the triple (HOST,USER,DOMAIN). + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int innetgr (__const char *__netgroup, __const char *__host, + __const char *__user, __const char *domain); + +/* Reentrant version of `getnetgrent' where result is placed in BUFFER. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int getnetgrent_r (char **__restrict __hostp, + char **__restrict __userp, + char **__restrict __domainp, + char *__restrict __buffer, size_t __buflen); +#endif /* UCLIBC_HAS_NETGROUP */ +#endif /* misc */ + + +#ifdef __USE_BSD +/* Call `rshd' at port RPORT on remote machine *AHOST to execute CMD. + The local user is LOCUSER, on the remote machine the command is + executed as REMUSER. In *FD2P the descriptor to the socket for the + connection is returned. The caller must have the right to use a + reserved port. When the function returns *AHOST contains the + official host name. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int rcmd (char **__restrict __ahost, unsigned short int __rport, + __const char *__restrict __locuser, + __const char *__restrict __remuser, + __const char *__restrict __cmd, int *__restrict __fd2p); + +#if 0 +/* FIXME */ +/* This is the equivalent function where the protocol can be selected + and which therefore can be used for IPv6. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int rcmd_af (char **__restrict __ahost, unsigned short int __rport, + __const char *__restrict __locuser, + __const char *__restrict __remuser, + __const char *__restrict __cmd, int *__restrict __fd2p, + sa_family_t __af); +#endif + +/* Call `rexecd' at port RPORT on remote machine *AHOST to execute + CMD. The process runs at the remote machine using the ID of user + NAME whose cleartext password is PASSWD. In *FD2P the descriptor + to the socket for the connection is returned. When the function + returns *AHOST contains the official host name. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int rexec (char **__restrict __ahost, int __rport, + __const char *__restrict __name, + __const char *__restrict __pass, + __const char *__restrict __cmd, int *__restrict __fd2p); + +/* This is the equivalent function where the protocol can be selected + and which therefore can be used for IPv6. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int rexec_af (char **__restrict __ahost, int __rport, + __const char *__restrict __name, + __const char *__restrict __pass, + __const char *__restrict __cmd, int *__restrict __fd2p, + sa_family_t __af); + +/* Check whether user REMUSER on system RHOST is allowed to login as LOCUSER. + If SUSER is not zero the user tries to become superuser. Return 0 if + it is possible. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int ruserok (__const char *__rhost, int __suser, + __const char *__remuser, __const char *__locuser); + +#if 0 +/* FIXME */ +/* This is the equivalent function where the protocol can be selected + and which therefore can be used for IPv6. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int ruserok_af (__const char *__rhost, int __suser, + __const char *__remuser, __const char *__locuser, + sa_family_t __af); +#endif + +/* Try to allocate reserved port, returning a descriptor for a socket opened + at this port or -1 if unsuccessful. The search for an available port + will start at ALPORT and continues with lower numbers. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int rresvport (int *__alport); + +#if 0 +/* FIXME */ +/* This is the equivalent function where the protocol can be selected + and which therefore can be used for IPv6. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int rresvport_af (int *__alport, sa_family_t __af); +#endif +#endif + + +/* Extension from POSIX.1g. */ +#ifdef __USE_POSIX +/* Structure to contain information about address of a service provider. */ +struct addrinfo +{ + int ai_flags; /* Input flags. */ + int ai_family; /* Protocol family for socket. */ + int ai_socktype; /* Socket type. */ + int ai_protocol; /* Protocol for socket. */ + socklen_t ai_addrlen; /* Length of socket address. */ + struct sockaddr *ai_addr; /* Socket address for socket. */ + char *ai_canonname; /* Canonical name for service location. */ + struct addrinfo *ai_next; /* Pointer to next in list. */ +}; + +/* Possible values for `ai_flags' field in `addrinfo' structure. */ +# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */ +# define AI_CANONNAME 0x0002 /* Request for canonical name. */ +# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */ +# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */ +# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */ +# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose + returned address type.. */ +# ifdef __USE_GNU +# define AI_IDN 0x0040 /* IDN encode input (assuming it is encoded + in the current locale's character set) + before looking it up. */ +# define AI_CANONIDN 0x0080 /* Translate canonical name from IDN format. */ +# define AI_IDN_ALLOW_UNASSIGNED 0x0100 /* Don't reject unassigned Unicode + code points. */ +# define AI_IDN_USE_STD3_ASCII_RULES 0x0200 /* Validate strings according to + STD3 rules. */ +# endif +# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */ + +/* Error values for `getaddrinfo' function. */ +# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */ +# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */ +# define EAI_AGAIN -3 /* Temporary failure in name resolution. */ +# define EAI_FAIL -4 /* Non-recoverable failure in name res. */ +# define EAI_NODATA -5 /* No address associated with NAME. */ +# define EAI_FAMILY -6 /* `ai_family' not supported. */ +# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */ +# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */ +# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */ +# define EAI_MEMORY -10 /* Memory allocation failure. */ +# define EAI_SYSTEM -11 /* System error returned in `errno'. */ +# define EAI_OVERFLOW -12 /* Argument buffer overflow. */ +# ifdef __USE_GNU +# define EAI_INPROGRESS -100 /* Processing request in progress. */ +# define EAI_CANCELED -101 /* Request canceled. */ +# define EAI_NOTCANCELED -102 /* Request not canceled. */ +# define EAI_ALLDONE -103 /* All requests done. */ +# define EAI_INTR -104 /* Interrupted by a signal. */ +# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */ +# endif + +# define NI_MAXHOST 1025 +# define NI_MAXSERV 32 + +# define NI_NUMERICHOST 1 /* Don't try to look up hostname. */ +# define NI_NUMERICSERV 2 /* Don't convert port number to name. */ +# define NI_NOFQDN 4 /* Only return nodename portion. */ +# define NI_NAMEREQD 8 /* Don't return numeric addresses. */ +# define NI_DGRAM 16 /* Look up UDP service rather than TCP. */ +# ifdef __USE_GNU +# define NI_IDN 32 /* Convert name from IDN format. */ +# define NI_IDN_ALLOW_UNASSIGNED 64 /* Don't reject unassigned Unicode + code points. */ +# define NI_IDN_USE_STD3_ASCII_RULES 128 /* Validate strings according to + STD3 rules. */ +# endif + +/* Translate name of a service location and/or a service name to set of + socket addresses. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int getaddrinfo (__const char *__restrict __name, + __const char *__restrict __service, + __const struct addrinfo *__restrict __req, + struct addrinfo **__restrict __pai); + +/* Free `addrinfo' structure AI including associated storage. */ +extern void freeaddrinfo (struct addrinfo *__ai) __THROW; + +/* Convert error return from getaddrinfo() to a string. */ +extern __const char *gai_strerror (int __ecode) __THROW; + +/* Translate a socket address to a location and service name. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int getnameinfo (__const struct sockaddr *__restrict __sa, + socklen_t __salen, char *__restrict __host, + socklen_t __hostlen, char *__restrict __serv, + socklen_t __servlen, unsigned int __flags); +#endif /* POSIX */ + +__END_DECLS + +#endif /* netdb.h */ diff --git a/conts/posix/libposix/include/posix/neteconet/ec.h b/conts/posix/libposix/include/posix/neteconet/ec.h new file mode 100644 index 0000000..f21601c --- /dev/null +++ b/conts/posix/libposix/include/posix/neteconet/ec.h @@ -0,0 +1,52 @@ +/* Definitions for use with Linux AF_ECONET sockets. + Copyright (C) 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NETECONET_EC_H +#define _NETECONET_EC_H 1 + +#include +#include + +struct ec_addr + { + unsigned char station; /* Station number. */ + unsigned char net; /* Network number. */ + }; + +struct sockaddr_ec + { + __SOCKADDR_COMMON (sec_); + unsigned char port; /* Port number. */ + unsigned char cb; /* Control/flag byte. */ + unsigned char type; /* Type of message. */ + struct ec_addr addr; + unsigned long cookie; + }; + +#define ECTYPE_PACKET_RECEIVED 0 /* Packet received */ +#define ECTYPE_TRANSMIT_STATUS 0x10 /* Transmit completed */ + +#define ECTYPE_TRANSMIT_OK 1 +#define ECTYPE_TRANSMIT_NOT_LISTENING 2 +#define ECTYPE_TRANSMIT_NET_ERROR 3 +#define ECTYPE_TRANSMIT_NO_CLOCK 4 +#define ECTYPE_TRANSMIT_LINE_JAMMED 5 +#define ECTYPE_TRANSMIT_NOT_PRESENT 6 + +#endif diff --git a/conts/posix/libposix/include/posix/netinet/ether.h b/conts/posix/libposix/include/posix/netinet/ether.h new file mode 100644 index 0000000..ca780e2 --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/ether.h @@ -0,0 +1,54 @@ +/* Functions for storing Ethernet addresses in ASCII and mapping to hostnames. + Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NETINET_ETHER_H +#define _NETINET_ETHER_H 1 + +#include + +/* Get definition of `struct ether_addr'. */ +#include + +__BEGIN_DECLS + +/* Convert 48 bit Ethernet ADDRess to ASCII. */ +extern char *ether_ntoa (__const struct ether_addr *__addr) __THROW; +extern char *ether_ntoa_r (__const struct ether_addr *__addr, char *__buf) + __THROW; + +/* Convert ASCII string S to 48 bit Ethernet address. */ +extern struct ether_addr *ether_aton (__const char *__asc) __THROW; +extern struct ether_addr *ether_aton_r (__const char *__asc, + struct ether_addr *__addr) __THROW; + +/* Map 48 bit Ethernet number ADDR to HOSTNAME. */ +extern int ether_ntohost (char *__hostname, __const struct ether_addr *__addr) + __THROW; + +/* Map HOSTNAME to 48 bit Ethernet address. */ +extern int ether_hostton (__const char *__hostname, struct ether_addr *__addr) + __THROW; + +/* Scan LINE and set ADDR and HOSTNAME. */ +extern int ether_line (__const char *__line, struct ether_addr *__addr, + char *__hostname) __THROW; + +__END_DECLS + +#endif /* netinet/ether.h */ diff --git a/conts/posix/libposix/include/posix/netinet/icmp6.h b/conts/posix/libposix/include/posix/netinet/icmp6.h new file mode 100644 index 0000000..c5138a3 --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/icmp6.h @@ -0,0 +1,346 @@ +/* Copyright (C) 1991,92,93,94,95,96,97,2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NETINET_ICMP6_H +#define _NETINET_ICMP6_H 1 + +#include +#include +#include +#include + +#define ICMP6_FILTER 1 + +#define ICMP6_FILTER_BLOCK 1 +#define ICMP6_FILTER_PASS 2 +#define ICMP6_FILTER_BLOCKOTHERS 3 +#define ICMP6_FILTER_PASSONLY 4 + +struct icmp6_filter + { + uint32_t icmp6_filt[8]; + }; + +struct icmp6_hdr + { + uint8_t icmp6_type; /* type field */ + uint8_t icmp6_code; /* code field */ + uint16_t icmp6_cksum; /* checksum field */ + union + { + uint32_t icmp6_un_data32[1]; /* type-specific field */ + uint16_t icmp6_un_data16[2]; /* type-specific field */ + uint8_t icmp6_un_data8[4]; /* type-specific field */ + } icmp6_dataun; + }; + +#define icmp6_data32 icmp6_dataun.icmp6_un_data32 +#define icmp6_data16 icmp6_dataun.icmp6_un_data16 +#define icmp6_data8 icmp6_dataun.icmp6_un_data8 +#define icmp6_pptr icmp6_data32[0] /* parameter prob */ +#define icmp6_mtu icmp6_data32[0] /* packet too big */ +#define icmp6_id icmp6_data16[0] /* echo request/reply */ +#define icmp6_seq icmp6_data16[1] /* echo request/reply */ +#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ + +#define ICMP6_DST_UNREACH 1 +#define ICMP6_PACKET_TOO_BIG 2 +#define ICMP6_TIME_EXCEEDED 3 +#define ICMP6_PARAM_PROB 4 + +#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ + +#define ICMP6_ECHO_REQUEST 128 +#define ICMP6_ECHO_REPLY 129 +#define MLD_LISTENER_QUERY 130 +#define MLD_LISTENER_REPORT 131 +#define MLD_LISTENER_REDUCTION 132 + +#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ +#define ICMP6_DST_UNREACH_ADMIN 1 /* communication with destination */ + /* administratively prohibited */ +#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */ +#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ +#define ICMP6_DST_UNREACH_NOPORT 4 /* bad port */ + +#define ICMP6_TIME_EXCEED_TRANSIT 0 /* Hop Limit == 0 in transit */ +#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* Reassembly time out */ + +#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ +#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized Next Header */ +#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized IPv6 option */ + +#define ICMP6_FILTER_WILLPASS(type, filterp) \ + ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0) + +#define ICMP6_FILTER_WILLBLOCK(type, filterp) \ + ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0) + +#define ICMP6_FILTER_SETPASS(type, filterp) \ + ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))) + +#define ICMP6_FILTER_SETBLOCK(type, filterp) \ + ((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))) + +#define ICMP6_FILTER_SETPASSALL(filterp) \ + memset (filterp, 0, sizeof (struct icmp6_filter)); + +#define ICMP6_FILTER_SETBLOCKALL(filterp) \ + memset (filterp, 0xFF, sizeof (struct icmp6_filter)); + +#define ND_ROUTER_SOLICIT 133 +#define ND_ROUTER_ADVERT 134 +#define ND_NEIGHBOR_SOLICIT 135 +#define ND_NEIGHBOR_ADVERT 136 +#define ND_REDIRECT 137 + +struct nd_router_solicit /* router solicitation */ + { + struct icmp6_hdr nd_rs_hdr; + /* could be followed by options */ + }; + +#define nd_rs_type nd_rs_hdr.icmp6_type +#define nd_rs_code nd_rs_hdr.icmp6_code +#define nd_rs_cksum nd_rs_hdr.icmp6_cksum +#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] + +struct nd_router_advert /* router advertisement */ + { + struct icmp6_hdr nd_ra_hdr; + uint32_t nd_ra_reachable; /* reachable time */ + uint32_t nd_ra_retransmit; /* retransmit timer */ + /* could be followed by options */ + }; + +#define nd_ra_type nd_ra_hdr.icmp6_type +#define nd_ra_code nd_ra_hdr.icmp6_code +#define nd_ra_cksum nd_ra_hdr.icmp6_cksum +#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] +#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] +#define ND_RA_FLAG_MANAGED 0x80 +#define ND_RA_FLAG_OTHER 0x40 +#define ND_RA_FLAG_HOME_AGENT 0x20 +#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] + +struct nd_neighbor_solicit /* neighbor solicitation */ + { + struct icmp6_hdr nd_ns_hdr; + struct in6_addr nd_ns_target; /* target address */ + /* could be followed by options */ + }; + +#define nd_ns_type nd_ns_hdr.icmp6_type +#define nd_ns_code nd_ns_hdr.icmp6_code +#define nd_ns_cksum nd_ns_hdr.icmp6_cksum +#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] + +struct nd_neighbor_advert /* neighbor advertisement */ + { + struct icmp6_hdr nd_na_hdr; + struct in6_addr nd_na_target; /* target address */ + /* could be followed by options */ + }; + +#define nd_na_type nd_na_hdr.icmp6_type +#define nd_na_code nd_na_hdr.icmp6_code +#define nd_na_cksum nd_na_hdr.icmp6_cksum +#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] +#if BYTE_ORDER == BIG_ENDIAN +#define ND_NA_FLAG_ROUTER 0x80000000 +#define ND_NA_FLAG_SOLICITED 0x40000000 +#define ND_NA_FLAG_OVERRIDE 0x20000000 +#else /* BYTE_ORDER == LITTLE_ENDIAN */ +#define ND_NA_FLAG_ROUTER 0x00000080 +#define ND_NA_FLAG_SOLICITED 0x00000040 +#define ND_NA_FLAG_OVERRIDE 0x00000020 +#endif + +struct nd_redirect /* redirect */ + { + struct icmp6_hdr nd_rd_hdr; + struct in6_addr nd_rd_target; /* target address */ + struct in6_addr nd_rd_dst; /* destination address */ + /* could be followed by options */ + }; + +#define nd_rd_type nd_rd_hdr.icmp6_type +#define nd_rd_code nd_rd_hdr.icmp6_code +#define nd_rd_cksum nd_rd_hdr.icmp6_cksum +#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] + +struct nd_opt_hdr /* Neighbor discovery option header */ + { + uint8_t nd_opt_type; + uint8_t nd_opt_len; /* in units of 8 octets */ + /* followed by option specific data */ + }; + +#define ND_OPT_SOURCE_LINKADDR 1 +#define ND_OPT_TARGET_LINKADDR 2 +#define ND_OPT_PREFIX_INFORMATION 3 +#define ND_OPT_REDIRECTED_HEADER 4 +#define ND_OPT_MTU 5 +#define ND_OPT_RTR_ADV_INTERVAL 7 +#define ND_OPT_HOME_AGENT_INFO 8 + +struct nd_opt_prefix_info /* prefix information */ + { + uint8_t nd_opt_pi_type; + uint8_t nd_opt_pi_len; + uint8_t nd_opt_pi_prefix_len; + uint8_t nd_opt_pi_flags_reserved; + uint32_t nd_opt_pi_valid_time; + uint32_t nd_opt_pi_preferred_time; + uint32_t nd_opt_pi_reserved2; + struct in6_addr nd_opt_pi_prefix; + }; + +#define ND_OPT_PI_FLAG_ONLINK 0x80 +#define ND_OPT_PI_FLAG_AUTO 0x40 +#define ND_OPT_PI_FLAG_RADDR 0x20 + +struct nd_opt_rd_hdr /* redirected header */ + { + uint8_t nd_opt_rh_type; + uint8_t nd_opt_rh_len; + uint16_t nd_opt_rh_reserved1; + uint32_t nd_opt_rh_reserved2; + /* followed by IP header and data */ + }; + +struct nd_opt_mtu /* MTU option */ + { + uint8_t nd_opt_mtu_type; + uint8_t nd_opt_mtu_len; + uint16_t nd_opt_mtu_reserved; + uint32_t nd_opt_mtu_mtu; + }; + +struct mld_hdr + { + struct icmp6_hdr mld_icmp6_hdr; + struct in6_addr mld_addr; /* multicast address */ + }; + +#define mld_type mld_icmp6_hdr.icmp6_type +#define mld_code mld_icmp6_hdr.icmp6_code +#define mld_cksum mld_icmp6_hdr.icmp6_cksum +#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0] +#define mld_reserved mld_icmp6_hdr.icmp6_data16[1] + +#define ICMP6_ROUTER_RENUMBERING 138 + +struct icmp6_router_renum /* router renumbering header */ + { + struct icmp6_hdr rr_hdr; + uint8_t rr_segnum; + uint8_t rr_flags; + uint16_t rr_maxdelay; + uint32_t rr_reserved; + }; + +#define rr_type rr_hdr.icmp6_type +#define rr_code rr_hdr.icmp6_code +#define rr_cksum rr_hdr.icmp6_cksum +#define rr_seqnum rr_hdr.icmp6_data32[0] + +/* Router renumbering flags */ +#define ICMP6_RR_FLAGS_TEST 0x80 +#define ICMP6_RR_FLAGS_REQRESULT 0x40 +#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20 +#define ICMP6_RR_FLAGS_SPECSITE 0x10 +#define ICMP6_RR_FLAGS_PREVDONE 0x08 + +struct rr_pco_match /* match prefix part */ + { + uint8_t rpm_code; + uint8_t rpm_len; + uint8_t rpm_ordinal; + uint8_t rpm_matchlen; + uint8_t rpm_minlen; + uint8_t rpm_maxlen; + uint16_t rpm_reserved; + struct in6_addr rpm_prefix; + }; + +/* PCO code values */ +#define RPM_PCO_ADD 1 +#define RPM_PCO_CHANGE 2 +#define RPM_PCO_SETGLOBAL 3 + +struct rr_pco_use /* use prefix part */ + { + uint8_t rpu_uselen; + uint8_t rpu_keeplen; + uint8_t rpu_ramask; + uint8_t rpu_raflags; + uint32_t rpu_vltime; + uint32_t rpu_pltime; + uint32_t rpu_flags; + struct in6_addr rpu_prefix; + }; + +#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20 +#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10 + +#if BYTE_ORDER == BIG_ENDIAN +# define ICMP6_RR_PCOUSE_DECRVLTIME 0x80000000 +# define ICMP6_RR_PCOUSE_DECRPLTIME 0x40000000 +#elif BYTE_ORDER == LITTLE_ENDIAN +# define ICMP6_RR_PCOUSE_DECRVLTIME 0x80 +# define ICMP6_RR_PCOUSE_DECRPLTIME 0x40 +#endif + +struct rr_result /* router renumbering result message */ + { + uint16_t rrr_flags; + uint8_t rrr_ordinal; + uint8_t rrr_matchedlen; + uint32_t rrr_ifid; + struct in6_addr rrr_prefix; + }; + +#if BYTE_ORDER == BIG_ENDIAN +# define ICMP6_RR_RESULT_FLAGS_OOB 0x0002 +# define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001 +#elif BYTE_ORDER == LITTLE_ENDIAN +# define ICMP6_RR_RESULT_FLAGS_OOB 0x0200 +# define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100 +#endif + +/* Mobile IPv6 extension: Advertisement Interval. */ +struct nd_opt_adv_interval + { + uint8_t nd_opt_adv_interval_type; + uint8_t nd_opt_adv_interval_len; + uint16_t nd_opt_adv_interval_reserved; + uint32_t nd_opt_adv_interval_ival; + }; + +/* Mobile IPv6 extension: Home Agent Info. */ +struct nd_opt_home_agent_info + { + uint8_t nd_opt_home_agent_info_type; + uint8_t nd_opt_home_agent_info_len; + uint16_t nd_opt_home_agent_info_reserved; + int16_t nd_opt_home_agent_info_preference; + uint16_t nd_opt_home_agent_info_lifetime; + }; + +#endif /* netinet/icmpv6.h */ diff --git a/conts/posix/libposix/include/posix/netinet/if_ether.h b/conts/posix/libposix/include/posix/netinet/if_ether.h new file mode 100644 index 0000000..aadb59b --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/if_ether.h @@ -0,0 +1,105 @@ +/* Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef __NETINET_IF_ETHER_H + +#define __NETINET_IF_ETHER_H 1 +#include +#include + +/* Get definitions from kernel header file. */ +#include + +#ifdef __USE_BSD +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)if_ether.h 8.3 (Berkeley) 5/2/95 + * $FreeBSD$ + */ + +#include +#include + +__BEGIN_DECLS +/* + * Ethernet Address Resolution Protocol. + * + * See RFC 826 for protocol description. Structure below is adapted + * to resolving internet addresses. Field names used correspond to + * RFC 826. + */ +struct ether_arp { + struct arphdr ea_hdr; /* fixed-size header */ + u_int8_t arp_sha[ETH_ALEN]; /* sender hardware address */ + u_int8_t arp_spa[4]; /* sender protocol address */ + u_int8_t arp_tha[ETH_ALEN]; /* target hardware address */ + u_int8_t arp_tpa[4]; /* target protocol address */ +}; +#define arp_hrd ea_hdr.ar_hrd +#define arp_pro ea_hdr.ar_pro +#define arp_hln ea_hdr.ar_hln +#define arp_pln ea_hdr.ar_pln +#define arp_op ea_hdr.ar_op + +/* + * Macro to map an IP multicast address to an Ethernet multicast address. + * The high-order 25 bits of the Ethernet address are statically assigned, + * and the low-order 23 bits are taken from the low end of the IP address. + */ +#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \ + /* struct in_addr *ipaddr; */ \ + /* u_char enaddr[ETH_ALEN]; */ \ +{ \ + (enaddr)[0] = 0x01; \ + (enaddr)[1] = 0x00; \ + (enaddr)[2] = 0x5e; \ + (enaddr)[3] = ((u_int8_t *)ipaddr)[1] & 0x7f; \ + (enaddr)[4] = ((u_int8_t *)ipaddr)[2]; \ + (enaddr)[5] = ((u_int8_t *)ipaddr)[3]; \ +} + +__END_DECLS +#endif /* __USE_BSD */ + +#endif /* netinet/if_ether.h */ diff --git a/conts/posix/libposix/include/posix/netinet/if_fddi.h b/conts/posix/libposix/include/posix/netinet/if_fddi.h new file mode 100644 index 0000000..1a0ec92 --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/if_fddi.h @@ -0,0 +1,37 @@ +/* Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NETINET_IF_FDDI_H +#define _NETINET_IF_FDDI_H 1 + +#include +#include +#include + +#include + +#ifdef __USE_BSD + +struct fddi_header { + u_int8_t fddi_fc; /* Frame Control (FC) value */ + u_int8_t fddi_dhost[FDDI_K_ALEN]; /* Destination host */ + u_int8_t fddi_shost[FDDI_K_ALEN]; /* Source host */ +}; +#endif + +#endif /* netinet/if_fddi.h */ diff --git a/conts/posix/libposix/include/posix/netinet/if_tr.h b/conts/posix/libposix/include/posix/netinet/if_tr.h new file mode 100644 index 0000000..1a7bc68 --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/if_tr.h @@ -0,0 +1,41 @@ +/* Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NETINET_IF_TR_H +#define _NETINET_IF_TR_H 1 + +#include +#include +#include + +#include + +#ifdef __USE_BSD + +struct trn_hdr { + u_int8_t trn_ac; /* access control field */ + u_int8_t trn_fc; /* field control field */ + u_int8_t trn_dhost[TR_ALEN]; /* destination host */ + u_int8_t trn_shost[TR_ALEN]; /* source host */ + u_int16_t trn_rcf; /* route control field */ + u_int16_t trn_rseg[8]; /* routing registers */ +}; + +#endif + +#endif /* netinet/if_tr.h */ diff --git a/conts/posix/libposix/include/posix/netinet/igmp.h b/conts/posix/libposix/include/posix/netinet/igmp.h new file mode 100644 index 0000000..67396ba --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/igmp.h @@ -0,0 +1,126 @@ +/* Copyright (C) 1997, 1999, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NETINET_IGMP_H +#define _NETINET_IGMP_H 1 + +#include +#include + +#ifdef __USE_BSD + +#include + +__BEGIN_DECLS + +/* + * Copyright (c) 1988 Stephen Deering. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Stephen Deering of Stanford University. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)igmp.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD$ + */ + +struct igmp { + u_int8_t igmp_type; /* IGMP type */ + u_int8_t igmp_code; /* routing code */ + u_int16_t igmp_cksum; /* checksum */ + struct in_addr igmp_group; /* group address */ +}; + +#define IGMP_MINLEN 8 + +/* + * Message types, including version number. + */ +#define IGMP_MEMBERSHIP_QUERY 0x11 /* membership query */ +#define IGMP_V1_MEMBERSHIP_REPORT 0x12 /* Ver. 1 membership report */ +#define IGMP_V2_MEMBERSHIP_REPORT 0x16 /* Ver. 2 membership report */ +#define IGMP_V2_LEAVE_GROUP 0x17 /* Leave-group message */ + +#define IGMP_DVMRP 0x13 /* DVMRP routing message */ +#define IGMP_PIM 0x14 /* PIM routing message */ +#define IGMP_TRACE 0x15 + +#define IGMP_MTRACE_RESP 0x1e /* traceroute resp.(to sender)*/ +#define IGMP_MTRACE 0x1f /* mcast traceroute messages */ + +#define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */ + /* query (in seconds) according */ + /* to RFC1112 */ +#define IGMP_TIMER_SCALE 10 /* denotes that the igmp code field */ + /* specifies time in 10th of seconds*/ + +/* + * States for the IGMP v2 state table. + */ +#define IGMP_DELAYING_MEMBER 1 +#define IGMP_IDLE_MEMBER 2 +#define IGMP_LAZY_MEMBER 3 +#define IGMP_SLEEPING_MEMBER 4 +#define IGMP_AWAKENING_MEMBER 5 + +/* + * States for IGMP router version cache. + */ +#define IGMP_v1_ROUTER 1 +#define IGMP_v2_ROUTER 2 + +/* + * The following four defininitions are for backwards compatibility. + * They should be removed as soon as all applications are updated to + * use the new constant names. + */ +#define IGMP_HOST_MEMBERSHIP_QUERY IGMP_MEMBERSHIP_QUERY +#define IGMP_HOST_MEMBERSHIP_REPORT IGMP_V1_MEMBERSHIP_REPORT +#define IGMP_HOST_NEW_MEMBERSHIP_REPORT IGMP_V2_MEMBERSHIP_REPORT +#define IGMP_HOST_LEAVE_MESSAGE IGMP_V2_LEAVE_GROUP + +__END_DECLS + +#endif + +#endif /* netinet/igmp.h */ diff --git a/conts/posix/libposix/include/posix/netinet/in.h b/conts/posix/libposix/include/posix/netinet/in.h new file mode 100644 index 0000000..935886e --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/in.h @@ -0,0 +1,512 @@ +/* Copyright (C) 1991-2001, 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NETINET_IN_H +#define _NETINET_IN_H 1 + +#include +#include +#include +#include + + +__BEGIN_DECLS + +/* Standard well-defined IP protocols. */ +enum + { + IPPROTO_IP = 0, /* Dummy protocol for TCP. */ +#define IPPROTO_IP IPPROTO_IP + IPPROTO_HOPOPTS = 0, /* IPv6 Hop-by-Hop options. */ +#define IPPROTO_HOPOPTS IPPROTO_HOPOPTS + IPPROTO_ICMP = 1, /* Internet Control Message Protocol. */ +#define IPPROTO_ICMP IPPROTO_ICMP + IPPROTO_IGMP = 2, /* Internet Group Management Protocol. */ +#define IPPROTO_IGMP IPPROTO_IGMP + IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94). */ +#define IPPROTO_IPIP IPPROTO_IPIP + IPPROTO_TCP = 6, /* Transmission Control Protocol. */ +#define IPPROTO_TCP IPPROTO_TCP + IPPROTO_EGP = 8, /* Exterior Gateway Protocol. */ +#define IPPROTO_EGP IPPROTO_EGP + IPPROTO_PUP = 12, /* PUP protocol. */ +#define IPPROTO_PUP IPPROTO_PUP + IPPROTO_UDP = 17, /* User Datagram Protocol. */ +#define IPPROTO_UDP IPPROTO_UDP + IPPROTO_IDP = 22, /* XNS IDP protocol. */ +#define IPPROTO_IDP IPPROTO_IDP + IPPROTO_TP = 29, /* SO Transport Protocol Class 4. */ +#define IPPROTO_TP IPPROTO_TP + IPPROTO_IPV6 = 41, /* IPv6 header. */ +#define IPPROTO_IPV6 IPPROTO_IPV6 + IPPROTO_ROUTING = 43, /* IPv6 routing header. */ +#define IPPROTO_ROUTING IPPROTO_ROUTING + IPPROTO_FRAGMENT = 44, /* IPv6 fragmentation header. */ +#define IPPROTO_FRAGMENT IPPROTO_FRAGMENT + IPPROTO_RSVP = 46, /* Reservation Protocol. */ +#define IPPROTO_RSVP IPPROTO_RSVP + IPPROTO_GRE = 47, /* General Routing Encapsulation. */ +#define IPPROTO_GRE IPPROTO_GRE + IPPROTO_ESP = 50, /* encapsulating security payload. */ +#define IPPROTO_ESP IPPROTO_ESP + IPPROTO_AH = 51, /* authentication header. */ +#define IPPROTO_AH IPPROTO_AH + IPPROTO_ICMPV6 = 58, /* ICMPv6. */ +#define IPPROTO_ICMPV6 IPPROTO_ICMPV6 + IPPROTO_NONE = 59, /* IPv6 no next header. */ +#define IPPROTO_NONE IPPROTO_NONE + IPPROTO_DSTOPTS = 60, /* IPv6 destination options. */ +#define IPPROTO_DSTOPTS IPPROTO_DSTOPTS + IPPROTO_MTP = 92, /* Multicast Transport Protocol. */ +#define IPPROTO_MTP IPPROTO_MTP + IPPROTO_ENCAP = 98, /* Encapsulation Header. */ +#define IPPROTO_ENCAP IPPROTO_ENCAP + IPPROTO_PIM = 103, /* Protocol Independent Multicast. */ +#define IPPROTO_PIM IPPROTO_PIM + IPPROTO_COMP = 108, /* Compression Header Protocol. */ +#define IPPROTO_COMP IPPROTO_COMP + IPPROTO_SCTP = 132, /* Stream Control Transmission Protocol. */ +#define IPPROTO_SCTP IPPROTO_SCTP + IPPROTO_RAW = 255, /* Raw IP packets. */ +#define IPPROTO_RAW IPPROTO_RAW + IPPROTO_MAX + }; + + +/* Type to represent a port. */ +typedef uint16_t in_port_t; + +/* Standard well-known ports. */ +enum + { + IPPORT_ECHO = 7, /* Echo service. */ + IPPORT_DISCARD = 9, /* Discard transmissions service. */ + IPPORT_SYSTAT = 11, /* System status service. */ + IPPORT_DAYTIME = 13, /* Time of day service. */ + IPPORT_NETSTAT = 15, /* Network status service. */ + IPPORT_FTP = 21, /* File Transfer Protocol. */ + IPPORT_TELNET = 23, /* Telnet protocol. */ + IPPORT_SMTP = 25, /* Simple Mail Transfer Protocol. */ + IPPORT_TIMESERVER = 37, /* Timeserver service. */ + IPPORT_NAMESERVER = 42, /* Domain Name Service. */ + IPPORT_WHOIS = 43, /* Internet Whois service. */ + IPPORT_MTP = 57, + + IPPORT_TFTP = 69, /* Trivial File Transfer Protocol. */ + IPPORT_RJE = 77, + IPPORT_FINGER = 79, /* Finger service. */ + IPPORT_TTYLINK = 87, + IPPORT_SUPDUP = 95, /* SUPDUP protocol. */ + + + IPPORT_EXECSERVER = 512, /* execd service. */ + IPPORT_LOGINSERVER = 513, /* rlogind service. */ + IPPORT_CMDSERVER = 514, + IPPORT_EFSSERVER = 520, + + /* UDP ports. */ + IPPORT_BIFFUDP = 512, + IPPORT_WHOSERVER = 513, + IPPORT_ROUTESERVER = 520, + + /* Ports less than this value are reserved for privileged processes. */ + IPPORT_RESERVED = 1024, + + /* Ports greater this value are reserved for (non-privileged) servers. */ + IPPORT_USERRESERVED = 5000 + }; + + +/* Internet address. */ +typedef uint32_t in_addr_t; +struct in_addr + { + in_addr_t s_addr; + }; + + +/* Definitions of the bits in an Internet address integer. + + On subnets, host and network parts are found according to + the subnet mask, not these masks. */ + +#define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0) +#define IN_CLASSA_NET 0xff000000 +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET) +#define IN_CLASSA_MAX 128 + +#define IN_CLASSB(a) ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000) +#define IN_CLASSB_NET 0xffff0000 +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET) +#define IN_CLASSB_MAX 65536 + +#define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000) +#define IN_CLASSC_NET 0xffffff00 +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET) + +#define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000) +#define IN_MULTICAST(a) IN_CLASSD(a) + +#define IN_EXPERIMENTAL(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000) +#define IN_BADCLASS(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000) + +/* Address to accept any incoming messages. */ +#define INADDR_ANY ((in_addr_t) 0x00000000) +/* Address to send to all hosts. */ +#define INADDR_BROADCAST ((in_addr_t) 0xffffffff) +/* Address indicating an error return. */ +#define INADDR_NONE ((in_addr_t) 0xffffffff) + +/* Network number for local host loopback. */ +#define IN_LOOPBACKNET 127 +/* Address to loopback in software to local host. */ +#ifndef INADDR_LOOPBACK +# define INADDR_LOOPBACK ((in_addr_t) 0x7f000001) /* Inet 127.0.0.1. */ +#endif + +/* Defines for Multicast INADDR. */ +#define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000) /* 224.0.0.0 */ +#define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001) /* 224.0.0.1 */ +#define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002) /* 224.0.0.2 */ +#define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */ + + +/* IPv6 address */ +struct in6_addr + { + union + { + uint8_t u6_addr8[16]; + uint16_t u6_addr16[8]; + uint32_t u6_addr32[4]; + } in6_u; +#define s6_addr in6_u.u6_addr8 +#define s6_addr16 in6_u.u6_addr16 +#define s6_addr32 in6_u.u6_addr32 + }; + +extern const struct in6_addr in6addr_any; /* :: */ +extern const struct in6_addr in6addr_loopback; /* ::1 */ +#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } } +#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } } + +#define INET_ADDRSTRLEN 16 +#define INET6_ADDRSTRLEN 46 + +/* Get the definition of the macro to define the common sockaddr members. */ +#include + + +/* Structure describing an Internet socket address. */ +struct sockaddr_in + { + __SOCKADDR_COMMON (sin_); + in_port_t sin_port; /* Port number. */ + struct in_addr sin_addr; /* Internet address. */ + + /* Pad to size of `struct sockaddr'. */ + unsigned char sin_zero[sizeof (struct sockaddr) - + __SOCKADDR_COMMON_SIZE - + sizeof (in_port_t) - + sizeof (struct in_addr)]; + }; + +/* Ditto, for IPv6. */ +struct sockaddr_in6 + { + __SOCKADDR_COMMON (sin6_); + in_port_t sin6_port; /* Transport layer port # */ + uint32_t sin6_flowinfo; /* IPv6 flow information */ + struct in6_addr sin6_addr; /* IPv6 address */ + uint32_t sin6_scope_id; /* IPv6 scope-id */ + }; + + +/* IPv4 multicast request. */ +struct ip_mreq + { + /* IP multicast address of group. */ + struct in_addr imr_multiaddr; + + /* Local IP address of interface. */ + struct in_addr imr_interface; + }; + +struct ip_mreq_source + { + /* IP multicast address of group. */ + struct in_addr imr_multiaddr; + + /* IP address of source. */ + struct in_addr imr_interface; + + /* IP address of interface. */ + struct in_addr imr_sourceaddr; + }; + +/* Likewise, for IPv6. */ +struct ipv6_mreq + { + /* IPv6 multicast address of group */ + struct in6_addr ipv6mr_multiaddr; + + /* local interface */ + unsigned int ipv6mr_interface; + }; + + +/* Multicast group request. */ +struct group_req + { + /* Interface index. */ + uint32_t gr_interface; + + /* Group address. */ + struct sockaddr_storage gr_group; + }; + +struct group_source_req + { + /* Interface index. */ + uint32_t gsr_interface; + + /* Group address. */ + struct sockaddr_storage gsr_group; + + /* Source address. */ + struct sockaddr_storage gsr_source; + }; + + +/* Full-state filter operations. */ +struct ip_msfilter + { + /* IP multicast address of group. */ + struct in_addr imsf_multiaddr; + + /* Local IP address of interface. */ + struct in_addr imsf_interface; + + /* Filter mode. */ + uint32_t imsf_fmode; + + /* Number of source addresses. */ + uint32_t imsf_numsrc; + /* Source addresses. */ + struct in_addr imsf_slist[1]; + }; + +#define IP_MSFILTER_SIZE(numsrc) (sizeof (struct ip_msfilter) \ + - sizeof (struct in_addr) \ + + (numsrc) * sizeof (struct in_addr)) + +struct group_filter + { + /* Interface index. */ + uint32_t gf_interface; + + /* Group address. */ + struct sockaddr_storage gf_group; + + /* Filter mode. */ + uint32_t gf_fmode; + + /* Number of source addresses. */ + uint32_t gf_numsrc; + /* Source addresses. */ + struct sockaddr_storage gf_slist[1]; +}; + +#define GROUP_FILTER_SIZE(numsrc) (sizeof (struct group_filter) \ + - sizeof (struct sockaddr_storage) \ + + ((numsrc) \ + * sizeof (struct sockaddr_storage))) + + +/* Get system-specific definitions. */ +#include + +/* Functions to convert between host and network byte order. + + Please note that these functions normally take `unsigned long int' or + `unsigned short int' values as arguments and also return them. But + this was a short-sighted decision since on different systems the types + may have different representations but the values are always the same. */ + +extern uint32_t ntohl (uint32_t __netlong) __THROW __attribute__ ((__const__)); +extern uint16_t ntohs (uint16_t __netshort) + __THROW __attribute__ ((__const__)); +extern uint32_t htonl (uint32_t __hostlong) + __THROW __attribute__ ((__const__)); +extern uint16_t htons (uint16_t __hostshort) + __THROW __attribute__ ((__const__)); + +#include + +/* Get machine dependent optimized versions of byte swapping functions. */ +#include + +#ifdef __OPTIMIZE__ +/* We can optimize calls to the conversion functions. Either nothing has + to be done or we are using directly the byte-swapping functions which + often can be inlined. */ +# if __BYTE_ORDER == __BIG_ENDIAN +/* The host byte order is the same as network byte order, + so these functions are all just identity. */ +# define ntohl(x) (x) +# define ntohs(x) (x) +# define htonl(x) (x) +# define htons(x) (x) +# else +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define ntohl(x) __bswap_32 (x) +# define ntohs(x) __bswap_16 (x) +# define htonl(x) __bswap_32 (x) +# define htons(x) __bswap_16 (x) +# endif +# endif +#endif + +#define IN6_IS_ADDR_UNSPECIFIED(a) \ + (((__const uint32_t *) (a))[0] == 0 \ + && ((__const uint32_t *) (a))[1] == 0 \ + && ((__const uint32_t *) (a))[2] == 0 \ + && ((__const uint32_t *) (a))[3] == 0) + +#define IN6_IS_ADDR_LOOPBACK(a) \ + (((__const uint32_t *) (a))[0] == 0 \ + && ((__const uint32_t *) (a))[1] == 0 \ + && ((__const uint32_t *) (a))[2] == 0 \ + && ((__const uint32_t *) (a))[3] == htonl (1)) + +#define IN6_IS_ADDR_MULTICAST(a) (((__const uint8_t *) (a))[0] == 0xff) + +#define IN6_IS_ADDR_LINKLOCAL(a) \ + ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \ + == htonl (0xfe800000)) + +#define IN6_IS_ADDR_SITELOCAL(a) \ + ((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \ + == htonl (0xfec00000)) + +#define IN6_IS_ADDR_V4MAPPED(a) \ + ((((__const uint32_t *) (a))[0] == 0) \ + && (((__const uint32_t *) (a))[1] == 0) \ + && (((__const uint32_t *) (a))[2] == htonl (0xffff))) + +#define IN6_IS_ADDR_V4COMPAT(a) \ + ((((__const uint32_t *) (a))[0] == 0) \ + && (((__const uint32_t *) (a))[1] == 0) \ + && (((__const uint32_t *) (a))[2] == 0) \ + && (ntohl (((__const uint32_t *) (a))[3]) > 1)) + +#define IN6_ARE_ADDR_EQUAL(a,b) \ + ((((__const uint32_t *) (a))[0] == ((__const uint32_t *) (b))[0]) \ + && (((__const uint32_t *) (a))[1] == ((__const uint32_t *) (b))[1]) \ + && (((__const uint32_t *) (a))[2] == ((__const uint32_t *) (b))[2]) \ + && (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3])) + +/* Bind socket to a privileged IP port. */ +extern int bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __THROW; + +/* The IPv6 version of this function. */ +extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in) + __THROW; + + +#define IN6_IS_ADDR_MC_NODELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((__const uint8_t *) (a))[1] & 0xf) == 0x1)) + +#define IN6_IS_ADDR_MC_LINKLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((__const uint8_t *) (a))[1] & 0xf) == 0x2)) + +#define IN6_IS_ADDR_MC_SITELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((__const uint8_t *) (a))[1] & 0xf) == 0x5)) + +#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((__const uint8_t *) (a))[1] & 0xf) == 0x8)) + +#define IN6_IS_ADDR_MC_GLOBAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) \ + && ((((__const uint8_t *) (a))[1] & 0xf) == 0xe)) + +/* IPv6 packet information. */ +struct in6_pktinfo + { + struct in6_addr ipi6_addr; /* src/dst IPv6 address */ + unsigned int ipi6_ifindex; /* send/recv interface index */ + }; + + +#if 0 /*def __USE_GNU*/ +/* Hop-by-Hop and Destination Options Processing. */ +extern int inet6_option_space (int __nbytes) __THROW; +extern int inet6_option_init (void *__bp, struct cmsghdr **__cmsgp, + int __type) __THROW; +extern int inet6_option_append (struct cmsghdr *__cmsg, + __const uint8_t *__typep, int __multx, + int __plusy) __THROW; +extern uint8_t *inet6_option_alloc (struct cmsghdr *__cmsg, int __datalen, + int __multx, int __plusy) __THROW; +extern int inet6_option_next (__const struct cmsghdr *__cmsg, + uint8_t **__tptrp) __THROW; +extern int inet6_option_find (__const struct cmsghdr *__cmsg, + uint8_t **__tptrp, int __type) __THROW; + + +/* Multicast source filter support. */ + +/* Get IPv4 source filter. */ +extern int getipv4sourcefilter (int __s, struct in_addr __interface_addr, + struct in_addr __group, uint32_t *__fmode, + uint32_t *__numsrc, struct in_addr *__slist) + __THROW; + +/* Set IPv4 source filter. */ +extern int setipv4sourcefilter (int __s, struct in_addr __interface_addr, + struct in_addr __group, uint32_t __fmode, + uint32_t __numsrc, + __const struct in_addr *__slist) + __THROW; + + +/* Get source filter. */ +extern int getsourcefilter (int __s, uint32_t __interface_addr, + __const struct sockaddr *__group, + socklen_t __grouplen, uint32_t *__fmode, + uint32_t *__numsrc, + struct sockaddr_storage *__slist) __THROW; + +/* Set source filter. */ +extern int setsourcefilter (int __s, uint32_t __interface_addr, + __const struct sockaddr *__group, + socklen_t __grouplen, uint32_t __fmode, + uint32_t __numsrc, + __const struct sockaddr_storage *__slist) __THROW; +#endif /* use GNU */ + +__END_DECLS + +#endif /* netinet/in.h */ diff --git a/conts/posix/libposix/include/posix/netinet/in_systm.h b/conts/posix/libposix/include/posix/netinet/in_systm.h new file mode 100644 index 0000000..51a08e1 --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/in_systm.h @@ -0,0 +1,41 @@ +/* System specific type definitions for networking code. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NETINET_IN_SYSTM_H +#define _NETINET_IN_SYSTM_H 1 + +#include +#include + +__BEGIN_DECLS + +/* + * Network order versions of various data types. Unfortunately, BSD + * assumes specific sizes for shorts (16 bit) and longs (32 bit) which + * don't hold in general. As a consequence, the network order versions + * may not reflect the actual size of the native data types. + */ + +typedef u_int16_t n_short; /* short as received from the net */ +typedef u_int32_t n_long; /* long as received from the net */ +typedef u_int32_t n_time; /* ms since 00:00 GMT, byte rev */ + +__END_DECLS + +#endif /* netinet/in_systm.h */ diff --git a/conts/posix/libposix/include/posix/netinet/ip.h b/conts/posix/libposix/include/posix/netinet/ip.h new file mode 100644 index 0000000..fc91440 --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/ip.h @@ -0,0 +1,249 @@ +/* Copyright (C) 1991,92,93,95,96,97,98,99,2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef __NETINET_IP_H +#define __NETINET_IP_H 1 + +#include +#include + +#include + +__BEGIN_DECLS + +struct timestamp + { + u_int8_t len; + u_int8_t ptr; +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int flags:4; + unsigned int overflow:4; +#elif __BYTE_ORDER == __BIG_ENDIAN + unsigned int overflow:4; + unsigned int flags:4; +#else +# error "Please fix " +#endif + u_int32_t data[9]; + }; + +struct iphdr + { +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int ihl:4; + unsigned int version:4; +#elif __BYTE_ORDER == __BIG_ENDIAN + unsigned int version:4; + unsigned int ihl:4; +#else +# error "Please fix " +#endif + u_int8_t tos; + u_int16_t tot_len; + u_int16_t id; + u_int16_t frag_off; + u_int8_t ttl; + u_int8_t protocol; + u_int16_t check; + u_int32_t saddr; + u_int32_t daddr; + /*The options start here. */ + }; + +#ifdef __USE_BSD +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ip.h 8.1 (Berkeley) 6/10/93 + */ + +/* + * Definitions for internet protocol version 4. + * Per RFC 791, September 1981. + */ + +/* + * Structure of an internet header, naked of options. + */ +struct ip + { +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int ip_hl:4; /* header length */ + unsigned int ip_v:4; /* version */ +#endif +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int ip_v:4; /* version */ + unsigned int ip_hl:4; /* header length */ +#endif + u_int8_t ip_tos; /* type of service */ + u_short ip_len; /* total length */ + u_short ip_id; /* identification */ + u_short ip_off; /* fragment offset field */ +#define IP_RF 0x8000 /* reserved fragment flag */ +#define IP_DF 0x4000 /* dont fragment flag */ +#define IP_MF 0x2000 /* more fragments flag */ +#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ + u_int8_t ip_ttl; /* time to live */ + u_int8_t ip_p; /* protocol */ + u_short ip_sum; /* checksum */ + struct in_addr ip_src, ip_dst; /* source and dest address */ + }; + +/* + * Time stamp option structure. + */ +struct ip_timestamp + { + u_int8_t ipt_code; /* IPOPT_TS */ + u_int8_t ipt_len; /* size of structure (variable) */ + u_int8_t ipt_ptr; /* index of current entry */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int ipt_flg:4; /* flags, see below */ + unsigned int ipt_oflw:4; /* overflow counter */ +#endif +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int ipt_oflw:4; /* overflow counter */ + unsigned int ipt_flg:4; /* flags, see below */ +#endif + u_int32_t data[9]; + }; +#endif /* __USE_BSD */ + +#define IPVERSION 4 /* IP version number */ +#define IP_MAXPACKET 65535 /* maximum packet size */ + +/* + * Definitions for IP type of service (ip_tos) + */ +#define IPTOS_TOS_MASK 0x1E +#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK) +#define IPTOS_LOWDELAY 0x10 +#define IPTOS_THROUGHPUT 0x08 +#define IPTOS_RELIABILITY 0x04 +#define IPTOS_LOWCOST 0x02 +#define IPTOS_MINCOST IPTOS_LOWCOST + +/* + * Definitions for IP precedence (also in ip_tos) (hopefully unused) + */ +#define IPTOS_PREC_MASK 0xe0 +#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK) +#define IPTOS_PREC_NETCONTROL 0xe0 +#define IPTOS_PREC_INTERNETCONTROL 0xc0 +#define IPTOS_PREC_CRITIC_ECP 0xa0 +#define IPTOS_PREC_FLASHOVERRIDE 0x80 +#define IPTOS_PREC_FLASH 0x60 +#define IPTOS_PREC_IMMEDIATE 0x40 +#define IPTOS_PREC_PRIORITY 0x20 +#define IPTOS_PREC_ROUTINE 0x00 + +/* + * Definitions for options. + */ +#define IPOPT_COPY 0x80 +#define IPOPT_CLASS_MASK 0x60 +#define IPOPT_NUMBER_MASK 0x1f + +#define IPOPT_COPIED(o) ((o) & IPOPT_COPY) +#define IPOPT_CLASS(o) ((o) & IPOPT_CLASS_MASK) +#define IPOPT_NUMBER(o) ((o) & IPOPT_NUMBER_MASK) + +#define IPOPT_CONTROL 0x00 +#define IPOPT_RESERVED1 0x20 +#define IPOPT_DEBMEAS 0x40 +#define IPOPT_MEASUREMENT IPOPT_DEBMEAS +#define IPOPT_RESERVED2 0x60 + +#define IPOPT_EOL 0 /* end of option list */ +#define IPOPT_END IPOPT_EOL +#define IPOPT_NOP 1 /* no operation */ +#define IPOPT_NOOP IPOPT_NOP + +#define IPOPT_RR 7 /* record packet route */ +#define IPOPT_TS 68 /* timestamp */ +#define IPOPT_TIMESTAMP IPOPT_TS +#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ +#define IPOPT_SEC IPOPT_SECURITY +#define IPOPT_LSRR 131 /* loose source route */ +#define IPOPT_SATID 136 /* satnet id */ +#define IPOPT_SID IPOPT_SATID +#define IPOPT_SSRR 137 /* strict source route */ +#define IPOPT_RA 148 /* router alert */ + +/* + * Offsets to fields in options other than EOL and NOP. + */ +#define IPOPT_OPTVAL 0 /* option ID */ +#define IPOPT_OLEN 1 /* option length */ +#define IPOPT_OFFSET 2 /* offset within option */ +#define IPOPT_MINOFF 4 /* min value of above */ + +#define MAX_IPOPTLEN 40 + +/* flag bits for ipt_flg */ +#define IPOPT_TS_TSONLY 0 /* timestamps only */ +#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ +#define IPOPT_TS_PRESPEC 3 /* specified modules only */ + +/* bits for security (not byte swapped) */ +#define IPOPT_SECUR_UNCLASS 0x0000 +#define IPOPT_SECUR_CONFID 0xf135 +#define IPOPT_SECUR_EFTO 0x789a +#define IPOPT_SECUR_MMMM 0xbc4d +#define IPOPT_SECUR_RESTR 0xaf13 +#define IPOPT_SECUR_SECRET 0xd788 +#define IPOPT_SECUR_TOPSECRET 0x6bc5 + +/* + * Internet implementation parameters. + */ +#define MAXTTL 255 /* maximum time to live (seconds) */ +#define IPDEFTTL 64 /* default ttl, from RFC 1340 */ +#define IPFRAGTTL 60 /* time to live for frags, slowhz */ +#define IPTTLDEC 1 /* subtracted when forwarding */ + +#define IP_MSS 576 /* default maximum segment size */ + +__END_DECLS + +#endif /* netinet/ip.h */ diff --git a/conts/posix/libposix/include/posix/netinet/ip6.h b/conts/posix/libposix/include/posix/netinet/ip6.h new file mode 100644 index 0000000..0ad62f8 --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/ip6.h @@ -0,0 +1,188 @@ +/* Copyright (C) 1991-1997, 2001, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NETINET_IP6_H +#define _NETINET_IP6_H 1 + +#include +#include + +struct ip6_hdr + { + union + { + struct ip6_hdrctl + { + uint32_t ip6_un1_flow; /* 4 bits version, 8 bits TC, + 20 bits flow-ID */ + uint16_t ip6_un1_plen; /* payload length */ + uint8_t ip6_un1_nxt; /* next header */ + uint8_t ip6_un1_hlim; /* hop limit */ + } ip6_un1; + uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits tclass */ + } ip6_ctlun; + struct in6_addr ip6_src; /* source address */ + struct in6_addr ip6_dst; /* destination address */ + }; + +#define ip6_vfc ip6_ctlun.ip6_un2_vfc +#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow +#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen +#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt +#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim +#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim + +/* Generic extension header. */ +struct ip6_ext + { + uint8_t ip6e_nxt; /* next header. */ + uint8_t ip6e_len; /* length in units of 8 octets. */ + }; + +/* Hop-by-Hop options header. */ +struct ip6_hbh + { + uint8_t ip6h_nxt; /* next header. */ + uint8_t ip6h_len; /* length in units of 8 octets. */ + /* followed by options */ + }; + +/* Destination options header */ +struct ip6_dest + { + uint8_t ip6d_nxt; /* next header */ + uint8_t ip6d_len; /* length in units of 8 octets */ + /* followed by options */ + }; + +/* Routing header */ +struct ip6_rthdr + { + uint8_t ip6r_nxt; /* next header */ + uint8_t ip6r_len; /* length in units of 8 octets */ + uint8_t ip6r_type; /* routing type */ + uint8_t ip6r_segleft; /* segments left */ + /* followed by routing type specific data */ + }; + +/* Type 0 Routing header */ +struct ip6_rthdr0 + { + uint8_t ip6r0_nxt; /* next header */ + uint8_t ip6r0_len; /* length in units of 8 octets */ + uint8_t ip6r0_type; /* always zero */ + uint8_t ip6r0_segleft; /* segments left */ + uint8_t ip6r0_reserved; /* reserved field */ + uint8_t ip6r0_slmap[3]; /* strict/loose bit map */ + struct in6_addr ip6r0_addr[1]; /* up to 23 addresses */ + }; + +/* Fragment header */ +struct ip6_frag + { + uint8_t ip6f_nxt; /* next header */ + uint8_t ip6f_reserved; /* reserved field */ + uint16_t ip6f_offlg; /* offset, reserved, and flag */ + uint32_t ip6f_ident; /* identification */ + }; + +#if BYTE_ORDER == BIG_ENDIAN +#define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */ +#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */ +#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */ +#else /* BYTE_ORDER == LITTLE_ENDIAN */ +#define IP6F_OFF_MASK 0xf8ff /* mask out offset from _offlg */ +#define IP6F_RESERVED_MASK 0x0600 /* reserved bits in ip6f_offlg */ +#define IP6F_MORE_FRAG 0x0100 /* more-fragments flag */ +#endif + +/* IPv6 options */ +struct ip6_opt + { + uint8_t ip6o_type; + uint8_t ip6o_len; + }; + +/* The high-order 3 bits of the option type define the behavior + * when processing an unknown option and whether or not the option + * content changes in flight. + */ +#define IP6OPT_TYPE(o) ((o) & 0xc0) +#define IP6OPT_TYPE_SKIP 0x00 +#define IP6OPT_TYPE_DISCARD 0x40 +#define IP6OPT_TYPE_FORCEICMP 0x80 +#define IP6OPT_TYPE_ICMP 0xc0 +#define IP6OPT_TYPE_MUTABLE 0x20 + +/* Special option types for padding. */ +#define IP6OPT_PAD1 0 +#define IP6OPT_PADN 1 + +#define IP6OPT_JUMBO 0xc2 +#define IP6OPT_NSAP_ADDR 0xc3 +#define IP6OPT_TUNNEL_LIMIT 0x04 +#define IP6OPT_ROUTER_ALERT 0x05 + +/* Jumbo Payload Option */ +struct ip6_opt_jumbo + { + uint8_t ip6oj_type; + uint8_t ip6oj_len; + uint8_t ip6oj_jumbo_len[4]; + }; +#define IP6OPT_JUMBO_LEN 6 + +/* NSAP Address Option */ +struct ip6_opt_nsap + { + uint8_t ip6on_type; + uint8_t ip6on_len; + uint8_t ip6on_src_nsap_len; + uint8_t ip6on_dst_nsap_len; + /* followed by source NSAP */ + /* followed by destination NSAP */ + }; + +/* Tunnel Limit Option */ +struct ip6_opt_tunnel + { + uint8_t ip6ot_type; + uint8_t ip6ot_len; + uint8_t ip6ot_encap_limit; + }; + +/* Router Alert Option */ +struct ip6_opt_router + { + uint8_t ip6or_type; + uint8_t ip6or_len; + uint8_t ip6or_value[2]; + }; + +/* Router alert values (in network byte order) */ +#if BYTE_ORDER == BIG_ENDIAN +# define IP6_ALERT_MLD 0x0000 +# define IP6_ALERT_RSVP 0x0001 +# define IP6_ALERT_AN 0x0002 +#else /* BYTE_ORDER == LITTLE_ENDING */ +# define IP6_ALERT_MLD 0x0000 +# define IP6_ALERT_RSVP 0x0100 +# define IP6_ALERT_AN 0x0200 +#endif + +#endif /* netinet/ip6.h */ diff --git a/conts/posix/libposix/include/posix/netinet/ip_fw.h b/conts/posix/libposix/include/posix/netinet/ip_fw.h new file mode 100644 index 0000000..278a039 --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/ip_fw.h @@ -0,0 +1 @@ +#include diff --git a/conts/posix/libposix/include/posix/netinet/ip_icmp.h b/conts/posix/libposix/include/posix/netinet/ip_icmp.h new file mode 100644 index 0000000..2fc8e9c --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/ip_icmp.h @@ -0,0 +1,283 @@ +/* Copyright (C) 1991, 92, 93, 95, 96, 97, 99 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef __NETINET_IP_ICMP_H +#define __NETINET_IP_ICMP_H 1 + +#include +#include + +__BEGIN_DECLS + +struct icmphdr +{ + u_int8_t type; /* message type */ + u_int8_t code; /* type sub-code */ + u_int16_t checksum; + union + { + struct + { + u_int16_t id; + u_int16_t sequence; + } echo; /* echo datagram */ + u_int32_t gateway; /* gateway address */ + struct + { + u_int16_t __unused; + u_int16_t mtu; + } frag; /* path mtu discovery */ + } un; +}; + +#define ICMP_ECHOREPLY 0 /* Echo Reply */ +#define ICMP_DEST_UNREACH 3 /* Destination Unreachable */ +#define ICMP_SOURCE_QUENCH 4 /* Source Quench */ +#define ICMP_REDIRECT 5 /* Redirect (change route) */ +#define ICMP_ECHO 8 /* Echo Request */ +#define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */ +#define ICMP_PARAMETERPROB 12 /* Parameter Problem */ +#define ICMP_TIMESTAMP 13 /* Timestamp Request */ +#define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */ +#define ICMP_INFO_REQUEST 15 /* Information Request */ +#define ICMP_INFO_REPLY 16 /* Information Reply */ +#define ICMP_ADDRESS 17 /* Address Mask Request */ +#define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */ +#define NR_ICMP_TYPES 18 + + +/* Codes for UNREACH. */ +#define ICMP_NET_UNREACH 0 /* Network Unreachable */ +#define ICMP_HOST_UNREACH 1 /* Host Unreachable */ +#define ICMP_PROT_UNREACH 2 /* Protocol Unreachable */ +#define ICMP_PORT_UNREACH 3 /* Port Unreachable */ +#define ICMP_FRAG_NEEDED 4 /* Fragmentation Needed/DF set */ +#define ICMP_SR_FAILED 5 /* Source Route failed */ +#define ICMP_NET_UNKNOWN 6 +#define ICMP_HOST_UNKNOWN 7 +#define ICMP_HOST_ISOLATED 8 +#define ICMP_NET_ANO 9 +#define ICMP_HOST_ANO 10 +#define ICMP_NET_UNR_TOS 11 +#define ICMP_HOST_UNR_TOS 12 +#define ICMP_PKT_FILTERED 13 /* Packet filtered */ +#define ICMP_PREC_VIOLATION 14 /* Precedence violation */ +#define ICMP_PREC_CUTOFF 15 /* Precedence cut off */ +#define NR_ICMP_UNREACH 15 /* instead of hardcoding immediate value */ + +/* Codes for REDIRECT. */ +#define ICMP_REDIR_NET 0 /* Redirect Net */ +#define ICMP_REDIR_HOST 1 /* Redirect Host */ +#define ICMP_REDIR_NETTOS 2 /* Redirect Net for TOS */ +#define ICMP_REDIR_HOSTTOS 3 /* Redirect Host for TOS */ + +/* Codes for TIME_EXCEEDED. */ +#define ICMP_EXC_TTL 0 /* TTL count exceeded */ +#define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */ + + +#ifdef __USE_BSD +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 + */ + +#include +#include + +/* + * Internal of an ICMP Router Advertisement + */ +struct icmp_ra_addr +{ + u_int32_t ira_addr; + u_int32_t ira_preference; +}; + +struct icmp +{ + u_int8_t icmp_type; /* type of message, see below */ + u_int8_t icmp_code; /* type sub code */ + u_int16_t icmp_cksum; /* ones complement checksum of struct */ + union + { + u_char ih_pptr; /* ICMP_PARAMPROB */ + struct in_addr ih_gwaddr; /* gateway address */ + struct ih_idseq /* echo datagram */ + { + u_int16_t icd_id; + u_int16_t icd_seq; + } ih_idseq; + u_int32_t ih_void; + + /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ + struct ih_pmtu + { + u_int16_t ipm_void; + u_int16_t ipm_nextmtu; + } ih_pmtu; + + struct ih_rtradv + { + u_int8_t irt_num_addrs; + u_int8_t irt_wpa; + u_int16_t irt_lifetime; + } ih_rtradv; + } icmp_hun; +#define icmp_pptr icmp_hun.ih_pptr +#define icmp_gwaddr icmp_hun.ih_gwaddr +#define icmp_id icmp_hun.ih_idseq.icd_id +#define icmp_seq icmp_hun.ih_idseq.icd_seq +#define icmp_void icmp_hun.ih_void +#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void +#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu +#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs +#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa +#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime + union + { + struct + { + u_int32_t its_otime; + u_int32_t its_rtime; + u_int32_t its_ttime; + } id_ts; + struct + { + struct ip idi_ip; + /* options and then 64 bits of data */ + } id_ip; + struct icmp_ra_addr id_radv; + u_int32_t id_mask; + u_int8_t id_data[1]; + } icmp_dun; +#define icmp_otime icmp_dun.id_ts.its_otime +#define icmp_rtime icmp_dun.id_ts.its_rtime +#define icmp_ttime icmp_dun.id_ts.its_ttime +#define icmp_ip icmp_dun.id_ip.idi_ip +#define icmp_radv icmp_dun.id_radv +#define icmp_mask icmp_dun.id_mask +#define icmp_data icmp_dun.id_data +}; + +/* + * Lower bounds on packet lengths for various types. + * For the error advice packets must first insure that the + * packet is large enough to contain the returned ip header. + * Only then can we do the check to see if 64 bits of packet + * data have been returned, since we need to check the returned + * ip header length. + */ +#define ICMP_MINLEN 8 /* abs minimum */ +#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ +#define ICMP_MASKLEN 12 /* address mask */ +#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ +#ifndef _IP_VHL +#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) + /* N.B.: must separately check that ip_hl >= 5 */ +#else +#define ICMP_ADVLEN(p) (8 + (IP_VHL_HL((p)->icmp_ip.ip_vhl) << 2) + 8) + /* N.B.: must separately check that header length >= 5 */ +#endif + +/* Definition of type and code fields. */ +/* defined above: ICMP_ECHOREPLY, ICMP_REDIRECT, ICMP_ECHO */ +#define ICMP_UNREACH 3 /* dest unreachable, codes: */ +#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ +#define ICMP_ROUTERADVERT 9 /* router advertisement */ +#define ICMP_ROUTERSOLICIT 10 /* router solicitation */ +#define ICMP_TIMXCEED 11 /* time exceeded, code: */ +#define ICMP_PARAMPROB 12 /* ip header bad */ +#define ICMP_TSTAMP 13 /* timestamp request */ +#define ICMP_TSTAMPREPLY 14 /* timestamp reply */ +#define ICMP_IREQ 15 /* information request */ +#define ICMP_IREQREPLY 16 /* information reply */ +#define ICMP_MASKREQ 17 /* address mask request */ +#define ICMP_MASKREPLY 18 /* address mask reply */ + +#define ICMP_MAXTYPE 18 + +/* UNREACH codes */ +#define ICMP_UNREACH_NET 0 /* bad net */ +#define ICMP_UNREACH_HOST 1 /* bad host */ +#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ +#define ICMP_UNREACH_PORT 3 /* bad port */ +#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ +#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ +#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ +#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ +#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ +#define ICMP_UNREACH_NET_PROHIB 9 /* net denied */ +#define ICMP_UNREACH_HOST_PROHIB 10 /* host denied */ +#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ +#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ +#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */ +#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */ +#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */ + +/* REDIRECT codes */ +#define ICMP_REDIRECT_NET 0 /* for network */ +#define ICMP_REDIRECT_HOST 1 /* for host */ +#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ +#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ + +/* TIMEXCEED codes */ +#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ +#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ + +/* PARAMPROB code */ +#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */ + +#define ICMP_INFOTYPE(type) \ + ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \ + (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \ + (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \ + (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \ + (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) + +#endif /* __USE_BSD */ + +__END_DECLS + +#endif /* netinet/ip_icmp.h */ diff --git a/conts/posix/libposix/include/posix/netinet/ip_tcp.h b/conts/posix/libposix/include/posix/netinet/ip_tcp.h new file mode 100644 index 0000000..600aebc --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/ip_tcp.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#)tcp.h 7.5 (Berkeley) 6/29/88 + */ + +#ifndef _NETINET_IP_TCP_H +#define _NETINET_IP_TCP_H + +#include +#include +#include + +typedef u_int32_t tcp_seq; +/* + * TCP header. + * Per RFC 793, September, 1981. + */ +struct tcphdr { + u_short th_sport; /* source port */ + u_short th_dport; /* destination port */ + tcp_seq th_seq; /* sequence number */ + tcp_seq th_ack; /* acknowledgement number */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + u_char th_x2:4, /* (unused) */ + th_off:4; /* data offset */ +#endif +#if __BYTE_ORDER == __BIG_ENDIAN + u_char th_off:4, /* data offset */ + th_x2:4; /* (unused) */ +#endif + u_char th_flags; +#define TH_FIN 0x01 +#define TH_SYN 0x02 +#define TH_RST 0x04 +#define TH_PUSH 0x08 +#define TH_ACK 0x10 +#define TH_URG 0x20 + u_short th_win; /* window */ + u_short th_sum; /* checksum */ + u_short th_urp; /* urgent pointer */ +}; + +#define TCPOPT_EOL 0 +#define TCPOPT_NOP 1 +#define TCPOPT_MAXSEG 2 + +/* + * Default maximum segment size for TCP. + * With an IP MSS of 576, this is 536, + * but 512 is probably more convenient. + */ +#ifdef lint +#define TCP_MSS 536 +#else +#define TCP_MSS MIN(512, IP_MSS - sizeof (struct tcpiphdr)) +#endif + +#endif /* _NETINET_TCP_H */ diff --git a/conts/posix/libposix/include/posix/netinet/ip_udp.h b/conts/posix/libposix/include/posix/netinet/ip_udp.h new file mode 100644 index 0000000..3f0d8ef --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/ip_udp.h @@ -0,0 +1 @@ +#include diff --git a/conts/posix/libposix/include/posix/netinet/protocols.h b/conts/posix/libposix/include/posix/netinet/protocols.h new file mode 100644 index 0000000..1a619c4 --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/protocols.h @@ -0,0 +1,62 @@ +/* protocols.h */ +#ifndef _NETINET_PROTOCOLS_H +#define _NETINET_PROTOCOLS_H + +#define IP_ICMP 1 +#define IP_IGMP 2 +#define IP_GGP 3 +#define IP_ST 5 +#define IP_TCP 6 +#define IP_UCL 7 +#define IP_EGP 8 +#define IP_IGP 9 +#define IP_BBN_RCC_MON 10 +#define IP_NVP_II 11 +#define IP_PUP 12 +#define IP_ARGUS 13 +#define IP_EMCON 14 +#define IP_XNET 15 +#define IP_CHAOS 16 +#define IP_UDP 17 +#define IP_MUX 18 +#define IP_DCN_MEAS 19 +#define IP_HMP 20 +#define IP_PRM 21 +#define IP_XNS_IDP 22 +#define IP_TRUNK1 23 +#define IP_TRUNK2 24 +#define IP_LEAF1 25 +#define IP_LEAF2 26 +#define IP_RDP 27 +#define IP_IRTP 28 +#define IP_ISO_TP4 29 +#define IP_NETBLT 30 +#define IP_MFE_NSP 31 +#define IP_MERIT_INP 32 +#define IP_SEP 33 +#define IP_3PC 34 +#define IP_CFTP 62 +#define SAT_EXPAK 64 +#define IP_RVD 66 +#define IP_IPPC 67 +#define IP_SAT_MON 69 +#define IP_VISA 70 +#define IP_IPCV 71 +#define IP_BR_SAT_MON 76 +#define IP_SUN_ND 77 +#define IP_WB_MON 78 +#define IP_WB_EXPAK 79 +#define IP_ISO_IP 80 +#define IP_VMTP 81 +#define IP_SECURE_VMTP 82 +#define IP_VINES 83 +#define IP_TTP 84 +#define NSFNET_IGP 85 +#define IP_DGP 86 +#define IP_TCF 87 +#define IP_IGRP 88 +#define IP_OSPFIGP 89 +#define IP_SPRITE_RPG 90 +#define IP_LARP 91 + +#endif /* _NETINET_PROTOCOLS_H*/ diff --git a/conts/posix/libposix/include/posix/netinet/tcp.h b/conts/posix/libposix/include/posix/netinet/tcp.h new file mode 100644 index 0000000..87099ec --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/tcp.h @@ -0,0 +1,225 @@ +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)tcp.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NETINET_TCP_H +#define _NETINET_TCP_H 1 + +#include + +/* + * User-settable options (used with setsockopt). + */ +#define TCP_NODELAY 1 /* Don't delay send to coalesce packets */ +#define TCP_MAXSEG 2 /* Set maximum segment size */ +#define TCP_CORK 3 /* Control sending of partial frames */ +#define TCP_KEEPIDLE 4 /* Start keeplives after this period */ +#define TCP_KEEPINTVL 5 /* Interval between keepalives */ +#define TCP_KEEPCNT 6 /* Number of keepalives before death */ +#define TCP_SYNCNT 7 /* Number of SYN retransmits */ +#define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */ +#define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */ +#define TCP_WINDOW_CLAMP 10 /* Bound advertised window */ +#define TCP_INFO 11 /* Information about this connection. */ +#define TCP_QUICKACK 12 /* Bock/reenable quick ACKs. */ + +#ifdef __USE_MISC +# include + +# ifdef __FAVOR_BSD +typedef u_int32_t tcp_seq; +/* + * TCP header. + * Per RFC 793, September, 1981. + */ +struct tcphdr + { + u_int16_t th_sport; /* source port */ + u_int16_t th_dport; /* destination port */ + tcp_seq th_seq; /* sequence number */ + tcp_seq th_ack; /* acknowledgement number */ +# if __BYTE_ORDER == __LITTLE_ENDIAN + u_int8_t th_x2:4; /* (unused) */ + u_int8_t th_off:4; /* data offset */ +# endif +# if __BYTE_ORDER == __BIG_ENDIAN + u_int8_t th_off:4; /* data offset */ + u_int8_t th_x2:4; /* (unused) */ +# endif + u_int8_t th_flags; +# define TH_FIN 0x01 +# define TH_SYN 0x02 +# define TH_RST 0x04 +# define TH_PUSH 0x08 +# define TH_ACK 0x10 +# define TH_URG 0x20 + u_int16_t th_win; /* window */ + u_int16_t th_sum; /* checksum */ + u_int16_t th_urp; /* urgent pointer */ +}; + +# else /* !__FAVOR_BSD */ +struct tcphdr + { + u_int16_t source; + u_int16_t dest; + u_int32_t seq; + u_int32_t ack_seq; +# if __BYTE_ORDER == __LITTLE_ENDIAN + u_int16_t res1:4; + u_int16_t doff:4; + u_int16_t fin:1; + u_int16_t syn:1; + u_int16_t rst:1; + u_int16_t psh:1; + u_int16_t ack:1; + u_int16_t urg:1; + u_int16_t res2:2; +# elif __BYTE_ORDER == __BIG_ENDIAN + u_int16_t doff:4; + u_int16_t res1:4; + u_int16_t res2:2; + u_int16_t urg:1; + u_int16_t ack:1; + u_int16_t psh:1; + u_int16_t rst:1; + u_int16_t syn:1; + u_int16_t fin:1; +# else +# error "Adjust your defines" +# endif + u_int16_t window; + u_int16_t check; + u_int16_t urg_ptr; +}; +# endif /* __FAVOR_BSD */ + +enum +{ + TCP_ESTABLISHED = 1, + TCP_SYN_SENT, + TCP_SYN_RECV, + TCP_FIN_WAIT1, + TCP_FIN_WAIT2, + TCP_TIME_WAIT, + TCP_CLOSE, + TCP_CLOSE_WAIT, + TCP_LAST_ACK, + TCP_LISTEN, + TCP_CLOSING /* now a valid state */ +}; + +# define TCPOPT_EOL 0 +# define TCPOPT_NOP 1 +# define TCPOPT_MAXSEG 2 +# define TCPOLEN_MAXSEG 4 +# define TCPOPT_WINDOW 3 +# define TCPOLEN_WINDOW 3 +# define TCPOPT_SACK_PERMITTED 4 /* Experimental */ +# define TCPOLEN_SACK_PERMITTED 2 +# define TCPOPT_SACK 5 /* Experimental */ +# define TCPOPT_TIMESTAMP 8 +# define TCPOLEN_TIMESTAMP 10 +# define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ + +# define TCPOPT_TSTAMP_HDR \ + (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) + +/* + * Default maximum segment size for TCP. + * With an IP MSS of 576, this is 536, + * but 512 is probably more convenient. + * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). + */ +# define TCP_MSS 512 + +# define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ + +# define TCP_MAX_WINSHIFT 14 /* maximum window shift */ + +# define SOL_TCP 6 /* TCP level */ + + +# define TCPI_OPT_TIMESTAMPS 1 +# define TCPI_OPT_SACK 2 +# define TCPI_OPT_WSCALE 4 +# define TCPI_OPT_ECN 8 + +/* Values for tcpi_state. */ +enum tcp_ca_state +{ + TCP_CA_Open = 0, + TCP_CA_Disorder = 1, + TCP_CA_CWR = 2, + TCP_CA_Recovery = 3, + TCP_CA_Loss = 4 +}; + +struct tcp_info +{ + u_int8_t tcpi_state; + u_int8_t tcpi_ca_state; + u_int8_t tcpi_retransmits; + u_int8_t tcpi_probes; + u_int8_t tcpi_backoff; + u_int8_t tcpi_options; + u_int8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; + + u_int32_t tcpi_rto; + u_int32_t tcpi_ato; + u_int32_t tcpi_snd_mss; + u_int32_t tcpi_rcv_mss; + + u_int32_t tcpi_unacked; + u_int32_t tcpi_sacked; + u_int32_t tcpi_lost; + u_int32_t tcpi_retrans; + u_int32_t tcpi_fackets; + + /* Times. */ + u_int32_t tcpi_last_data_sent; + u_int32_t tcpi_last_ack_sent; /* Not remembered, sorry. */ + u_int32_t tcpi_last_data_recv; + u_int32_t tcpi_last_ack_recv; + + /* Metrics. */ + u_int32_t tcpi_pmtu; + u_int32_t tcpi_rcv_ssthresh; + u_int32_t tcpi_rtt; + u_int32_t tcpi_rttvar; + u_int32_t tcpi_snd_ssthresh; + u_int32_t tcpi_snd_cwnd; + u_int32_t tcpi_advmss; + u_int32_t tcpi_reordering; +}; + +#endif /* Misc. */ + +#endif /* netinet/tcp.h */ diff --git a/conts/posix/libposix/include/posix/netinet/udp.h b/conts/posix/libposix/include/posix/netinet/udp.h new file mode 100644 index 0000000..5be4bbd --- /dev/null +++ b/conts/posix/libposix/include/posix/netinet/udp.h @@ -0,0 +1,55 @@ +/* Copyright (C) 1991, 92, 93, 95, 96, 97 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef __NETINET_UDP_H +#define __NETINET_UDP_H 1 + +#include +#include + +__BEGIN_DECLS + +/* UDP header as specified by RFC 768, August 1980. */ +#ifdef __FAVOR_BSD +struct udphdr { + u_int16_t uh_sport; /* source port */ + u_int16_t uh_dport; /* destination port */ + u_int16_t uh_ulen; /* udp length */ + u_int16_t uh_sum; /* udp checksum */ +}; +#else + +struct udphdr { + u_int16_t source; + u_int16_t dest; + u_int16_t len; + u_int16_t check; +}; +#endif + +#define SOL_UDP 17 /* sockopt level for UDP */ + +__END_DECLS + +#endif /* netinet/udp.h */ diff --git a/conts/posix/libposix/include/posix/netipx/ipx.h b/conts/posix/libposix/include/posix/netipx/ipx.h new file mode 100644 index 0000000..7eb42ef --- /dev/null +++ b/conts/posix/libposix/include/posix/netipx/ipx.h @@ -0,0 +1,113 @@ +/* Copyright (C) 1991, 92, 93, 95, 96, 97, 98 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef __NETIPX_IPX_H +#define __NETIPX_IPX_H 1 + +#include + +#include +#include + +__BEGIN_DECLS + +#define SOL_IPX 256 /* sockopt level */ + +#define IPX_TYPE 1 +#define IPX_NODE_LEN 6 +#define IPX_MTU 576 + +struct sockaddr_ipx + { + sa_family_t sipx_family; + u_int16_t sipx_port; + u_int32_t sipx_network; + unsigned char sipx_node[IPX_NODE_LEN]; + u_int8_t sipx_type; + unsigned char sipx_zero; /* 16 byte fill */ + }; + +/* + * So we can fit the extra info for SIOCSIFADDR into the address nicely + */ + +#define sipx_special sipx_port +#define sipx_action sipx_zero +#define IPX_DLTITF 0 +#define IPX_CRTITF 1 + +typedef struct ipx_route_definition + { + unsigned long ipx_network; + unsigned long ipx_router_network; + unsigned char ipx_router_node[IPX_NODE_LEN]; + } +ipx_route_definition; + +typedef struct ipx_interface_definition + { + unsigned long ipx_network; + unsigned char ipx_device[16]; + unsigned char ipx_dlink_type; +#define IPX_FRAME_NONE 0 +#define IPX_FRAME_SNAP 1 +#define IPX_FRAME_8022 2 +#define IPX_FRAME_ETHERII 3 +#define IPX_FRAME_8023 4 +#define IPX_FRAME_TR_8022 5 + unsigned char ipx_special; +#define IPX_SPECIAL_NONE 0 +#define IPX_PRIMARY 1 +#define IPX_INTERNAL 2 + unsigned char ipx_node[IPX_NODE_LEN]; + } +ipx_interface_definition; + +typedef struct ipx_config_data + { + unsigned char ipxcfg_auto_select_primary; + unsigned char ipxcfg_auto_create_interfaces; + } +ipx_config_data; + +/* + * OLD Route Definition for backward compatibility. + */ + +struct ipx_route_def + { + unsigned long ipx_network; + unsigned long ipx_router_network; +#define IPX_ROUTE_NO_ROUTER 0 + unsigned char ipx_router_node[IPX_NODE_LEN]; + unsigned char ipx_device[16]; + unsigned short ipx_flags; +#define IPX_RT_SNAP 8 +#define IPX_RT_8022 4 +#define IPX_RT_BLUEBOOK 2 +#define IPX_RT_ROUTED 1 + }; + +#define SIOCAIPXITFCRT (SIOCPROTOPRIVATE) +#define SIOCAIPXPRISLT (SIOCPROTOPRIVATE + 1) +#define SIOCIPXCFGDATA (SIOCPROTOPRIVATE + 2) +#define SIOCIPXNCPCONN (SIOCPROTOPRIVATE + 3) + +__END_DECLS + +#endif /* netipx/ipx.h */ diff --git a/conts/posix/libposix/include/posix/netpacket/packet.h b/conts/posix/libposix/include/posix/netpacket/packet.h new file mode 100644 index 0000000..6c63428 --- /dev/null +++ b/conts/posix/libposix/include/posix/netpacket/packet.h @@ -0,0 +1,64 @@ +/* Definitions for use with Linux AF_PACKET sockets. + Copyright (C) 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef __NETPACKET_PACKET_H +#define __NETPACKET_PACKET_H 1 + +struct sockaddr_ll + { + unsigned short int sll_family; + unsigned short int sll_protocol; + int sll_ifindex; + unsigned short int sll_hatype; + unsigned char sll_pkttype; + unsigned char sll_halen; + unsigned char sll_addr[8]; + }; + +/* Packet types. */ + +#define PACKET_HOST 0 /* To us. */ +#define PACKET_BROADCAST 1 /* To all. */ +#define PACKET_MULTICAST 2 /* To group. */ +#define PACKET_OTHERHOST 3 /* To someone else. */ +#define PACKET_OUTGOING 4 /* Originated by us . */ +#define PACKET_LOOPBACK 5 +#define PACKET_FASTROUTE 6 + +/* Packet socket options. */ + +#define PACKET_ADD_MEMBERSHIP 1 +#define PACKET_DROP_MEMBERSHIP 2 +#define PACKET_RECV_OUTPUT 3 +#define PACKET_RX_RING 5 +#define PACKET_STATISTICS 6 + +struct packet_mreq + { + int mr_ifindex; + unsigned short int mr_type; + unsigned short int mr_alen; + unsigned char mr_address[8]; + }; + +#define PACKET_MR_MULTICAST 0 +#define PACKET_MR_PROMISC 1 +#define PACKET_MR_ALLMULTI 2 + +#endif /* netpacket/packet.h */ diff --git a/conts/posix/libposix/include/posix/nl_types.h b/conts/posix/libposix/include/posix/nl_types.h new file mode 100644 index 0000000..74e7621 --- /dev/null +++ b/conts/posix/libposix/include/posix/nl_types.h @@ -0,0 +1,59 @@ +/* Copyright (C) 1996, 1997, 1999, 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _NL_TYPES_H +#define _NL_TYPES_H 1 + +#include + +/* The default message set used by the gencat program. */ +#define NL_SETD 1 + +/* Value for FLAG parameter of `catgets' to say we want XPG4 compliance. */ +#define NL_CAT_LOCALE 1 + + +__BEGIN_DECLS + +#ifdef __UCLIBC_MJN3_ONLY__ +#warning "mjn3 FIXME: None of these prototypes have implementations." +#endif + +/* Message catalog descriptor type. */ +typedef void *nl_catd; + +/* Type used by `nl_langinfo'. */ +typedef int nl_item; + +/* Open message catalog for later use, returning descriptor. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern nl_catd catopen (__const char *__cat_name, int __flag) __nonnull ((1)); + +/* Return translation with NUMBER in SET of CATALOG; if not found + return STRING. */ +extern char *catgets (nl_catd __catalog, int __set, int __number, + __const char *__string) __THROW __nonnull ((1)); + +/* Close message CATALOG. */ +extern int catclose (nl_catd __catalog) __THROW __nonnull ((1)); + +__END_DECLS + +#endif /* nl_types.h */ diff --git a/conts/posix/libposix/include/posix/obstack.h b/conts/posix/libposix/include/posix/obstack.h new file mode 100644 index 0000000..071acaf --- /dev/null +++ b/conts/posix/libposix/include/posix/obstack.h @@ -0,0 +1,605 @@ +/* obstack.h - object stack macros + Copyright (C) 1988,89,90,91,92,93,94,96,97,98,99 Free Software Foundation, Inc. + This file is part of the GNU C Library. Its master source is NOT part of + the C library, however. The master source lives in /gd/gnu/lib. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Summary: + +All the apparent functions defined here are macros. The idea +is that you would use these pre-tested macros to solve a +very specific set of problems, and they would run fast. +Caution: no side-effects in arguments please!! They may be +evaluated MANY times!! + +These macros operate a stack of objects. Each object starts life +small, and may grow to maturity. (Consider building a word syllable +by syllable.) An object can move while it is growing. Once it has +been "finished" it never changes address again. So the "top of the +stack" is typically an immature growing object, while the rest of the +stack is of mature, fixed size and fixed address objects. + +These routines grab large chunks of memory, using a function you +supply, called `obstack_chunk_alloc'. On occasion, they free chunks, +by calling `obstack_chunk_free'. You must define them and declare +them before using any obstack macros. + +Each independent stack is represented by a `struct obstack'. +Each of the obstack macros expects a pointer to such a structure +as the first argument. + +One motivation for this package is the problem of growing char strings +in symbol tables. Unless you are "fascist pig with a read-only mind" +--Gosper's immortal quote from HAKMEM item 154, out of context--you +would not like to put any arbitrary upper limit on the length of your +symbols. + +In practice this often means you will build many short symbols and a +few long symbols. At the time you are reading a symbol you don't know +how long it is. One traditional method is to read a symbol into a +buffer, realloc()ating the buffer every time you try to read a symbol +that is longer than the buffer. This is beaut, but you still will +want to copy the symbol from the buffer to a more permanent +symbol-table entry say about half the time. + +With obstacks, you can work differently. Use one obstack for all symbol +names. As you read a symbol, grow the name in the obstack gradually. +When the name is complete, finalize it. Then, if the symbol exists already, +free the newly read name. + +The way we do this is to take a large chunk, allocating memory from +low addresses. When you want to build a symbol in the chunk you just +add chars above the current "high water mark" in the chunk. When you +have finished adding chars, because you got to the end of the symbol, +you know how long the chars are, and you can create a new object. +Mostly the chars will not burst over the highest address of the chunk, +because you would typically expect a chunk to be (say) 100 times as +long as an average object. + +In case that isn't clear, when we have enough chars to make up +the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) +so we just point to it where it lies. No moving of chars is +needed and this is the second win: potentially long strings need +never be explicitly shuffled. Once an object is formed, it does not +change its address during its lifetime. + +When the chars burst over a chunk boundary, we allocate a larger +chunk, and then copy the partly formed object from the end of the old +chunk to the beginning of the new larger chunk. We then carry on +accreting characters to the end of the object as we normally would. + +A special macro is provided to add a single char at a time to a +growing object. This allows the use of register variables, which +break the ordinary 'growth' macro. + +Summary: + We allocate large chunks. + We carve out one object at a time from the current chunk. + Once carved, an object never moves. + We are free to append data of any size to the currently + growing object. + Exactly one object is growing in an obstack at any one time. + You can run one obstack per control block. + You may have as many control blocks as you dare. + Because of the way we do it, you can `unwind' an obstack + back to a previous state. (You may remove objects much + as you would with a stack.) +*/ + + +/* Don't do the contents of this file more than once. */ + +#ifndef _OBSTACK_H +#define _OBSTACK_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* We use subtraction of (char *) 0 instead of casting to int + because on word-addressable machines a simple cast to int + may ignore the byte-within-word field of the pointer. */ + +#ifndef __PTR_TO_INT +# define __PTR_TO_INT(P) ((P) - (char *) 0) +#endif + +#ifndef __INT_TO_PTR +# define __INT_TO_PTR(P) ((P) + (char *) 0) +#endif + +/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is + defined, as with GNU C, use that; that way we don't pollute the + namespace with 's symbols. Otherwise, if is + available, include it and use ptrdiff_t. In traditional C, long is + the best that we can do. */ + +#ifdef __PTRDIFF_TYPE__ +# define PTR_INT_TYPE __PTRDIFF_TYPE__ +#else +# ifdef HAVE_STDDEF_H +# include +# define PTR_INT_TYPE ptrdiff_t +# else +# define PTR_INT_TYPE long +# endif +#endif + +#if defined _LIBC || defined HAVE_STRING_H +# include +# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N)) +#else +# ifdef memcpy +# define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N)) +# else +# define _obstack_memcpy(To, From, N) bcopy ((From), (To), (N)) +# endif +#endif + +struct _obstack_chunk /* Lives at front of each chunk. */ +{ + char *limit; /* 1 past end of this chunk */ + struct _obstack_chunk *prev; /* address of prior chunk or NULL */ + char contents[4]; /* objects begin here */ +}; + +struct obstack /* control current object in current chunk */ +{ + long chunk_size; /* preferred size to allocate chunks in */ + struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */ + char *object_base; /* address of object we are building */ + char *next_free; /* where to add next char to current object */ + char *chunk_limit; /* address of char after current chunk */ + PTR_INT_TYPE temp; /* Temporary for some macros. */ + int alignment_mask; /* Mask of alignment for each object. */ +#if defined __STDC__ && __STDC__ + /* These prototypes vary based on `use_extra_arg', and we use + casts to the prototypeless function type in all assignments, + but having prototypes here quiets -Wstrict-prototypes. */ + struct _obstack_chunk *(*chunkfun) (void *, long); + void (*freefun) (void *, struct _obstack_chunk *); + void *extra_arg; /* first arg for chunk alloc/dealloc funcs */ +#else + struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */ + void (*freefun) (); /* User's function to free a chunk. */ + char *extra_arg; /* first arg for chunk alloc/dealloc funcs */ +#endif + unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */ + unsigned maybe_empty_object:1;/* There is a possibility that the current + chunk contains a zero-length object. This + prevents freeing the chunk if we allocate + a bigger chunk to replace it. */ + unsigned alloc_failed:1; /* No longer used, as we now call the failed + handler on error, but retained for binary + compatibility. */ +}; + +/* Declare the external functions we use; they are in obstack.c. */ + +#if defined __STDC__ && __STDC__ +extern void _obstack_newchunk (struct obstack *, int); +extern void _obstack_free (struct obstack *, void *); +extern int _obstack_begin (struct obstack *, int, int, + void *(*) (long), void (*) (void *)); +extern int _obstack_begin_1 (struct obstack *, int, int, + void *(*) (void *, long), + void (*) (void *, void *), void *); +extern int _obstack_memory_used (struct obstack *); +#else +extern void _obstack_newchunk (); +extern void _obstack_free (); +extern int _obstack_begin (); +extern int _obstack_begin_1 (); +extern int _obstack_memory_used (); +#endif + +#if defined __STDC__ && __STDC__ + +/* Do the function-declarations after the structs + but before defining the macros. */ + +void obstack_init (struct obstack *obstack); + +void * obstack_alloc (struct obstack *obstack, int size); + +void * obstack_copy (struct obstack *obstack, const void *address, int size); +void * obstack_copy0 (struct obstack *obstack, const void *address, int size); + +void obstack_free (struct obstack *obstack, void *block); + +void obstack_blank (struct obstack *obstack, int size); + +void obstack_grow (struct obstack *obstack, const void *data, int size); +void obstack_grow0 (struct obstack *obstack, const void *data, int size); + +void obstack_1grow (struct obstack *obstack, int data_char); +void obstack_ptr_grow (struct obstack *obstack, const void *data); +void obstack_int_grow (struct obstack *obstack, int data); + +void * obstack_finish (struct obstack *obstack); + +int obstack_object_size (struct obstack *obstack); + +int obstack_room (struct obstack *obstack); +void obstack_make_room (struct obstack *obstack, int size); +void obstack_1grow_fast (struct obstack *obstack, int data_char); +void obstack_ptr_grow_fast (struct obstack *obstack, const void *data); +void obstack_int_grow_fast (struct obstack *obstack, int data); +void obstack_blank_fast (struct obstack *obstack, int size); + +void * obstack_base (struct obstack *obstack); +void * obstack_next_free (struct obstack *obstack); +int obstack_alignment_mask (struct obstack *obstack); +int obstack_chunk_size (struct obstack *obstack); +int obstack_memory_used (struct obstack *obstack); + +#endif /* __STDC__ */ + +/* Non-ANSI C cannot really support alternative functions for these macros, + so we do not declare them. */ + +/* Error handler called when `obstack_chunk_alloc' failed to allocate + more memory. This can be set to a user defined function which + should either abort gracefully or use longjump - but shouldn't + return. The default action is to print a message and abort. */ +#if defined __STDC__ && __STDC__ +extern void (*obstack_alloc_failed_handler) (void); +#else +extern void (*obstack_alloc_failed_handler) (); +#endif + +/* Exit value used when `print_and_abort' is used. */ +extern int obstack_exit_failure; + +/* Pointer to beginning of object being allocated or to be allocated next. + Note that this might not be the final address of the object + because a new chunk might be needed to hold the final size. */ + +#define obstack_base(h) ((h)->object_base) + +/* Size for allocating ordinary chunks. */ + +#define obstack_chunk_size(h) ((h)->chunk_size) + +/* Pointer to next byte not yet allocated in current chunk. */ + +#define obstack_next_free(h) ((h)->next_free) + +/* Mask specifying low bits that should be clear in address of an object. */ + +#define obstack_alignment_mask(h) ((h)->alignment_mask) + +/* To prevent prototype warnings provide complete argument list in + standard C version. */ +#if defined __STDC__ && __STDC__ + +# define obstack_init(h) \ + _obstack_begin ((h), 0, 0, \ + (void *(*) (long)) obstack_chunk_alloc, \ + (void (*) (void *)) obstack_chunk_free) + +# define obstack_begin(h, size) \ + _obstack_begin ((h), (size), 0, \ + (void *(*) (long)) obstack_chunk_alloc, \ + (void (*) (void *)) obstack_chunk_free) + +# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ + _obstack_begin ((h), (size), (alignment), \ + (void *(*) (long)) (chunkfun), \ + (void (*) (void *)) (freefun)) + +# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ + _obstack_begin_1 ((h), (size), (alignment), \ + (void *(*) (void *, long)) (chunkfun), \ + (void (*) (void *, void *)) (freefun), (arg)) + +# define obstack_chunkfun(h, newchunkfun) \ + ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun)) + +# define obstack_freefun(h, newfreefun) \ + ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun)) + +#else + +# define obstack_init(h) \ + _obstack_begin ((h), 0, 0, \ + (void *(*) ()) obstack_chunk_alloc, \ + (void (*) ()) obstack_chunk_free) + +# define obstack_begin(h, size) \ + _obstack_begin ((h), (size), 0, \ + (void *(*) ()) obstack_chunk_alloc, \ + (void (*) ()) obstack_chunk_free) + +# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ + _obstack_begin ((h), (size), (alignment), \ + (void *(*) ()) (chunkfun), \ + (void (*) ()) (freefun)) + +# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ + _obstack_begin_1 ((h), (size), (alignment), \ + (void *(*) ()) (chunkfun), \ + (void (*) ()) (freefun), (arg)) + +# define obstack_chunkfun(h, newchunkfun) \ + ((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun)) + +# define obstack_freefun(h, newfreefun) \ + ((h) -> freefun = (void (*)()) (newfreefun)) + +#endif + +#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) + +#define obstack_blank_fast(h,n) ((h)->next_free += (n)) + +#define obstack_memory_used(h) _obstack_memory_used (h) + +#if defined __GNUC__ && defined __STDC__ && __STDC__ +/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and + does not implement __extension__. But that compiler doesn't define + __GNUC_MINOR__. */ +# if __GNUC__ < 2 || (defined __NeXT__ && __NeXT__ && !__GNUC_MINOR__) +# define __extension__ +# endif + +/* For GNU C, if not -traditional, + we can define these macros to compute all args only once + without using a global variable. + Also, we can avoid using the `temp' slot, to make faster code. */ + +# define obstack_object_size(OBSTACK) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + (unsigned) (__o->next_free - __o->object_base); }) + +# define obstack_room(OBSTACK) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + (unsigned) (__o->chunk_limit - __o->next_free); }) + +# define obstack_make_room(OBSTACK,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->chunk_limit - __o->next_free < __len) \ + _obstack_newchunk (__o, __len); \ + (void) 0; }) + +# define obstack_empty_p(OBSTACK) \ + __extension__ \ + ({ struct obstack *__o = (OBSTACK); \ + (__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); }) + +# define obstack_grow(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->next_free + __len > __o->chunk_limit) \ + _obstack_newchunk (__o, __len); \ + _obstack_memcpy (__o->next_free, (where), __len); \ + __o->next_free += __len; \ + (void) 0; }) + +# define obstack_grow0(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->next_free + __len + 1 > __o->chunk_limit) \ + _obstack_newchunk (__o, __len + 1); \ + _obstack_memcpy (__o->next_free, (where), __len); \ + __o->next_free += __len; \ + *(__o->next_free)++ = 0; \ + (void) 0; }) + +# define obstack_1grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + if (__o->next_free + 1 > __o->chunk_limit) \ + _obstack_newchunk (__o, 1); \ + *(__o->next_free)++ = (datum); \ + (void) 0; }) + +/* These assume that the obstack alignment is good enough for pointers + or ints, and that the data added so far to the current object + shares that much alignment. */ + +# define obstack_ptr_grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + if (__o->next_free + sizeof (void *) > __o->chunk_limit) \ + _obstack_newchunk (__o, sizeof (void *)); \ + *((void **)__o->next_free)++ = (datum); \ + (void) 0; }) + +# define obstack_int_grow(OBSTACK,datum) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + if (__o->next_free + sizeof (int) > __o->chunk_limit) \ + _obstack_newchunk (__o, sizeof (int)); \ + *((int *)__o->next_free)++ = (datum); \ + (void) 0; }) + +# define obstack_ptr_grow_fast(h,aptr) \ + (*((void **) (h)->next_free)++ = (aptr)) + +# define obstack_int_grow_fast(h,aint) \ + (*((int *) (h)->next_free)++ = (aint)) + +# define obstack_blank(OBSTACK,length) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + int __len = (length); \ + if (__o->chunk_limit - __o->next_free < __len) \ + _obstack_newchunk (__o, __len); \ + __o->next_free += __len; \ + (void) 0; }) + +# define obstack_alloc(OBSTACK,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_blank (__h, (length)); \ + obstack_finish (__h); }) + +# define obstack_copy(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_grow (__h, (where), (length)); \ + obstack_finish (__h); }) + +# define obstack_copy0(OBSTACK,where,length) \ +__extension__ \ +({ struct obstack *__h = (OBSTACK); \ + obstack_grow0 (__h, (where), (length)); \ + obstack_finish (__h); }) + +/* The local variable is named __o1 to avoid a name conflict + when obstack_blank is called. */ +# define obstack_finish(OBSTACK) \ +__extension__ \ +({ struct obstack *__o1 = (OBSTACK); \ + void *value; \ + value = (void *) __o1->object_base; \ + if (__o1->next_free == value) \ + __o1->maybe_empty_object = 1; \ + __o1->next_free \ + = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\ + & ~ (__o1->alignment_mask)); \ + if (__o1->next_free - (char *)__o1->chunk \ + > __o1->chunk_limit - (char *)__o1->chunk) \ + __o1->next_free = __o1->chunk_limit; \ + __o1->object_base = __o1->next_free; \ + value; }) + +# define obstack_free(OBSTACK, OBJ) \ +__extension__ \ +({ struct obstack *__o = (OBSTACK); \ + void *__obj = (OBJ); \ + if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ + __o->next_free = __o->object_base = (char *)__obj; \ + else (obstack_free) (__o, __obj); }) + +#else /* not __GNUC__ or not __STDC__ */ + +# define obstack_object_size(h) \ + (unsigned) ((h)->next_free - (h)->object_base) + +# define obstack_room(h) \ + (unsigned) ((h)->chunk_limit - (h)->next_free) + +# define obstack_empty_p(h) \ + ((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0) + +/* Note that the call to _obstack_newchunk is enclosed in (..., 0) + so that we can avoid having void expressions + in the arms of the conditional expression. + Casting the third operand to void was tried before, + but some compilers won't accept it. */ + +# define obstack_make_room(h,length) \ +( (h)->temp = (length), \ + (((h)->next_free + (h)->temp > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), (h)->temp), 0) : 0)) + +# define obstack_grow(h,where,length) \ +( (h)->temp = (length), \ + (((h)->next_free + (h)->temp > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ + _obstack_memcpy ((h)->next_free, (where), (h)->temp), \ + (h)->next_free += (h)->temp) + +# define obstack_grow0(h,where,length) \ +( (h)->temp = (length), \ + (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \ + _obstack_memcpy ((h)->next_free, (where), (h)->temp), \ + (h)->next_free += (h)->temp, \ + *((h)->next_free)++ = 0) + +# define obstack_1grow(h,datum) \ +( (((h)->next_free + 1 > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), 1), 0) : 0), \ + (*((h)->next_free)++ = (datum))) + +# define obstack_ptr_grow(h,datum) \ +( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ + (*((const char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = (datum))) + +# define obstack_int_grow(h,datum) \ +( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ + ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ + (*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = (datum))) + +# define obstack_ptr_grow_fast(h,aptr) \ + (*((const char **) (h)->next_free)++ = (aptr)) + +# define obstack_int_grow_fast(h,aint) \ + (*((int *) (h)->next_free)++ = (aint)) + +# define obstack_blank(h,length) \ +( (h)->temp = (length), \ + (((h)->chunk_limit - (h)->next_free < (h)->temp) \ + ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ + ((h)->next_free += (h)->temp)) + +# define obstack_alloc(h,length) \ + (obstack_blank ((h), (length)), obstack_finish ((h))) + +# define obstack_copy(h,where,length) \ + (obstack_grow ((h), (where), (length)), obstack_finish ((h))) + +# define obstack_copy0(h,where,length) \ + (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) + +# define obstack_finish(h) \ +( ((h)->next_free == (h)->object_base \ + ? (((h)->maybe_empty_object = 1), 0) \ + : 0), \ + (h)->temp = __PTR_TO_INT ((h)->object_base), \ + (h)->next_free \ + = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \ + & ~ ((h)->alignment_mask)), \ + (((h)->next_free - (char *) (h)->chunk \ + > (h)->chunk_limit - (char *) (h)->chunk) \ + ? ((h)->next_free = (h)->chunk_limit) : 0), \ + (h)->object_base = (h)->next_free, \ + __INT_TO_PTR ((h)->temp)) + +# if defined __STDC__ && __STDC__ +# define obstack_free(h,obj) \ +( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \ + (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ + ? (int) ((h)->next_free = (h)->object_base \ + = (h)->temp + (char *) (h)->chunk) \ + : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0))) +# else +# define obstack_free(h,obj) \ +( (h)->temp = (char *) (obj) - (char *) (h)->chunk, \ + (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ + ? (int) ((h)->next_free = (h)->object_base \ + = (h)->temp + (char *) (h)->chunk) \ + : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0))) +# endif + +#endif /* not __GNUC__ or not __STDC__ */ + +#ifdef __cplusplus +} /* C++ */ +#endif + +#endif /* obstack.h */ diff --git a/conts/posix/libposix/include/posix/paths.h b/conts/posix/libposix/include/posix/paths.h new file mode 100644 index 0000000..ae892c4 --- /dev/null +++ b/conts/posix/libposix/include/posix/paths.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)paths.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _PATHS_H_ +#define _PATHS_H_ + +/* Default search path. */ +#define _PATH_DEFPATH "/usr/bin:/bin" +/* All standard utilities path. */ +#define _PATH_STDPATH \ + "/usr/bin:/bin:/usr/sbin:/sbin" + +#define _PATH_BSHELL "/bin/sh" +#define _PATH_CONSOLE "/dev/console" +#define _PATH_CSHELL "/bin/csh" +#define _PATH_DEVDB "/var/run/dev.db" +#define _PATH_DEVNULL "/dev/null" +#define _PATH_DRUM "/dev/drum" +#define _PATH_KLOG "/proc/kmsg" +#define _PATH_KMEM "/dev/kmem" +#define _PATH_LASTLOG "/var/log/lastlog" +#define _PATH_MAILDIR "/var/mail" +#define _PATH_MAN "/usr/share/man" +#define _PATH_MEM "/dev/mem" +#define _PATH_MNTTAB "/etc/fstab" +#define _PATH_MOUNTED "/etc/mtab" +#define _PATH_NOLOGIN "/etc/nologin" +#define _PATH_PRESERVE "/var/lib" +#define _PATH_RWHODIR "/var/spool/rwho" +#define _PATH_SENDMAIL "/usr/sbin/sendmail" +#define _PATH_SHADOW "/etc/shadow" +#define _PATH_SHELLS "/etc/shells" +#define _PATH_TTY "/dev/tty" +#define _PATH_UNIX "/boot/vmlinux" +#define _PATH_UTMP "/var/run/utmp" +#define _PATH_VI "/usr/bin/vi" +#define _PATH_WTMP "/var/log/wtmp" + +/* uClibc */ +#ifdef _LIBC +#define _PATH_PASSWD "/etc/passwd" +#define _PATH_GROUP "/etc/group" +#endif + +/* Provide trailing slash, since mostly used for building pathnames. */ +#define _PATH_DEV "/dev/" +#define _PATH_TMP "/tmp/" +#define _PATH_VARDB "/var/db/" +#define _PATH_VARRUN "/var/run/" +#define _PATH_VARTMP "/var/tmp/" + +#endif /* !_PATHS_H_ */ diff --git a/conts/posix/libposix/include/posix/poll.h b/conts/posix/libposix/include/posix/poll.h new file mode 100644 index 0000000..06fb41a --- /dev/null +++ b/conts/posix/libposix/include/posix/poll.h @@ -0,0 +1 @@ +#include diff --git a/conts/posix/libposix/include/posix/posix_init.h b/conts/posix/libposix/include/posix/posix_init.h new file mode 100644 index 0000000..43a99b2 --- /dev/null +++ b/conts/posix/libposix/include/posix/posix_init.h @@ -0,0 +1,7 @@ +#ifndef __LIBPOSIX_INIT_H__ +#define __LIBPOSIX_INIT_H__ + +void libposix_init(void); +void posix_service_init(void); + +#endif /* __LIBPOSIX_INIT_H__ */ diff --git a/conts/posix/libposix/include/posix/printf.h b/conts/posix/libposix/include/posix/printf.h new file mode 100644 index 0000000..a68c6da --- /dev/null +++ b/conts/posix/libposix/include/posix/printf.h @@ -0,0 +1,252 @@ +/* Copyright (C) 1991-1993,1995-1999,2000,2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* March 11, 2001 Manuel Novoa III + * + * Modified as appropriate for my new stdio lib. + */ + +#ifndef _PRINTF_H + +#define _PRINTF_H 1 +#include + +__BEGIN_DECLS + +#define __need_FILE +#include +#define __need_size_t +#define __need_wchar_t +#include + +/* WARNING -- This is definitely nonportable... but it seems to work + * with gcc, which is currently the only "supported" compiler. + * The library code uses bitmasks for space-efficiency (you can't + * set/test multiple bitfields in one operation). Unfortunatly, we + * need to support bitfields since that's what glibc uses. So, we take + * advantage of how gcc lays out bitfields to create an appropriate + * mapping. By defining __PRINTF_INFO_NO_BITFIELD we access the + * bitfields using bitmasks in a single flag variable. + * + * WARNING -- This may very well fail if built with -fpack-struct!!! + * + * TODO -- Add a validation test. + * TODO -- Add an option to build in a shim translation function if + * the bitfield<->bitmask mapping fails. + */ +/* #define __PRINTF_INFO_NO_BITFIELD */ +#include + +struct printf_info +{ + int prec; /* Precision. */ + int width; /* Width. */ +#ifdef __UCLIBC_HAS_WCHAR__ + wchar_t spec; /* Format letter. */ +#else + int spec; +#endif +#ifndef __PRINTF_INFO_NO_BITFIELD +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int space:1; /* Space flag. */ + unsigned int showsign:1; /* + flag. */ + unsigned int extra:1; /* For special use. */ + unsigned int left:1; /* - flag. */ + unsigned int alt:1; /* # flag. */ + unsigned int group:1; /* ' flag. */ + unsigned int i18n:1; /* I flag. */ + unsigned int wide:1; /* Nonzero for wide character streams. */ + unsigned int is_char:1; /* hh flag. */ + unsigned int is_short:1; /* h flag. */ + unsigned int is_long:1; /* l flag. */ + unsigned int is_long_double:1;/* L flag. */ + unsigned int __padding:20;/* non-gnu -- total of 32 bits on 32bit arch */ + +#elif __BYTE_ORDER == __BIG_ENDIAN + + unsigned int __padding:20;/* non-gnu -- total of 32 bits on 32bit arch */ + unsigned int is_long_double:1;/* L flag. */ + unsigned int is_long:1; /* l flag. */ + unsigned int is_short:1; /* h flag. */ + unsigned int is_char:1; /* hh flag. */ + unsigned int wide:1; /* Nonzero for wide character streams. */ + unsigned int i18n:1; /* I flag. */ + unsigned int group:1; /* ' flag. */ + unsigned int alt:1; /* # flag. */ + unsigned int left:1; /* - flag. */ + unsigned int extra:1; /* For special use. */ + unsigned int showsign:1; /* + flag. */ + unsigned int space:1; /* Space flag. */ + +#else +#error unsupported byte order! +#endif + +#define PRINT_INFO_FLAG_VAL(INFO_PTR,BITFIELD) (INFO_PTR)->BITFIELD +#define PRINT_INFO_SET_FLAG(INFO_PTR,BITFIELD) (INFO_PTR)->BITFIELD = 1 +#define PRINT_INFO_CLR_FLAG(INFO_PTR,BITFIELD) (INFO_PTR)->BITFIELD = 0 +#define PRINT_INFO_SET_extra(INFO_PTR,VAL) (INFO_PTR)->extra = (VAL) + +#else /* __PRINTF_INFO_NO_BITFIELD */ + + unsigned int _flags; /* non-gnu */ +#define __PRINT_INFO_FLAG_space (1<<0) +#define __PRINT_INFO_FLAG_showsign (1<<1) +#define __PRINT_INFO_FLAG_extra (1<<2) +#define __PRINT_INFO_FLAG_left (1<<3) +#define __PRINT_INFO_FLAG_alt (1<<4) +#define __PRINT_INFO_FLAG_group (1<<5) +#define __PRINT_INFO_FLAG_i18n (1<<6) +#define __PRINT_INFO_FLAG_wide (1<<7) + +#define __PRINT_INFO_FLAG_is_char (1<<8) +#define __PRINT_INFO_FLAG_is_short (1<<9) +#define __PRINT_INFO_FLAG_is_long (1<<10) +#define __PRINT_INFO_FLAG_is_long_double (1<<11) + +#if defined(__STDC__) && __STDC__ +#define PRINT_INFO_FLAG_VAL(INFO_PTR,BITFIELD) \ + ((INFO_PTR)->_flags & __PRINT_INFO_FLAG_##BITFIELD) +#define PRINT_INFO_SET_FLAG(INFO_PTR,BITFIELD) \ + ((INFO_PTR)->_flags |= __PRINT_INFO_FLAG_##BITFIELD) +#define PRINT_INFO_CLR_FLAG(INFO_PTR,BITFIELD) \ + ((INFO_PTR)->_flags &= ~__PRINT_INFO_FLAG_##BITFIELD) +#else +#define PRINT_INFO_FLAG_VAL(INFO_PTR,BITFIELD) \ + ((INFO_PTR)->_flags & __PRINT_INFO_FLAG_/**/BITFIELD) +#define PRINT_INFO_SET_FLAG(INFO_PTR,BITFIELD) \ + ((INFO_PTR)->_flags |= __PRINT_INFO_FLAG_/**/BITFIELD) +#define PRINT_INFO_CLR_FLAG(INFO_PTR,BITFIELD) \ + ((INFO_PTR)->_flags &= ~__PRINT_INFO_FLAG_/**/BITFIELD) +#endif +#define PRINT_INFO_SET_extra(INFO_PTR,VAL) \ + ((INFO_PTR)->_flags |= (((INFO_PTR)->_flags & ~1) | ((VAL) & 1))) +#endif /* __PRINTF_INFO_NO_BITFIELD */ +#ifdef __UCLIBC_HAS_WCHAR__ + wchar_t pad; /* Padding character. */ +#else + int pad; +#endif +}; + + +/* Type of a printf specifier-handler function. + STREAM is the FILE on which to write output. + INFO gives information about the format specification. + ARGS is a vector of pointers to the argument data; + the number of pointers will be the number returned + by the associated arginfo function for the same INFO. + + The function should return the number of characters written, + or -1 for errors. */ + +#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__ +typedef int (*printf_function) (FILE *__stream, + __const struct printf_info *__info, + __const void *__const *__args); + +/* Type of a printf specifier-arginfo function. + INFO gives information about the format specification. + N, ARGTYPES, and return value are as for parse_printf_format. */ + +typedef int printf_arginfo_function (__const struct printf_info *__info, + size_t __n, int *__argtypes); + + +/* Register FUNC to be called to format SPEC specifiers; ARGINFO must be + specified to determine how many arguments a SPEC conversion requires and + what their types are. */ + +extern int register_printf_function (int __spec, printf_function __func, + printf_arginfo_function __arginfo); +#endif + + +/* Parse FMT, and fill in N elements of ARGTYPES with the + types needed for the conversions FMT specifies. Returns + the number of arguments required by FMT. + + The ARGINFO function registered with a user-defined format is passed a + `struct printf_info' describing the format spec being parsed. A width + or precision of INT_MIN means a `*' was used to indicate that the + width/precision will come from an arg. The function should fill in the + array it is passed with the types of the arguments it wants, and return + the number of arguments it wants. */ + +extern size_t parse_printf_format (__const char *__restrict __fmt, size_t __n, + int *__restrict __argtypes) __THROW; + + +/* Codes returned by `parse_printf_format' for basic types. + + These values cover all the standard format specifications. + Users can add new values after PA_LAST for their own types. */ + +/* WARNING -- The above is not entirely true, even for glibc. + * As far as the library code is concerned, such args are treated + * as 'your type' pointers if qualified by PA_FLAG_PTR. If they + * aren't qualified as pointers, I _think_ glibc just ignores them + * and carries on. I think it should be treated as an error. */ + +enum +{ /* C type: */ + PA_INT, /* int */ + PA_CHAR, /* int, cast to char */ + PA_WCHAR, /* wide char */ + PA_STRING, /* const char *, a '\0'-terminated string */ + PA_WSTRING, /* const wchar_t *, wide character string */ + PA_POINTER, /* void * */ + PA_FLOAT, /* float */ + PA_DOUBLE, /* double */ + __PA_NOARG, /* non-glibc -- signals non-arg width or prec */ + PA_LAST +}; + +/* Flag bits that can be set in a type returned by `parse_printf_format'. */ +/* WARNING -- These differ in value from what glibc uses. */ +#define PA_FLAG_MASK (0xff00) +#define __PA_FLAG_CHAR (0x0100) /* non-gnu -- to deal with hh */ +#define PA_FLAG_SHORT (0x0200) +#define PA_FLAG_LONG (0x0400) +#define PA_FLAG_LONG_LONG (0x0800) +#define PA_FLAG_LONG_DOUBLE PA_FLAG_LONG_LONG +#define PA_FLAG_PTR (0x1000) /* TODO -- make dynamic??? */ + +#define __PA_INTMASK (0x0f00) /* non-gnu -- all int flags */ + +#if 0 +/* Function which can be registered as `printf'-handlers. */ + +/* Print floating point value using using abbreviations for the orders + of magnitude used for numbers ('k' for kilo, 'm' for mega etc). If + the format specifier is a uppercase character powers of 1000 are + used. Otherwise powers of 1024. */ +extern int printf_size (FILE *__restrict __fp, + __const struct printf_info *__info, + __const void *__const *__restrict __args) __THROW; + +/* This is the appropriate argument information function for `printf_size'. */ +extern int printf_size_info (__const struct printf_info *__restrict + __info, size_t __n, int *__restrict __argtypes) + __THROW; + +#endif + +__END_DECLS + +#endif /* printf.h */ diff --git a/conts/posix/libposix/include/posix/protocols/routed.h b/conts/posix/libposix/include/posix/protocols/routed.h new file mode 100644 index 0000000..befd865 --- /dev/null +++ b/conts/posix/libposix/include/posix/protocols/routed.h @@ -0,0 +1,101 @@ +/*- + * Copyright (c) 1983, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)routed.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _PROTOCOLS_ROUTED_H +#define _PROTOCOLS_ROUTED_H 1 + +#include +/* + * Routing Information Protocol + * + * Derived from Xerox NS Routing Information Protocol + * by changing 32-bit net numbers to sockaddr's and + * padding stuff to 32-bit boundaries. + */ +#define RIPVERSION 1 + +struct netinfo { + struct sockaddr rip_dst; /* destination net/host */ + int rip_metric; /* cost of route */ +}; + +struct rip { + u_char rip_cmd; /* request/response */ + u_char rip_vers; /* protocol version # */ + u_char rip_res1[2]; /* pad to 32-bit boundary */ + union { + struct netinfo ru_nets[1]; /* variable length... */ + char ru_tracefile[1]; /* ditto ... */ + } ripun; +#define rip_nets ripun.ru_nets +#define rip_tracefile ripun.ru_tracefile +}; + +/* + * Packet types. + */ +#define RIPCMD_REQUEST 1 /* want info */ +#define RIPCMD_RESPONSE 2 /* responding to request */ +#define RIPCMD_TRACEON 3 /* turn tracing on */ +#define RIPCMD_TRACEOFF 4 /* turn it off */ + +#define RIPCMD_MAX 5 +#ifdef RIPCMDS +char *ripcmds[RIPCMD_MAX] = + { "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF" }; +#endif + +#define HOPCNT_INFINITY 16 /* per Xerox NS */ +#define MAXPACKETSIZE 512 /* max broadcast size */ + +/* + * Timer values used in managing the routing table. + * Complete tables are broadcast every SUPPLY_INTERVAL seconds. + * If changes occur between updates, dynamic updates containing only changes + * may be sent. When these are sent, a timer is set for a random value + * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates + * are sent until the timer expires. + * + * Every update of a routing entry forces an entry's timer to be reset. + * After EXPIRE_TIME without updates, the entry is marked invalid, + * but held onto until GARBAGE_TIME so that others may + * see it "be deleted". + */ +#define TIMER_RATE 30 /* alarm clocks every 30 seconds */ + +#define SUPPLY_INTERVAL 30 /* time to supply tables */ +#define MIN_WAITTIME 2 /* min. interval to broadcast changes */ +#define MAX_WAITTIME 5 /* max. time to delay changes */ + +#define EXPIRE_TIME 180 /* time to mark entry invalid */ +#define GARBAGE_TIME 240 /* time to garbage collect */ + +#endif /* protocols/routed.h */ diff --git a/conts/posix/libposix/include/posix/protocols/rwhod.h b/conts/posix/libposix/include/posix/protocols/rwhod.h new file mode 100644 index 0000000..446d6f9 --- /dev/null +++ b/conts/posix/libposix/include/posix/protocols/rwhod.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)rwhod.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _PROTOCOLS_RWHOD_H +#define _PROTOCOLS_RWHOD_H 1 + +#include + +/* + * rwho protocol packet format. + */ +struct outmp { + char out_line[8]; /* tty name */ + char out_name[8]; /* user id */ + int32_t out_time; /* time on */ +}; + +struct whod { + char wd_vers; /* protocol version # */ + char wd_type; /* packet type, see below */ + char wd_pad[2]; + int wd_sendtime; /* time stamp by sender */ + int wd_recvtime; /* time stamp applied by receiver */ + char wd_hostname[32]; /* hosts's name */ + int wd_loadav[3]; /* load average as in uptime */ + int wd_boottime; /* time system booted */ + struct whoent { + struct outmp we_utmp; /* active tty info */ + int we_idle; /* tty idle time */ + } wd_we[1024 / sizeof (struct whoent)]; +}; + +#define WHODVERSION 1 +#define WHODTYPE_STATUS 1 /* host status */ + +/* We used to define _PATH_RWHODIR here but it's now in . */ +#include + +#endif /* protocols/rwhod.h */ diff --git a/conts/posix/libposix/include/posix/protocols/talkd.h b/conts/posix/libposix/include/posix/protocols/talkd.h new file mode 100644 index 0000000..a8f33b1 --- /dev/null +++ b/conts/posix/libposix/include/posix/protocols/talkd.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)talkd.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _PROTOCOLS_TALKD_H +#define _PROTOCOLS_TALKD_H 1 + +/* + * This describes the protocol used by the talk server and clients. + * + * The talk server acts a repository of invitations, responding to + * requests by clients wishing to rendezvous for the purpose of + * holding a conversation. In normal operation, a client, the caller, + * initiates a rendezvous by sending a CTL_MSG to the server of + * type LOOK_UP. This causes the server to search its invitation + * tables to check if an invitation currently exists for the caller + * (to speak to the callee specified in the message). If the lookup + * fails, the caller then sends an ANNOUNCE message causing the server + * to broadcast an announcement on the callee's login ports requesting + * contact. When the callee responds, the local server uses the + * recorded invitation to respond with the appropriate rendezvous + * address and the caller and callee client programs establish a + * stream connection through which the conversation takes place. + */ + +#include +#include + +/* + * Client->server request message format. + */ +typedef struct { + u_char vers; /* protocol version */ + u_char type; /* request type, see below */ + u_char answer; /* not used */ + u_char pad; + u_int32_t id_num; /* message id */ + struct osockaddr addr; /* old (4.3) style */ + struct osockaddr ctl_addr; /* old (4.3) style */ + int32_t pid; /* caller's process id */ +#define NAME_SIZE 12 + char l_name[NAME_SIZE];/* caller's name */ + char r_name[NAME_SIZE];/* callee's name */ +#define TTY_SIZE 16 + char r_tty[TTY_SIZE];/* callee's tty name */ +} CTL_MSG; + +/* + * Server->client response message format. + */ +typedef struct { + u_char vers; /* protocol version */ + u_char type; /* type of request message, see below */ + u_char answer; /* response to request message, see below */ + u_char pad; + u_int32_t id_num; /* message id */ + struct osockaddr addr; /* address for establishing conversation */ +} CTL_RESPONSE; + +#define TALK_VERSION 1 /* protocol version */ + +/* message type values */ +#define LEAVE_INVITE 0 /* leave invitation with server */ +#define LOOK_UP 1 /* check for invitation by callee */ +#define DELETE 2 /* delete invitation by caller */ +#define ANNOUNCE 3 /* announce invitation by caller */ + +/* answer values */ +#define SUCCESS 0 /* operation completed properly */ +#define NOT_HERE 1 /* callee not logged in */ +#define FAILED 2 /* operation failed for unexplained reason */ +#define MACHINE_UNKNOWN 3 /* caller's machine name unknown */ +#define PERMISSION_DENIED 4 /* callee's tty doesn't permit announce */ +#define UNKNOWN_REQUEST 5 /* request has invalid type value */ +#define BADVERSION 6 /* request has invalid protocol version */ +#define BADADDR 7 /* request has invalid addr value */ +#define BADCTLADDR 8 /* request has invalid ctl_addr value */ + +/* + * Operational parameters. + */ +#define MAX_LIFE 60 /* max time daemon saves invitations */ +/* RING_WAIT should be 10's of seconds less than MAX_LIFE */ +#define RING_WAIT 30 /* time to wait before resending invitation */ + +#endif /* protocols/talkd.h */ diff --git a/conts/posix/libposix/include/posix/protocols/timed.h b/conts/posix/libposix/include/posix/protocols/timed.h new file mode 100644 index 0000000..4345bed --- /dev/null +++ b/conts/posix/libposix/include/posix/protocols/timed.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)timed.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _PROTOCOLS_TIMED_H +#define _PROTOCOLS_TIMED_H 1 + +#include + +/* + * Time Synchronization Protocol + */ + +#define TSPVERSION 1 +#define ANYADDR NULL + +struct tsp { + u_char tsp_type; + u_char tsp_vers; + u_short tsp_seq; + union { + struct timeval tspu_time; + char tspu_hopcnt; + } tsp_u; + char tsp_name[MAXHOSTNAMELEN]; +}; + +#define tsp_time tsp_u.tspu_time +#define tsp_hopcnt tsp_u.tspu_hopcnt + +/* + * Command types. + */ +#define TSP_ANY 0 /* match any types */ +#define TSP_ADJTIME 1 /* send adjtime */ +#define TSP_ACK 2 /* generic acknowledgement */ +#define TSP_MASTERREQ 3 /* ask for master's name */ +#define TSP_MASTERACK 4 /* acknowledge master request */ +#define TSP_SETTIME 5 /* send network time */ +#define TSP_MASTERUP 6 /* inform slaves that master is up */ +#define TSP_SLAVEUP 7 /* slave is up but not polled */ +#define TSP_ELECTION 8 /* advance candidature for master */ +#define TSP_ACCEPT 9 /* support candidature of master */ +#define TSP_REFUSE 10 /* reject candidature of master */ +#define TSP_CONFLICT 11 /* two or more masters present */ +#define TSP_RESOLVE 12 /* masters' conflict resolution */ +#define TSP_QUIT 13 /* reject candidature if master is up */ +#define TSP_DATE 14 /* reset the time (date command) */ +#define TSP_DATEREQ 15 /* remote request to reset the time */ +#define TSP_DATEACK 16 /* acknowledge time setting */ +#define TSP_TRACEON 17 /* turn tracing on */ +#define TSP_TRACEOFF 18 /* turn tracing off */ +#define TSP_MSITE 19 /* find out master's site */ +#define TSP_MSITEREQ 20 /* remote master's site request */ +#define TSP_TEST 21 /* for testing election algo */ +#define TSP_SETDATE 22 /* New from date command */ +#define TSP_SETDATEREQ 23 /* New remote for above */ +#define TSP_LOOP 24 /* loop detection packet */ + +#define TSPTYPENUMBER 25 + +#ifdef TSPTYPES +char *tsptype[TSPTYPENUMBER] = + { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP", + "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT", + "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ", + "TEST", "SETDATE", "SETDATEREQ", "LOOP" }; +#endif + +#endif /* protocols/timed.h */ diff --git a/conts/posix/libposix/include/posix/pty.h b/conts/posix/libposix/include/posix/pty.h new file mode 100644 index 0000000..2d4b5e2 --- /dev/null +++ b/conts/posix/libposix/include/posix/pty.h @@ -0,0 +1,44 @@ +/* Functions for pseudo TTY handling. + Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _PTY_H +#define _PTY_H 1 + +#include + +#include +#include + + +__BEGIN_DECLS + +/* Create pseudo tty master slave pair with NAME and set terminal + attributes according to TERMP and WINP and return handles for both + ends in AMASTER and ASLAVE. */ +extern int openpty (int *__amaster, int *__aslave, char *__name, + struct termios *__termp, struct winsize *__winp) __THROW; + +/* Create child process and establish the slave pseudo terminal as the + child's controlling terminal. */ +extern int forkpty (int *__amaster, char *__name, + struct termios *__termp, struct winsize *__winp) __THROW; + +__END_DECLS + +#endif /* pty.h */ diff --git a/conts/posix/libposix/include/posix/pwd.h b/conts/posix/libposix/include/posix/pwd.h new file mode 100644 index 0000000..e874133 --- /dev/null +++ b/conts/posix/libposix/include/posix/pwd.h @@ -0,0 +1,186 @@ +/* Copyright (C) 1991,1992,1995-2001,2003,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * POSIX Standard: 9.2.2 User Database Access + */ + +#ifndef _PWD_H +#define _PWD_H 1 + +#include + +__BEGIN_DECLS + +#include + +#define __need_size_t +#include + +#if defined __USE_XOPEN || defined __USE_XOPEN2K +/* The Single Unix specification says that some more types are + available here. */ +# ifndef __gid_t_defined +typedef __gid_t gid_t; +# define __gid_t_defined +# endif + +# ifndef __uid_t_defined +typedef __uid_t uid_t; +# define __uid_t_defined +# endif +#endif + +/* The passwd structure. */ +struct passwd +{ + char *pw_name; /* Username. */ + char *pw_passwd; /* Password. */ + __uid_t pw_uid; /* User ID. */ + __gid_t pw_gid; /* Group ID. */ + char *pw_gecos; /* Real name. */ + char *pw_dir; /* Home directory. */ + char *pw_shell; /* Shell program. */ +}; + + +#if defined __USE_SVID || defined __USE_GNU +# define __need_FILE +# include +#endif + + +#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN_EXTENDED +/* Rewind the password-file stream. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void setpwent (void); + +/* Close the password-file stream. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void endpwent (void); + +/* Read an entry from the password-file stream, opening it if necessary. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct passwd *getpwent (void); +#endif + +#ifdef __USE_SVID +/* Read an entry from STREAM. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern struct passwd *fgetpwent (FILE *__stream); + +/* Write the given entry onto the given stream. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int putpwent (__const struct passwd *__restrict __p, + FILE *__restrict __f); +#endif + +/* Search for an entry with a matching user ID. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct passwd *getpwuid (__uid_t __uid); + +/* Search for an entry with a matching username. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern struct passwd *getpwnam (__const char *__name); + +#if defined __USE_POSIX || defined __USE_MISC + +# ifdef __USE_MISC +/* Reasonable value for the buffer sized used in the reentrant + functions below. But better use `sysconf'. */ +# define NSS_BUFLEN_PASSWD 1024 +# endif + +/* Reentrant versions of some of the functions above. + + PLEASE NOTE: the `getpwent_r' function is not (yet) standardized. + The interface may change in later versions of this library. But + the interface is designed following the principals used for the + other reentrant functions so the chances are good this is what the + POSIX people would choose. */ + +# if defined __USE_SVID || defined __USE_MISC +/* This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int getpwent_r (struct passwd *__restrict __resultbuf, + char *__restrict __buffer, size_t __buflen, + struct passwd **__restrict __result); +# endif + +extern int getpwuid_r (__uid_t __uid, + struct passwd *__restrict __resultbuf, + char *__restrict __buffer, size_t __buflen, + struct passwd **__restrict __result); + +extern int getpwnam_r (__const char *__restrict __name, + struct passwd *__restrict __resultbuf, + char *__restrict __buffer, size_t __buflen, + struct passwd **__restrict __result); + + +# ifdef __USE_SVID +/* Read an entry from STREAM. This function is not standardized and + probably never will. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int fgetpwent_r (FILE *__restrict __stream, + struct passwd *__restrict __resultbuf, + char *__restrict __buffer, size_t __buflen, + struct passwd **__restrict __result); +# endif + +#endif /* POSIX or reentrant */ + +#ifdef __USE_GNU +/* Re-construct the password-file line for the given uid + in the given buffer. This knows the format that the caller + will expect, but this need not be the format of the password file. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int getpw (__uid_t __uid, char *__buffer); +#endif + +__END_DECLS + +#endif /* pwd.h */ diff --git a/conts/posix/libposix/include/posix/regex.h b/conts/posix/libposix/include/posix/regex.h new file mode 100644 index 0000000..2209f2b --- /dev/null +++ b/conts/posix/libposix/include/posix/regex.h @@ -0,0 +1,580 @@ +/* Definitions for data structures and routines for the regular + expression library. + Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _REGEX_H +#define _REGEX_H 1 + +#include + +/* Allow the use in C++ code. */ +#ifdef __cplusplus +extern "C" { +#endif + +/* POSIX says that must be included (by the caller) before + . */ + +#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS +/* VMS doesn't have `size_t' in , even though POSIX says it + should be there. */ +# include +#endif + +/* The following two types have to be signed and unsigned integer type + wide enough to hold a value of a pointer. For most ANSI compilers + ptrdiff_t and size_t should be likely OK. Still size of these two + types is 2 for Microsoft C. Ugh... */ +typedef long int s_reg_t; +typedef unsigned long int active_reg_t; + +/* The following bits are used to determine the regexp syntax we + recognize. The set/not-set meanings are chosen so that Emacs syntax + remains the value 0. The bits are given in alphabetical order, and + the definitions shifted by one from the previous bit; thus, when we + add or remove a bit, only one other definition need change. */ +typedef unsigned long int reg_syntax_t; + +/* If this bit is not set, then \ inside a bracket expression is literal. + If set, then such a \ quotes the following character. */ +#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1) + +/* If this bit is not set, then + and ? are operators, and \+ and \? are + literals. + If set, then \+ and \? are operators and + and ? are literals. */ +#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) + +/* If this bit is set, then character classes are supported. They are: + [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], + [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. + If not set, then character classes are not supported. */ +#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) + +/* If this bit is set, then ^ and $ are always anchors (outside bracket + expressions, of course). + If this bit is not set, then it depends: + ^ is an anchor if it is at the beginning of a regular + expression or after an open-group or an alternation operator; + $ is an anchor if it is at the end of a regular expression, or + before a close-group or an alternation operator. + + This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because + POSIX draft 11.2 says that * etc. in leading positions is undefined. + We already implemented a previous draft which made those constructs + invalid, though, so we haven't changed the code back. */ +#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) + +/* If this bit is set, then special characters are always special + regardless of where they are in the pattern. + If this bit is not set, then special characters are special only in + some contexts; otherwise they are ordinary. Specifically, + * + ? and intervals are only special when not after the beginning, + open-group, or alternation operator. */ +#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) + +/* If this bit is set, then *, +, ?, and { cannot be first in an re or + immediately after an alternation or begin-group operator. */ +#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) + +/* If this bit is set, then . matches newline. + If not set, then it doesn't. */ +#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) + +/* If this bit is set, then . doesn't match NUL. + If not set, then it does. */ +#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) + +/* If this bit is set, nonmatching lists [^...] do not match newline. + If not set, they do. */ +#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) + +/* If this bit is set, either \{...\} or {...} defines an + interval, depending on RE_NO_BK_BRACES. + If not set, \{, \}, {, and } are literals. */ +#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) + +/* If this bit is set, +, ? and | aren't recognized as operators. + If not set, they are. */ +#define RE_LIMITED_OPS (RE_INTERVALS << 1) + +/* If this bit is set, newline is an alternation operator. + If not set, newline is literal. */ +#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) + +/* If this bit is set, then `{...}' defines an interval, and \{ and \} + are literals. + If not set, then `\{...\}' defines an interval. */ +#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) + +/* If this bit is set, (...) defines a group, and \( and \) are literals. + If not set, \(...\) defines a group, and ( and ) are literals. */ +#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) + +/* If this bit is set, then \ matches . + If not set, then \ is a back-reference. */ +#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) + +/* If this bit is set, then | is an alternation operator, and \| is literal. + If not set, then \| is an alternation operator, and | is literal. */ +#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) + +/* If this bit is set, then an ending range point collating higher + than the starting range point, as in [z-a], is invalid. + If not set, then when ending range point collates higher than the + starting range point, the range is ignored. */ +#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) + +/* If this bit is set, then an unmatched ) is ordinary. + If not set, then an unmatched ) is invalid. */ +#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) + +/* If this bit is set, succeed as soon as we match the whole pattern, + without further backtracking. */ +#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1) + +/* If this bit is set, do not process the GNU regex operators. + If not set, then the GNU regex operators are recognized. */ +#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1) + +/* If this bit is set, turn on internal regex debugging. + If not set, and debugging was on, turn it off. + This only works if regex.c is compiled -DDEBUG. + We define this bit always, so that all that's needed to turn on + debugging is to recompile regex.c; the calling code can always have + this bit set, and it won't affect anything in the normal case. */ +#define RE_DEBUG (RE_NO_GNU_OPS << 1) + +/* If this bit is set, a syntactically invalid interval is treated as + a string of ordinary characters. For example, the ERE 'a{1' is + treated as 'a\{1'. */ +#define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1) + +/* If this bit is set, then ignore case when matching. + If not set, then case is significant. */ +#define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1) + +/* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only + for ^, because it is difficult to scan the regex backwards to find + whether ^ should be special. */ +#define RE_CARET_ANCHORS_HERE (RE_ICASE << 1) + +/* If this bit is set, then \{ cannot be first in an bre or + immediately after an alternation or begin-group operator. */ +#define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1) + +/* If this bit is set, then no_sub will be set to 1 during + re_compile_pattern. */ +#define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1) + +/* This global variable defines the particular regexp syntax to use (for + some interfaces). When a regexp is compiled, the syntax used is + stored in the pattern buffer, so changing this does not affect + already-compiled regexps. */ +extern reg_syntax_t re_syntax_options; + +/* Define combinations of the above bits for the standard possibilities. + (The [[[ comments delimit what gets put into the Texinfo file, so + don't delete them!) */ +/* [[[begin syntaxes]]] */ +#define RE_SYNTAX_EMACS 0 + +#define RE_SYNTAX_AWK \ + (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ + | RE_NO_BK_PARENS | RE_NO_BK_REFS \ + | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ + | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \ + | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS) + +#define RE_SYNTAX_GNU_AWK \ + ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \ + & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS \ + | RE_CONTEXT_INVALID_OPS )) + +#define RE_SYNTAX_POSIX_AWK \ + (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \ + | RE_INTERVALS | RE_NO_GNU_OPS) + +#define RE_SYNTAX_GREP \ + (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ + | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ + | RE_NEWLINE_ALT) + +#define RE_SYNTAX_EGREP \ + (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ + | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ + | RE_NO_BK_VBAR) + +#define RE_SYNTAX_POSIX_EGREP \ + (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \ + | RE_INVALID_INTERVAL_ORD) + +/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ +#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC + +#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC + +/* Syntax bits common to both basic and extended POSIX regex syntax. */ +#define _RE_SYNTAX_POSIX_COMMON \ + (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ + | RE_INTERVALS | RE_NO_EMPTY_RANGES) + +#define RE_SYNTAX_POSIX_BASIC \ + (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP) + +/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes + RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this + isn't minimal, since other operators, such as \`, aren't disabled. */ +#define RE_SYNTAX_POSIX_MINIMAL_BASIC \ + (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) + +#define RE_SYNTAX_POSIX_EXTENDED \ + (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ + | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ + | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD) + +/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is + removed and RE_NO_BK_REFS is added. */ +#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ + (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ + | RE_NO_BK_PARENS | RE_NO_BK_REFS \ + | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) +/* [[[end syntaxes]]] */ + +/* Maximum number of duplicates an interval can allow. Some systems + (erroneously) define this in other header files, but we want our + value, so remove any previous define. */ +#ifdef RE_DUP_MAX +# undef RE_DUP_MAX +#endif +/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */ +#define RE_DUP_MAX (0x7fff) + + +/* POSIX `cflags' bits (i.e., information for `regcomp'). */ + +/* If this bit is set, then use extended regular expression syntax. + If not set, then use basic regular expression syntax. */ +#define REG_EXTENDED 1 + +/* If this bit is set, then ignore case when matching. + If not set, then case is significant. */ +#define REG_ICASE (REG_EXTENDED << 1) + +/* If this bit is set, then anchors do not match at newline + characters in the string. + If not set, then anchors do match at newlines. */ +#define REG_NEWLINE (REG_ICASE << 1) + +/* If this bit is set, then report only success or fail in regexec. + If not set, then returns differ between not matching and errors. */ +#define REG_NOSUB (REG_NEWLINE << 1) + + +/* POSIX `eflags' bits (i.e., information for regexec). */ + +/* If this bit is set, then the beginning-of-line operator doesn't match + the beginning of the string (presumably because it's not the + beginning of a line). + If not set, then the beginning-of-line operator does match the + beginning of the string. */ +#define REG_NOTBOL 1 + +/* Like REG_NOTBOL, except for the end-of-line. */ +#define REG_NOTEOL (1 << 1) + +/* Use PMATCH[0] to delimit the start and end of the search in the + buffer. */ +#define REG_STARTEND (1 << 2) + + +/* If any error codes are removed, changed, or added, update the + `re_error_msg' table in regex.c. */ +typedef enum +{ +#ifdef _XOPEN_SOURCE + REG_ENOSYS = -1, /* This will never happen for this implementation. */ +#endif + + REG_NOERROR = 0, /* Success. */ + REG_NOMATCH, /* Didn't find a match (for regexec). */ + + /* POSIX regcomp return error codes. (In the order listed in the + standard.) */ + REG_BADPAT, /* Invalid pattern. */ + REG_ECOLLATE, /* Invalid collating element. */ + REG_ECTYPE, /* Invalid character class name. */ + REG_EESCAPE, /* Trailing backslash. */ + REG_ESUBREG, /* Invalid back reference. */ + REG_EBRACK, /* Unmatched left bracket. */ + REG_EPAREN, /* Parenthesis imbalance. */ + REG_EBRACE, /* Unmatched \{. */ + REG_BADBR, /* Invalid contents of \{\}. */ + REG_ERANGE, /* Invalid range end. */ + REG_ESPACE, /* Ran out of memory. */ + REG_BADRPT, /* No preceding re for repetition op. */ + + /* Error codes we've added. */ + REG_EEND, /* Premature end. */ + REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ + REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ +} reg_errcode_t; + +/* This data structure represents a compiled pattern. Before calling + the pattern compiler, the fields `buffer', `allocated', `fastmap', + `translate', and `no_sub' can be set. After the pattern has been + compiled, the `re_nsub' field is available. All other fields are + private to the regex routines. */ + +#ifndef RE_TRANSLATE_TYPE +# define RE_TRANSLATE_TYPE unsigned char * +#endif + +struct re_pattern_buffer +{ + /* Space that holds the compiled pattern. It is declared as + `unsigned char *' because its elements are sometimes used as + array indexes. */ + unsigned char *buffer; + + /* Number of bytes to which `buffer' points. */ + unsigned long int allocated; + + /* Number of bytes actually used in `buffer'. */ + unsigned long int used; + + /* Syntax setting with which the pattern was compiled. */ + reg_syntax_t syntax; + + /* Pointer to a fastmap, if any, otherwise zero. re_search uses the + fastmap, if there is one, to skip over impossible starting points + for matches. */ + char *fastmap; + + /* Either a translate table to apply to all characters before + comparing them, or zero for no translation. The translation is + applied to a pattern when it is compiled and to a string when it + is matched. */ + RE_TRANSLATE_TYPE translate; + + /* Number of subexpressions found by the compiler. */ + size_t re_nsub; + + /* Zero if this pattern cannot match the empty string, one else. + Well, in truth it's used only in `re_search_2', to see whether or + not we should use the fastmap, so we don't set this absolutely + perfectly; see `re_compile_fastmap' (the `duplicate' case). */ + unsigned can_be_null : 1; + + /* If REGS_UNALLOCATED, allocate space in the `regs' structure + for `max (RE_NREGS, re_nsub + 1)' groups. + If REGS_REALLOCATE, reallocate space if necessary. + If REGS_FIXED, use what's there. */ +#define REGS_UNALLOCATED 0 +#define REGS_REALLOCATE 1 +#define REGS_FIXED 2 + unsigned regs_allocated : 2; + + /* Set to zero when `regex_compile' compiles a pattern; set to one + by `re_compile_fastmap' if it updates the fastmap. */ + unsigned fastmap_accurate : 1; + + /* If set, `re_match_2' does not return information about + subexpressions. */ + unsigned no_sub : 1; + + /* If set, a beginning-of-line anchor doesn't match at the beginning + of the string. */ + unsigned not_bol : 1; + + /* Similarly for an end-of-line anchor. */ + unsigned not_eol : 1; + + /* If true, an anchor at a newline matches. */ + unsigned newline_anchor : 1; +}; + +typedef struct re_pattern_buffer regex_t; + +/* Type for byte offsets within the string. POSIX mandates this. */ +typedef int regoff_t; + + +/* This is the structure we store register match data in. See + regex.texinfo for a full description of what registers match. */ +struct re_registers +{ + unsigned num_regs; + regoff_t *start; + regoff_t *end; +}; + + +/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, + `re_match_2' returns information about at least this many registers + the first time a `regs' structure is passed. */ +#ifndef RE_NREGS +# define RE_NREGS 30 +#endif + + +/* POSIX specification for registers. Aside from the different names than + `re_registers', POSIX uses an array of structures, instead of a + structure of arrays. */ +typedef struct +{ + regoff_t rm_so; /* Byte offset from string's start to substring's start. */ + regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ +} regmatch_t; + +/* Declarations for routines. */ + +/* To avoid duplicating every routine declaration -- once with a + prototype (if we are ANSI), and once without (if we aren't) -- we + use the following macro to declare argument types. This + unfortunately clutters up the declarations a bit, but I think it's + worth it. */ + +#if __STDC__ + +# define _RE_ARGS(args) args + +#else /* not __STDC__ */ + +# define _RE_ARGS(args) () + +#endif /* not __STDC__ */ + +/* Sets the current default syntax to SYNTAX, and return the old syntax. + You can also simply assign to the `re_syntax_options' variable. */ +extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t __syntax)); + +/* Compile the regular expression PATTERN, with length LENGTH + and syntax given by the global `re_syntax_options', into the buffer + BUFFER. Return NULL if successful, and an error string if not. */ +extern const char *re_compile_pattern _RE_ARGS ((const char *__pattern, size_t __length, + struct re_pattern_buffer *__buffer)); + + +/* Compile a fastmap for the compiled pattern in BUFFER; used to + accelerate searches. Return 0 if successful and -2 if was an + internal error. */ +extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *__buffer)); + + +/* Search in the string STRING (with length LENGTH) for the pattern + compiled into BUFFER. Start searching at position START, for RANGE + characters. Return the starting position of the match, -1 for no + match, or -2 for an internal error. Also return register + information in REGS (if REGS and BUFFER->no_sub are nonzero). */ +extern int re_search _RE_ARGS ((struct re_pattern_buffer *__buffer, const char *__string, + int __length, int __start, int __range, + struct re_registers *__regs)); + + +/* Like `re_search', but search in the concatenation of STRING1 and + STRING2. Also, stop searching at index START + STOP. */ +extern int re_search_2 _RE_ARGS ((struct re_pattern_buffer *__buffer, + const char *__string1, int __length1, + const char *__string2, int __length2, int __start, + int __range, struct re_registers *__regs, int __stop)); + + +/* Like `re_search', but return how many characters in STRING the regexp + in BUFFER matched, starting at position START. */ +extern int re_match _RE_ARGS ((struct re_pattern_buffer *__buffer, const char *__string, + int __length, int __start, struct re_registers *__regs)); + + +/* Relates to `re_match' as `re_search_2' relates to `re_search'. */ +extern int re_match_2 _RE_ARGS ((struct re_pattern_buffer *__buffer, + const char *__string1, int __length1, + const char *__string2, int __length2, int __start, + struct re_registers *__regs, int __stop)); + + +/* Set REGS to hold NUM_REGS registers, storing them in STARTS and + ENDS. Subsequent matches using BUFFER and REGS will use this memory + for recording register information. STARTS and ENDS must be + allocated with malloc, and must each be at least `NUM_REGS * sizeof + (regoff_t)' bytes long. + + If NUM_REGS == 0, then subsequent matches should allocate their own + register data. + + Unless this function is called, the first search or match using + PATTERN_BUFFER will allocate its own register data, without + freeing the old data. */ +extern void re_set_registers _RE_ARGS ((struct re_pattern_buffer *__buffer, + struct re_registers *__regs, + unsigned int __num_regs, + regoff_t *__starts, regoff_t *__ends)); + +#if defined _REGEX_RE_COMP || defined _LIBC +# ifndef _CRAY +/* 4.2 bsd compatibility. */ +extern char *re_comp _RE_ARGS ((const char *)); +extern int re_exec _RE_ARGS ((const char *)); +# endif +#endif + +/* GCC 2.95 and later have "__restrict"; C99 compilers have + "restrict", and "configure" may have defined "restrict". */ +#ifndef __restrict +# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)) +# if defined restrict || 199901L <= __STDC_VERSION__ +# define __restrict restrict +# else +# define __restrict +# endif +# endif +#endif +/* gcc 3.1 and up support the [restrict] syntax. */ +#ifndef __restrict_arr +# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +# define __restrict_arr __restrict +# else +# define __restrict_arr +# endif +#endif + +/* POSIX compatibility. */ +extern int regcomp _RE_ARGS ((regex_t *__restrict __preg, + const char *__restrict __pattern, + int __cflags)); + +extern int regexec _RE_ARGS ((const regex_t *__restrict __preg, + const char *__restrict __string, size_t __nmatch, + regmatch_t __pmatch[__restrict_arr], + int __eflags)); + +extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__restrict __preg, + char *__restrict __errbuf, size_t __errbuf_size)); + +extern void regfree _RE_ARGS ((regex_t *__preg)); + + +#ifdef __cplusplus +} +#endif /* C++ */ + +#endif /* regex.h */ diff --git a/conts/posix/libposix/include/posix/regexp.h b/conts/posix/libposix/include/posix/regexp.h new file mode 100644 index 0000000..b7b50b7 --- /dev/null +++ b/conts/posix/libposix/include/posix/regexp.h @@ -0,0 +1,222 @@ +/* Copyright (C) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1996. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _REGEXP_H +#define _REGEXP_H 1 + +/* The contents of this header file was first standardized in X/Open + System Interface and Headers Issue 2, originally coming from SysV. + In issue 4, version 2, it is marked as TO BE WITDRAWN, and it has + been withdrawn in SUSv3. + + This code shouldn't be used in any newly written code. It is + included only for compatibility reasons. Use the POSIX definition + in for portable applications and a reasonable interface. */ + +#include +#include +#include +#include +#include + +/* The implementation provided here emulates the needed functionality + by mapping to the POSIX regular expression matcher. The interface + for the here included function is weird (this really is a harmless + word). + + The user has to provide six macros before this header file can be + included: + + INIT Declarations vor variables which can be used by the + other macros. + + GETC() Return the value of the next character in the regular + expression pattern. Successive calls should return + successive characters. + + PEEKC() Return the value of the next character in the regular + expression pattern. Immediately successive calls to + PEEKC() should return the same character which should + also be the next character returned by GETC(). + + UNGETC(c) Cause `c' to be returned by the next call to GETC() and + PEEKC(). + + RETURN(ptr) Used for normal exit of the `compile' function. `ptr' + is a pointer to the character after the last character of + the compiled regular expression. + + ERROR(val) Used for abnormal return from `compile'. `val' is the + error number. The error codes are: + 11 Range endpoint too large. + 16 Bad number. + 25 \digit out of range. + 36 Illegal or missing delimiter. + 41 No remembered search string. + 42 \( \) imbalance. + 43 Too many \(. + 44 More tan two numbers given in \{ \}. + 45 } expected after \. + 46 First number exceeds second in \{ \}. + 49 [ ] imbalance. + 50 Regular expression overflow. + + */ + +__BEGIN_DECLS + +/* Interface variables. They contain the results of the successful + calls to `setp' and `advance'. */ +extern char *loc1; +extern char *loc2; + +/* The use of this variable in the `advance' function is not + supported. */ +extern char *locs; + + +#ifndef __DO_NOT_DEFINE_COMPILE +/* Get and compile the user supplied pattern up to end of line or + string or until EOF is seen, whatever happens first. The result is + placed in the buffer starting at EXPBUF and delimited by ENDBUF. + + This function cannot be defined in the libc itself since it depends + on the macros. */ +char * +compile (char *__restrict instring, char *__restrict expbuf, + __const char *__restrict endbuf, int eof) +{ + char *__input_buffer = NULL; + size_t __input_size = 0; + size_t __current_size = 0; + int __ch; + int __error; + INIT + + /* Align the expression buffer according to the needs for an object + of type `regex_t'. Then check for minimum size of the buffer for + the compiled regular expression. */ + regex_t *__expr_ptr; +# if defined __GNUC__ && __GNUC__ >= 2 + const size_t __req = __alignof__ (regex_t *); +# else + /* How shall we find out? We simply guess it and can change it is + this really proofs to be wrong. */ + const size_t __req = 8; +# endif + expbuf += __req; + expbuf -= (expbuf - ((char *) 0)) % __req; + if (endbuf < expbuf + sizeof (regex_t)) + { + ERROR (50); + } + __expr_ptr = (regex_t *) expbuf; + /* The remaining space in the buffer can be used for the compiled + pattern. */ + __expr_ptr->buffer = expbuf + sizeof (regex_t); + __expr_ptr->allocated = endbuf - (char *) __expr_ptr->buffer; + + while ((__ch = (GETC ())) != eof) + { + if (__ch == '\0' || __ch == '\n') + { + UNGETC (__ch); + break; + } + + if (__current_size + 1 >= __input_size) + { + size_t __new_size = __input_size ? 2 * __input_size : 128; + char *__new_room = (char *) alloca (__new_size); + /* See whether we can use the old buffer. */ + if (__new_room + __new_size == __input_buffer) + { + __input_size += __new_size; + __input_buffer = (char *) memcpy (__new_room, __input_buffer, + __current_size); + } + else if (__input_buffer + __input_size == __new_room) + __input_size += __new_size; + else + { + __input_size = __new_size; + __input_buffer = (char *) memcpy (__new_room, __input_buffer, + __current_size); + } + } + __input_buffer[__current_size++] = __ch; + } + __input_buffer[__current_size++] = '\0'; + + /* Now compile the pattern. */ + __error = regcomp (__expr_ptr, __input_buffer, REG_NEWLINE); + if (__error != 0) + /* Oh well, we have to translate POSIX error codes. */ + switch (__error) + { + case REG_BADPAT: + case REG_ECOLLATE: + case REG_ECTYPE: + case REG_EESCAPE: + case REG_BADRPT: + case REG_EEND: + case REG_ERPAREN: + default: + /* There is no matching error code. */ + RETURN (36); + case REG_ESUBREG: + RETURN (25); + case REG_EBRACK: + RETURN (49); + case REG_EPAREN: + RETURN (42); + case REG_EBRACE: + RETURN (44); + case REG_BADBR: + RETURN (46); + case REG_ERANGE: + RETURN (11); + case REG_ESPACE: + case REG_ESIZE: + ERROR (50); + } + + /* Everything is ok. */ + RETURN ((char *) (__expr_ptr->buffer + __expr_ptr->used)); +} +#endif + + +/* Find the next match in STRING. The compiled regular expression is + found in the buffer starting at EXPBUF. `loc1' will return the + first character matched and `loc2' points to the next unmatched + character. */ +extern int step (__const char *__restrict __string, + __const char *__restrict __expbuf) __THROW; + +/* Match the beginning of STRING with the compiled regular expression + in EXPBUF. If the match is successful `loc2' will contain the + position of the first unmatched character. */ +extern int advance (__const char *__restrict __string, + __const char *__restrict __expbuf) __THROW; + + +__END_DECLS + +#endif /* regexp.h */ diff --git a/conts/posix/libposix/include/posix/resolv.h b/conts/posix/libposix/include/posix/resolv.h new file mode 100644 index 0000000..3434f5d --- /dev/null +++ b/conts/posix/libposix/include/posix/resolv.h @@ -0,0 +1,395 @@ +/* + * Copyright (c) 1983, 1987, 1989 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Portions Copyright (c) 1996-1999 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + * @(#)resolv.h 8.1 (Berkeley) 6/2/93 + * $BINDId: resolv.h,v 8.31 2000/03/30 20:16:50 vixie Exp $ + */ + +#ifndef _RESOLV_H_ + +/* These headers are needed for types used in the `struct res_state' + declaration. */ +#include +#include + +#ifndef __need_res_state +# define _RESOLV_H_ + +# include +# include +# include +# include +#endif + +#ifndef __res_state_defined +# define __res_state_defined + +typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error } + res_sendhookact; + +typedef res_sendhookact (*res_send_qhook) (struct sockaddr_in * const *ns, + const u_char **query, + int *querylen, + u_char *ans, + int anssiz, + int *resplen); + +typedef res_sendhookact (*res_send_rhook) (const struct sockaddr_in *ns, + const u_char *query, + int querylen, + u_char *ans, + int anssiz, + int *resplen); + +/* + * Global defines and variables for resolver stub. + */ +# define MAXNS 3 /* max # name servers we'll track */ +# define MAXDFLSRCH 3 /* # default domain levels to try */ +# define MAXDNSRCH 6 /* max # domains in search path */ +# define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */ + +# define RES_TIMEOUT 5 /* min. seconds between retries */ +# define MAXRESOLVSORT 10 /* number of net to sort on */ +# define RES_MAXNDOTS 15 /* should reflect bit field size */ +# define RES_MAXRETRANS 30 /* only for resolv.conf/RES_OPTIONS */ +# define RES_MAXRETRY 5 /* only for resolv.conf/RES_OPTIONS */ +# define RES_DFLRETRY 2 /* Default #/tries. */ +# define RES_MAXTIME 65535 /* Infinity, in milliseconds. */ + +struct __res_state { + int retrans; /* retransmition time interval */ + int retry; /* number of times to retransmit */ + u_long options; /* option flags - see below. */ + int nscount; /* number of name servers */ + struct sockaddr_in + nsaddr_list[MAXNS]; /* address of name server */ +# define nsaddr nsaddr_list[0] /* for backward compatibility */ + u_short id; /* current message id */ + char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ + char defdname[256]; /* default domain (deprecated) */ + u_long pfcode; /* RES_PRF_ flags - see below. */ + unsigned ndots:4; /* threshold for initial abs. query */ + unsigned nsort:4; /* number of elements in sort_list[] */ + char unused[3]; + struct { + struct in_addr addr; + u_int32_t mask; + } sort_list[MAXRESOLVSORT]; + res_send_qhook qhook; /* query hook */ + res_send_rhook rhook; /* response hook */ + int res_h_errno; /* last one set for this context */ + int _vcsock; /* PRIVATE: for res_send VC i/o */ + u_int _flags; /* PRIVATE: see below */ + union { + char pad[52]; /* On an i386 this means 512b total. */ + struct { + u_int16_t nscount; +#if 0 + u_int16_t nsmap[MAXNS]; +#else + u_int16_t nstimes[MAXNS]; /* ms. */ +#endif + int nssocks[MAXNS]; + u_int16_t nscount6; + u_int16_t nsinit; + struct sockaddr_in6 *nsaddrs[MAXNS]; +#if 0 +#ifdef _LIBC + unsigned long long int initstamp + __attribute__((packed)); +#else + unsigned int _initstamp[2]; +#endif +#endif + } _ext; + } _u; +}; + +typedef struct __res_state *res_state; +# undef __need_res_state +#endif + +#ifdef _RESOLV_H_ +/* + * Revision information. This is the release date in YYYYMMDD format. + * It can change every day so the right thing to do with it is use it + * in preprocessor commands such as "#if (__RES > 19931104)". Do not + * compare for equality; rather, use it to determine whether your resolver + * is new enough to contain a certain feature. + */ + +#if 0 +#define __RES 19991006 +#else +#define __RES 19960801 +#endif + +/* + * Resolver configuration file. + * Normally not present, but may contain the address of the + * inital name server(s) to query and the domain search list. + */ + +#ifndef _PATH_RESCONF +#define _PATH_RESCONF "/etc/resolv.conf" +#endif + +struct res_sym { + int number; /* Identifying number, like T_MX */ + char * name; /* Its symbolic name, like "MX" */ + char * humanname; /* Its fun name, like "mail exchanger" */ +}; + +/* + * Resolver flags (used to be discrete per-module statics ints). + */ +#define RES_F_VC 0x00000001 /* socket is TCP */ +#define RES_F_CONN 0x00000002 /* socket is connected */ + +/* res_findzonecut() options */ +#define RES_EXHAUSTIVE 0x00000001 /* always do all queries */ + +/* + * Resolver options (keep these in synch with res_debug.c, please) + */ +#define RES_INIT 0x00000001 /* address initialized */ +#define RES_DEBUG 0x00000002 /* print debug messages */ +#define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/ +#define RES_USEVC 0x00000008 /* use virtual circuit */ +#define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */ +#define RES_IGNTC 0x00000020 /* ignore trucation errors */ +#define RES_RECURSE 0x00000040 /* recursion desired */ +#define RES_DEFNAMES 0x00000080 /* use default domain name */ +#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */ +#define RES_DNSRCH 0x00000200 /* search up local domain tree */ +#define RES_INSECURE1 0x00000400 /* type 1 security disabled */ +#define RES_INSECURE2 0x00000800 /* type 2 security disabled */ +#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */ +#define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */ +#define RES_ROTATE 0x00004000 /* rotate ns list after each query */ +#define RES_NOCHECKNAME 0x00008000 /* do not check names for sanity. */ +#define RES_KEEPTSIG 0x00010000 /* do not strip TSIG records */ +#define RES_BLAST 0x00020000 /* blast all recursive servers */ +#if 0 +#define RES_USEBSTRING 0x00040000 /* IPv6 reverse lookup with byte + strings */ +#define RES_NOIP6DOTINT 0x00080000 /* Do not use .ip6.int in IPv6 + reverse lookup */ + +#define RES_DEFAULT (RES_RECURSE|RES_DEFNAMES|RES_DNSRCH|RES_NOIP6DOTINT) +#else +#define RES_DEFAULT (RES_RECURSE|RES_DEFNAMES|RES_DNSRCH) +#endif + +/* + * Resolver "pfcode" values. Used by dig. + */ +#define RES_PRF_STATS 0x00000001 +#define RES_PRF_UPDATE 0x00000002 +#define RES_PRF_CLASS 0x00000004 +#define RES_PRF_CMD 0x00000008 +#define RES_PRF_QUES 0x00000010 +#define RES_PRF_ANS 0x00000020 +#define RES_PRF_AUTH 0x00000040 +#define RES_PRF_ADD 0x00000080 +#define RES_PRF_HEAD1 0x00000100 +#define RES_PRF_HEAD2 0x00000200 +#define RES_PRF_TTLID 0x00000400 +#define RES_PRF_HEADX 0x00000800 +#define RES_PRF_QUERY 0x00001000 +#define RES_PRF_REPLY 0x00002000 +#define RES_PRF_INIT 0x00004000 +/* 0x00008000 */ + +/* Things involving an internal (static) resolver context. */ +#if 0 +__BEGIN_DECLS +extern struct __res_state *__res_state(void) __attribute__ ((__const__)); +__END_DECLS +#define _res (*__res_state()) +#else +extern struct __res_state _res; +#endif + +#define fp_nquery __fp_nquery +#define fp_query __fp_query +#define hostalias __hostalias +#define p_query __p_query +#define res_close __res_close +#define res_init __res_init +#define res_isourserver __res_isourserver +#define res_mkquery __res_mkquery +#define res_query __res_query +#define res_querydomain __res_querydomain +#define res_search __res_search +#define res_send __res_send + +__BEGIN_DECLS +void fp_nquery (const u_char *, int, FILE *) __THROW; +void fp_query (const u_char *, FILE *) __THROW; +const char * hostalias (const char *) __THROW; +void p_query (const u_char *) __THROW; +#ifdef __UCLIBC_HAS_BSD_RES_CLOSE__ +void res_close (void) __THROW; +#endif +int res_init (void) __THROW; +int res_isourserver (const struct sockaddr_in *) __THROW; +int res_mkquery (int, const char *, int, int, const u_char *, + int, const u_char *, u_char *, int) __THROW; +int res_query (const char *, int, int, u_char *, int) __THROW; +int res_querydomain (const char *, const char *, int, int, + u_char *, int) __THROW; +int res_search (const char *, int, int, u_char *, int) __THROW; +int res_send (const u_char *, int, u_char *, int) __THROW; +__END_DECLS + +#define b64_ntop __b64_ntop +#define b64_pton __b64_pton +#define dn_comp __dn_comp +#define dn_count_labels __dn_count_labels +#define dn_expand __dn_expand +#define dn_skipname __dn_skipname +#define fp_resstat __fp_resstat +#define loc_aton __loc_aton +#define loc_ntoa __loc_ntoa +#define p_cdname __p_cdname +#define p_cdnname __p_cdnname +#define p_class __p_class +#define p_fqname __p_fqname +#define p_fqnname __p_fqnname +#define p_option __p_option +#define p_secstodate __p_secstodate +#define p_section __p_section +#define p_time __p_time +#define p_type __p_type +#define p_rcode __p_rcode +#define putlong __putlong +#define putshort __putshort +#define res_dnok __res_dnok +#define res_hnok __res_hnok +#define res_hostalias __res_hostalias +#define res_mailok __res_mailok +#define res_nameinquery __res_nameinquery +#define res_nclose __res_nclose +#define res_ninit __res_ninit +#define res_nmkquery __res_nmkquery +#define res_npquery __res_npquery +#define res_nquery __res_nquery +#define res_nquerydomain __res_nquerydomain +#define res_nsearch __res_nsearch +#define res_nsend __res_nsend +#define res_nisourserver __res_nisourserver +#define res_ownok __res_ownok +#define res_queriesmatch __res_queriesmatch +#define res_randomid __res_randomid +#define sym_ntop __sym_ntop +#define sym_ntos __sym_ntos +#define sym_ston __sym_ston +__BEGIN_DECLS +int res_hnok (const char *) __THROW; +int res_ownok (const char *) __THROW; +int res_mailok (const char *) __THROW; +int res_dnok (const char *) __THROW; +int sym_ston (const struct res_sym *, const char *, int *) __THROW; +const char * sym_ntos (const struct res_sym *, int, int *) __THROW; +const char * sym_ntop (const struct res_sym *, int, int *) __THROW; +int b64_ntop (u_char const *, size_t, char *, size_t) __THROW; +int b64_pton (char const *, u_char *, size_t) __THROW; +int loc_aton (const char *ascii, u_char *binary) __THROW; +const char * loc_ntoa (const u_char *binary, char *ascii) __THROW; +int dn_skipname (const u_char *, const u_char *) __THROW; +void putlong (u_int32_t, u_char *) __THROW; +void putshort (u_int16_t, u_char *) __THROW; +const char * p_class (int) __THROW; +const char * p_time (u_int32_t) __THROW; +const char * p_type (int) __THROW; +const char * p_rcode (int) __THROW; +const u_char * p_cdnname (const u_char *, const u_char *, int, FILE *) + __THROW; +const u_char * p_cdname (const u_char *, const u_char *, FILE *) __THROW; +const u_char * p_fqnname (const u_char *cp, const u_char *msg, + int, char *, int) __THROW; +const u_char * p_fqname (const u_char *, const u_char *, FILE *) __THROW; +const char * p_option (u_long option) __THROW; +char * p_secstodate (u_long) __THROW; +int dn_count_labels (const char *) __THROW; +int dn_comp (const char *, u_char *, int, u_char **, u_char **) + __THROW; +int dn_expand (const u_char *, const u_char *, const u_char *, + char *, int) __THROW; +u_int res_randomid (void) __THROW; +int res_nameinquery (const char *, int, int, + const u_char *, const u_char *) __THROW; +int res_queriesmatch (const u_char *, const u_char *, + const u_char *, const u_char *) __THROW; +const char * p_section (int section, int opcode) __THROW; +/* Things involving a resolver context. */ +int res_ninit (res_state) __THROW; +int res_nisourserver (const res_state, + const struct sockaddr_in *) __THROW; +void fp_resstat (const res_state, FILE *) __THROW; +void res_npquery (const res_state, const u_char *, int, FILE *) + __THROW; +const char * res_hostalias (const res_state, const char *, char *, size_t) + __THROW; +int res_nquery (res_state, const char *, int, int, u_char *, int) + __THROW; +int res_nsearch (res_state, const char *, int, int, u_char *, int) + __THROW; +int res_nquerydomain (res_state, const char *, const char *, int, + int, u_char *, int) __THROW; +int res_nmkquery (res_state, int, const char *, int, int, + const u_char *, int, const u_char *, u_char *, + int) __THROW; +int res_nsend (res_state, const u_char *, int, u_char *, int) + __THROW; +void res_nclose (res_state) __THROW; +__END_DECLS +#endif + +#endif /* !_RESOLV_H_ */ diff --git a/conts/posix/libposix/include/posix/rpc/auth.h b/conts/posix/libposix/include/posix/rpc/auth.h new file mode 100644 index 0000000..17eb59f --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/auth.h @@ -0,0 +1,224 @@ +/* @(#)auth.h 2.3 88/08/07 4.0 RPCSRC; from 1.17 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * auth.h, Authentication interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * The data structures are completely opaque to the client. The client + * is required to pass a AUTH * to routines that create rpc + * "sessions". + */ + +#ifndef _RPC_AUTH_H + +#define _RPC_AUTH_H 1 +#ifdef _LIBC +/* Some adjustments to make the libc source from glibc + * compile more easily with uClibc... */ +#ifndef __FORCE_GLIBC +#define __FORCE_GLIBC +#endif +#ifndef _GNU_SOUCE +#define _GNU_SOUCE +#endif +#define _(X) X +#endif +#include +#include + +__BEGIN_DECLS + +#define MAX_AUTH_BYTES 400 +#define MAXNETNAMELEN 255 /* maximum length of network user's name */ + +/* + * Status returned from authentication check + */ +enum auth_stat { + AUTH_OK=0, + /* + * failed at remote end + */ + AUTH_BADCRED=1, /* bogus credentials (seal broken) */ + AUTH_REJECTEDCRED=2, /* client should begin new session */ + AUTH_BADVERF=3, /* bogus verifier (seal broken) */ + AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ + AUTH_TOOWEAK=5, /* rejected due to security reasons */ + /* + * failed locally + */ + AUTH_INVALIDRESP=6, /* bogus response verifier */ + AUTH_FAILED=7 /* some unknown reason */ +}; + +union des_block { + struct { + u_int32_t high; + u_int32_t low; + } key; + char c[8]; +}; +typedef union des_block des_block; +extern bool_t xdr_des_block (XDR *__xdrs, des_block *__blkp) __THROW; + +/* + * Authentication info. Opaque to client. + */ +struct opaque_auth { + enum_t oa_flavor; /* flavor of auth */ + caddr_t oa_base; /* address of more auth stuff */ + u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ +}; + +/* + * Auth handle, interface to client side authenticators. + */ +typedef struct AUTH AUTH; +struct AUTH { + struct opaque_auth ah_cred; + struct opaque_auth ah_verf; + union des_block ah_key; + struct auth_ops { + void (*ah_nextverf) (AUTH *); + int (*ah_marshal) (AUTH *, XDR *); /* nextverf & serialize */ + int (*ah_validate) (AUTH *, struct opaque_auth *); + /* validate verifier */ + int (*ah_refresh) (AUTH *); /* refresh credentials */ + void (*ah_destroy) (AUTH *); /* destroy this structure */ + } *ah_ops; + caddr_t ah_private; +}; + + +/* + * Authentication ops. + * The ops and the auth handle provide the interface to the authenticators. + * + * AUTH *auth; + * XDR *xdrs; + * struct opaque_auth verf; + */ +#define AUTH_NEXTVERF(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) +#define auth_nextverf(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) + +#define AUTH_MARSHALL(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) +#define auth_marshall(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) + +#define AUTH_VALIDATE(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) +#define auth_validate(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) + +#define AUTH_REFRESH(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) +#define auth_refresh(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) + +#define AUTH_DESTROY(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) +#define auth_destroy(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) + + +extern struct opaque_auth _null_auth; + + +/* + * These are the various implementations of client side authenticators. + */ + +/* + * Unix style authentication + * AUTH *authunix_create(machname, uid, gid, len, aup_gids) + * char *machname; + * int uid; + * int gid; + * int len; + * int *aup_gids; + */ +extern AUTH *authunix_create (char *__machname, __uid_t __uid, __gid_t __gid, + int __len, __gid_t *__aup_gids); +extern AUTH *authunix_create_default (void); +extern AUTH *authnone_create (void) __THROW; +extern AUTH *authdes_create (const char *__servername, u_int __window, + struct sockaddr *__syncaddr, des_block *__ckey) + __THROW; +extern AUTH *authdes_pk_create (const char *, netobj *, u_int, + struct sockaddr *, des_block *) __THROW; + + +#define AUTH_NONE 0 /* no authentication */ +#define AUTH_NULL 0 /* backward compatibility */ +#define AUTH_SYS 1 /* unix style (uid, gids) */ +#define AUTH_UNIX AUTH_SYS +#define AUTH_SHORT 2 /* short hand unix style */ +#define AUTH_DES 3 /* des style (encrypted timestamps) */ +#define AUTH_DH AUTH_DES /* Diffie-Hellman (this is DES) */ +#define AUTH_KERB 4 /* kerberos style */ + +/* + * Netname manipulating functions + * + */ +extern int getnetname (char *) __THROW; +extern int host2netname (char *, __const char *, __const char *) __THROW; +extern int user2netname (char *, __const uid_t, __const char *) __THROW; +extern int netname2user (__const char *, uid_t *, gid_t *, int *, gid_t *) + __THROW; +extern int netname2host (__const char *, char *, __const int) __THROW; + +/* + * + * These routines interface to the keyserv daemon + * + */ +extern int key_decryptsession (char *, des_block *); +extern int key_decryptsession_pk (char *, netobj *, des_block *); +extern int key_encryptsession (char *, des_block *); +extern int key_encryptsession_pk (char *, netobj *, des_block *); +extern int key_gendes (des_block *); +extern int key_setsecret (char *); +extern int key_secretkey_is_set (void); +extern int key_get_conv (char *, des_block *); + +/* + * XDR an opaque authentication struct. + */ +extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *) __THROW; + +__END_DECLS + +#endif /* rpc/auth.h */ diff --git a/conts/posix/libposix/include/posix/rpc/auth_des.h b/conts/posix/libposix/include/posix/rpc/auth_des.h new file mode 100644 index 0000000..12ada84 --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/auth_des.h @@ -0,0 +1,112 @@ +/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _RPC_AUTH_DES_H +#define _RPC_AUTH_DES_H 1 + +#include +#include + +__BEGIN_DECLS + +/* There are two kinds of "names": fullnames and nicknames */ +enum authdes_namekind + { + ADN_FULLNAME, + ADN_NICKNAME + }; + +/* A fullname contains the network name of the client, + a conversation key and the window */ +struct authdes_fullname + { + char *name; /* network name of client, up to MAXNETNAMELEN */ + des_block key; /* conversation key */ + uint32_t window; /* associated window */ + }; + +/* A credential */ +struct authdes_cred + { + enum authdes_namekind adc_namekind; + struct authdes_fullname adc_fullname; + uint32_t adc_nickname; + }; + +/* A timeval replacement for !32bit platforms */ +struct rpc_timeval + { + uint32_t tv_sec; /* Seconds. */ + uint32_t tv_usec; /* Microseconds. */ + }; + +/* A des authentication verifier */ +struct authdes_verf + { + union + { + struct rpc_timeval adv_ctime; /* clear time */ + des_block adv_xtime; /* crypt time */ + } + adv_time_u; + uint32_t adv_int_u; + }; + +/* des authentication verifier: client variety + + adv_timestamp is the current time. + adv_winverf is the credential window + 1. + Both are encrypted using the conversation key. */ +#define adv_timestamp adv_time_u.adv_ctime +#define adv_xtimestamp adv_time_u.adv_xtime +#define adv_winverf adv_int_u + +/* des authentication verifier: server variety + + adv_timeverf is the client's timestamp + client's window + adv_nickname is the server's nickname for the client. + adv_timeverf is encrypted using the conversation key. */ +#define adv_timeverf adv_time_u.adv_ctime +#define adv_xtimeverf adv_time_u.adv_xtime +#define adv_nickname adv_int_u + +/* Map a des credential into a unix cred. */ +extern int authdes_getucred (__const struct authdes_cred * __adc, + uid_t * __uid, gid_t * __gid, + short *__grouplen, gid_t * __groups) __THROW; + +/* Get the public key for NAME and place it in KEY. NAME can only be + up to MAXNETNAMELEN bytes long and the destination buffer KEY should + have HEXKEYBYTES + 1 bytes long to fit all characters from the key. */ +extern int getpublickey (__const char *__name, char *__key) __THROW; + +/* Get the secret key for NAME and place it in KEY. PASSWD is used to + decrypt the encrypted key stored in the database. NAME can only be + up to MAXNETNAMELEN bytes long and the destination buffer KEY + should have HEXKEYBYTES + 1 bytes long to fit all characters from + the key. */ +extern int getsecretkey (__const char *__name, char *__key, + __const char *__passwd) __THROW; + +extern int rtime (struct sockaddr_in *__addrp, struct rpc_timeval *__timep, + struct rpc_timeval *__timeout) __THROW; + +__END_DECLS + + +#endif /* rpc/auth_des.h */ diff --git a/conts/posix/libposix/include/posix/rpc/auth_unix.h b/conts/posix/libposix/include/posix/rpc/auth_unix.h new file mode 100644 index 0000000..424661d --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/auth_unix.h @@ -0,0 +1,90 @@ +/* @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC; from 1.8 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)auth_unix.h 1.5 86/07/16 SMI */ + +/* + * auth_unix.h, Protocol for UNIX style authentication parameters for RPC + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +/* + * The system is very weak. The client uses no encryption for it + * credentials and only sends null verifiers. The server sends backs + * null verifiers or optionally a verifier that suggests a new short hand + * for the credentials. + */ + +#ifndef _RPC_AUTH_UNIX_H +#define _RPC_AUTH_UNIX_H 1 + +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +/* The machine name is part of a credential; it may not exceed 255 bytes */ +#define MAX_MACHINE_NAME 255 + +/* gids compose part of a credential; there may not be more than 16 of them */ +#define NGRPS 16 + +/* + * Unix style credentials. + */ +struct authunix_parms + { + u_long aup_time; + char *aup_machname; + __uid_t aup_uid; + __gid_t aup_gid; + u_int aup_len; + __gid_t *aup_gids; + }; + +extern bool_t xdr_authunix_parms (XDR *__xdrs, struct authunix_parms *__p) + __THROW; + +/* + * If a response verifier has flavor AUTH_SHORT, + * then the body of the response verifier encapsulates the following structure; + * again it is serialized in the obvious fashion. + */ +struct short_hand_verf + { + struct opaque_auth new_cred; + }; + +__END_DECLS + +#endif /* rpc/auth_unix.h */ diff --git a/conts/posix/libposix/include/posix/rpc/clnt.h b/conts/posix/libposix/include/posix/rpc/clnt.h new file mode 100644 index 0000000..cf271c5 --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/clnt.h @@ -0,0 +1,421 @@ +/* @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * clnt.h - Client side remote procedure call interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_CLNT_H +#define _RPC_CLNT_H 1 + +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +/* + * Rpc calls return an enum clnt_stat. This should be looked at more, + * since each implementation is required to live with this (implementation + * independent) list of errors. + */ +enum clnt_stat { + RPC_SUCCESS=0, /* call succeeded */ + /* + * local errors + */ + RPC_CANTENCODEARGS=1, /* can't encode arguments */ + RPC_CANTDECODERES=2, /* can't decode results */ + RPC_CANTSEND=3, /* failure in sending call */ + RPC_CANTRECV=4, /* failure in receiving result */ + RPC_TIMEDOUT=5, /* call timed out */ + /* + * remote errors + */ + RPC_VERSMISMATCH=6, /* rpc versions not compatible */ + RPC_AUTHERROR=7, /* authentication error */ + RPC_PROGUNAVAIL=8, /* program not available */ + RPC_PROGVERSMISMATCH=9, /* program version mismatched */ + RPC_PROCUNAVAIL=10, /* procedure unavailable */ + RPC_CANTDECODEARGS=11, /* decode arguments error */ + RPC_SYSTEMERROR=12, /* generic "other problem" */ + RPC_NOBROADCAST = 21, /* Broadcasting not supported */ + /* + * callrpc & clnt_create errors + */ + RPC_UNKNOWNHOST=13, /* unknown host name */ + RPC_UNKNOWNPROTO=17, /* unknown protocol */ + RPC_UNKNOWNADDR = 19, /* Remote address unknown */ + + /* + * rpcbind errors + */ + RPC_RPCBFAILURE=14, /* portmapper failed in its call */ +#define RPC_PMAPFAILURE RPC_RPCBFAILURE + RPC_PROGNOTREGISTERED=15, /* remote program is not registered */ + RPC_N2AXLATEFAILURE = 22, /* Name to addr translation failed */ + /* + * unspecified error + */ + RPC_FAILED=16, + RPC_INTR=18, + RPC_TLIERROR=20, + RPC_UDERROR=23, + /* + * asynchronous errors + */ + RPC_INPROGRESS = 24, + RPC_STALERACHANDLE = 25 +}; + + +/* + * Error info. + */ +struct rpc_err { + enum clnt_stat re_status; + union { + int RE_errno; /* related system error */ + enum auth_stat RE_why; /* why the auth error occurred */ + struct { + u_long low; /* lowest verion supported */ + u_long high; /* highest verion supported */ + } RE_vers; + struct { /* maybe meaningful if RPC_FAILED */ + long s1; + long s2; + } RE_lb; /* life boot & debugging only */ + } ru; +#define re_errno ru.RE_errno +#define re_why ru.RE_why +#define re_vers ru.RE_vers +#define re_lb ru.RE_lb +}; + + +/* + * Client rpc handle. + * Created by individual implementations, see e.g. rpc_udp.c. + * Client is responsible for initializing auth, see e.g. auth_none.c. + */ +typedef struct CLIENT CLIENT; +struct CLIENT { + AUTH *cl_auth; /* authenticator */ + struct clnt_ops { + enum clnt_stat (*cl_call) (CLIENT *, u_long, xdrproc_t, caddr_t, xdrproc_t, + caddr_t, struct timeval); + /* call remote procedure */ + void (*cl_abort) (void); /* abort a call */ + void (*cl_geterr) (CLIENT *, struct rpc_err *); + /* get specific error code */ + bool_t (*cl_freeres) (CLIENT *, xdrproc_t, caddr_t); + /* frees results */ + void (*cl_destroy) (CLIENT *); /* destroy this structure */ + bool_t (*cl_control) (CLIENT *, int, char *); + /* the ioctl() of rpc */ + } *cl_ops; + caddr_t cl_private; /* private stuff */ +}; + + +/* + * client side rpc interface ops + * + * Parameter types are: + * + */ + +/* + * enum clnt_stat + * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) + * CLIENT *rh; + * u_long proc; + * xdrproc_t xargs; + * caddr_t argsp; + * xdrproc_t xres; + * caddr_t resp; + * struct timeval timeout; + */ +#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) +#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) + +/* + * void + * CLNT_ABORT(rh); + * CLIENT *rh; + */ +#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) +#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) + +/* + * struct rpc_err + * CLNT_GETERR(rh); + * CLIENT *rh; + */ +#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) +#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) + + +/* + * bool_t + * CLNT_FREERES(rh, xres, resp); + * CLIENT *rh; + * xdrproc_t xres; + * caddr_t resp; + */ +#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) +#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) + +/* + * bool_t + * CLNT_CONTROL(cl, request, info) + * CLIENT *cl; + * u_int request; + * char *info; + */ +#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) +#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) + +/* + * control operations that apply to all transports + * + * Note: options marked XXX are no-ops in this implementation of RPC. + * The are present in TI-RPC but can't be implemented here since they + * depend on the presence of STREAMS/TLI, which we don't have. + */ +#define CLSET_TIMEOUT 1 /* set timeout (timeval) */ +#define CLGET_TIMEOUT 2 /* get timeout (timeval) */ +#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ +#define CLGET_FD 6 /* get connections file descriptor */ +#define CLGET_SVC_ADDR 7 /* get server's address (netbuf) XXX */ +#define CLSET_FD_CLOSE 8 /* close fd while clnt_destroy */ +#define CLSET_FD_NCLOSE 9 /* Do not close fd while clnt_destroy*/ +#define CLGET_XID 10 /* Get xid */ +#define CLSET_XID 11 /* Set xid */ +#define CLGET_VERS 12 /* Get version number */ +#define CLSET_VERS 13 /* Set version number */ +#define CLGET_PROG 14 /* Get program number */ +#define CLSET_PROG 15 /* Set program number */ +#define CLSET_SVC_ADDR 16 /* get server's address (netbuf) XXX */ +#define CLSET_PUSH_TIMOD 17 /* push timod if not already present XXX */ +#define CLSET_POP_TIMOD 18 /* pop timod XXX */ +/* + * Connectionless only control operations + */ +#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ +#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ + +/* + * void + * CLNT_DESTROY(rh); + * CLIENT *rh; + */ +#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) +#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) + + +/* + * RPCTEST is a test program which is accessible on every rpc + * transport/port. It is used for testing, performance evaluation, + * and network administration. + */ + +#define RPCTEST_PROGRAM ((u_long)1) +#define RPCTEST_VERSION ((u_long)1) +#define RPCTEST_NULL_PROC ((u_long)2) +#define RPCTEST_NULL_BATCH_PROC ((u_long)3) + +/* + * By convention, procedure 0 takes null arguments and returns them + */ + +#define NULLPROC ((u_long)0) + +/* + * Below are the client handle creation routines for the various + * implementations of client side rpc. They can return NULL if a + * creation failure occurs. + */ + +/* + * Memory based rpc (for speed check and testing) + * CLIENT * + * clntraw_create(prog, vers) + * u_long prog; + * u_long vers; + */ +extern CLIENT *clntraw_create (__const u_long __prog, __const u_long __vers) + __THROW; + + +/* + * Generic client creation routine. Supported protocols are "udp", "tcp" and + * "unix" + * CLIENT * + * clnt_create(host, prog, vers, prot) + * char *host; -- hostname + * u_long prog; -- program number + * u_ong vers; -- version number + * char *prot; -- protocol + */ +extern CLIENT *clnt_create (__const char *__host, __const u_long __prog, + __const u_long __vers, __const char *__prot) + __THROW; + + +/* + * TCP based rpc + * CLIENT * + * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * u_long prog; + * u_long version; + * register int *sockp; + * u_int sendsz; + * u_int recvsz; + */ +extern CLIENT *clnttcp_create (struct sockaddr_in *__raddr, u_long __prog, + u_long __version, int *__sockp, u_int __sendsz, + u_int __recvsz) __THROW; + +/* + * UDP based rpc. + * CLIENT * + * clntudp_create(raddr, program, version, wait, sockp) + * struct sockaddr_in *raddr; + * u_long program; + * u_long version; + * struct timeval wait_resend; + * int *sockp; + * + * Same as above, but you specify max packet sizes. + * CLIENT * + * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * u_long program; + * u_long version; + * struct timeval wait_resend; + * int *sockp; + * u_int sendsz; + * u_int recvsz; + */ +extern CLIENT *clntudp_create (struct sockaddr_in *__raddr, u_long __program, + u_long __version, struct timeval __wait_resend, + int *__sockp) __THROW; +extern CLIENT *clntudp_bufcreate (struct sockaddr_in *__raddr, + u_long __program, u_long __version, + struct timeval __wait_resend, int *__sockp, + u_int __sendsz, u_int __recvsz) __THROW; + + + + +/* + * AF_UNIX based rpc + * CLIENT * + * clntunix_create(raddr, prog, vers, sockp, sendsz, recvsz) + * struct sockaddr_un *raddr; + * u_long prog; + * u_long version; + * register int *sockp; + * u_int sendsz; + * u_int recvsz; + */ +extern CLIENT *clntunix_create (struct sockaddr_un *__raddr, u_long __program, + u_long __version, int *__sockp, + u_int __sendsz, u_int __recvsz) __THROW; + + +extern int callrpc (__const char *__host, __const u_long __prognum, + __const u_long __versnum, __const u_long __procnum, + __const xdrproc_t __inproc, __const char *__in, + __const xdrproc_t __outproc, char *__out) __THROW; +extern int _rpc_dtablesize (void) __THROW; + +/* + * Print why creation failed + */ +extern void clnt_pcreateerror (__const char *__msg); /* stderr */ +extern char *clnt_spcreateerror(__const char *__msg) __THROW; /* string */ + +/* + * Like clnt_perror(), but is more verbose in its output + */ +extern void clnt_perrno (enum clnt_stat __num); /* stderr */ + +/* + * Print an English error message, given the client error code + */ +extern void clnt_perror (CLIENT *__clnt, __const char *__msg); + /* stderr */ +extern char *clnt_sperror (CLIENT *__clnt, __const char *__msg) __THROW; + /* string */ + +/* + * If a creation fails, the following allows the user to figure out why. + */ +struct rpc_createerr { + enum clnt_stat cf_stat; + struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ +}; + +extern struct rpc_createerr rpc_createerr; + + + +/* + * Copy error message to buffer. + */ +extern char *clnt_sperrno (enum clnt_stat __num) __THROW; /* string */ + +/* + * get the port number on the host for the rpc program,version and proto + */ +extern int getrpcport (__const char * __host, u_long __prognum, + u_long __versnum, u_int proto) __THROW; + +/* + * get the local host's IP address without consulting + * name service library functions + */ +extern void get_myaddress (struct sockaddr_in *) __THROW; + +#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ +#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ + +__END_DECLS + +#endif /* rpc/clnt.h */ diff --git a/conts/posix/libposix/include/posix/rpc/des_crypt.h b/conts/posix/libposix/include/posix/rpc/des_crypt.h new file mode 100644 index 0000000..6a65887 --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/des_crypt.h @@ -0,0 +1,97 @@ +/* + * @(#)des_crypt.h 2.1 88/08/11 4.0 RPCSRC; from 1.4 88/02/08 (C) 1986 SMI + * + * des_crypt.h, des library routine interface + * Copyright (C) 1986, Sun Microsystems, Inc. + */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +#ifndef __DES_CRYPT_H__ +#define __DES_CRYPT_H__ 1 + +#include + +__BEGIN_DECLS + +#define DES_MAXDATA 8192 /* max bytes encrypted in one call */ +#define DES_DIRMASK (1 << 0) +#define DES_ENCRYPT (0*DES_DIRMASK) /* Encrypt */ +#define DES_DECRYPT (1*DES_DIRMASK) /* Decrypt */ + + +#define DES_DEVMASK (1 << 1) +#define DES_HW (0*DES_DEVMASK) /* Use hardware device */ +#define DES_SW (1*DES_DEVMASK) /* Use software device */ + + +#define DESERR_NONE 0 /* succeeded */ +#define DESERR_NOHWDEVICE 1 /* succeeded, but hw device not available */ +#define DESERR_HWERROR 2 /* failed, hardware/driver error */ +#define DESERR_BADPARAM 3 /* failed, bad parameter to call */ + +#define DES_FAILED(err) \ + ((err) > DESERR_NOHWDEVICE) + +/* + * cbc_crypt() + * ecb_crypt() + * + * Encrypt (or decrypt) len bytes of a buffer buf. + * The length must be a multiple of eight. + * The key should have odd parity in the low bit of each byte. + * ivec is the input vector, and is updated to the new one (cbc only). + * The mode is created by oring together the appropriate parameters. + * DESERR_NOHWDEVICE is returned if DES_HW was specified but + * there was no hardware to do it on (the data will still be + * encrypted though, in software). + */ + + +/* + * Cipher Block Chaining mode + */ +extern int cbc_crypt (char *__key, char *__buf, unsigned __len, + unsigned __mode, char *__ivec) __THROW; + +/* + * Electronic Code Book mode + */ +extern int ecb_crypt (char *__key, char *__buf, unsigned __len, + unsigned __mode) __THROW; + +/* + * Set des parity for a key. + * DES parity is odd and in the low bit of each byte + */ +extern void des_setparity (char *__key) __THROW; + +__END_DECLS + +#endif diff --git a/conts/posix/libposix/include/posix/rpc/key_prot.h b/conts/posix/libposix/include/posix/rpc/key_prot.h new file mode 100644 index 0000000..3e2eb72 --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/key_prot.h @@ -0,0 +1,346 @@ +/* + * Please do not edit this file. + * It was generated using rpcgen. + */ + +#ifndef _KEY_PROT_H_RPCGEN +#define _KEY_PROT_H_RPCGEN + +#include + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +#if 0 +#pragma ident "@(#)key_prot.x 1.7 94/04/29 SMI" +#endif +/* Copyright (c) 1990, 1991 Sun Microsystems, Inc. */ + +/* + * Compiled from key_prot.x using rpcgen. + * DO NOT EDIT THIS FILE! + * This is NOT source code! + */ +#define PROOT 3 +#define HEXMODULUS "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b" +#define HEXKEYBYTES 48 +#define KEYSIZE 192 +#define KEYBYTES 24 +#define KEYCHECKSUMSIZE 16 + +enum keystatus { + KEY_SUCCESS = 0, + KEY_NOSECRET = 1, + KEY_UNKNOWN = 2, + KEY_SYSTEMERR = 3, +}; +typedef enum keystatus keystatus; +#ifdef __cplusplus +extern "C" bool_t xdr_keystatus(XDR *, keystatus*); +#elif __STDC__ +extern bool_t xdr_keystatus(XDR *, keystatus*); +#else /* Old Style C */ +bool_t xdr_keystatus(); +#endif /* Old Style C */ + + +typedef char keybuf[HEXKEYBYTES]; +#ifdef __cplusplus +extern "C" bool_t xdr_keybuf(XDR *, keybuf); +#elif __STDC__ +extern bool_t xdr_keybuf(XDR *, keybuf); +#else /* Old Style C */ +bool_t xdr_keybuf(); +#endif /* Old Style C */ + + +typedef char *netnamestr; +#ifdef __cplusplus +extern "C" bool_t xdr_netnamestr(XDR *, netnamestr*); +#elif __STDC__ +extern bool_t xdr_netnamestr(XDR *, netnamestr*); +#else /* Old Style C */ +bool_t xdr_netnamestr(); +#endif /* Old Style C */ + + +struct cryptkeyarg { + netnamestr remotename; + des_block deskey; +}; +typedef struct cryptkeyarg cryptkeyarg; +#ifdef __cplusplus +extern "C" bool_t xdr_cryptkeyarg(XDR *, cryptkeyarg*); +#elif __STDC__ +extern bool_t xdr_cryptkeyarg(XDR *, cryptkeyarg*); +#else /* Old Style C */ +bool_t xdr_cryptkeyarg(); +#endif /* Old Style C */ + + +struct cryptkeyarg2 { + netnamestr remotename; + netobj remotekey; + des_block deskey; +}; +typedef struct cryptkeyarg2 cryptkeyarg2; +#ifdef __cplusplus +extern "C" bool_t xdr_cryptkeyarg2(XDR *, cryptkeyarg2*); +#elif __STDC__ +extern bool_t xdr_cryptkeyarg2(XDR *, cryptkeyarg2*); +#else /* Old Style C */ +bool_t xdr_cryptkeyarg2(); +#endif /* Old Style C */ + + +struct cryptkeyres { + keystatus status; + union { + des_block deskey; + } cryptkeyres_u; +}; +typedef struct cryptkeyres cryptkeyres; +#ifdef __cplusplus +extern "C" bool_t xdr_cryptkeyres(XDR *, cryptkeyres*); +#elif __STDC__ +extern bool_t xdr_cryptkeyres(XDR *, cryptkeyres*); +#else /* Old Style C */ +bool_t xdr_cryptkeyres(); +#endif /* Old Style C */ + +#define MAXGIDS 16 + +struct unixcred { + u_int uid; + u_int gid; + struct { + u_int gids_len; + u_int *gids_val; + } gids; +}; +typedef struct unixcred unixcred; +#ifdef __cplusplus +extern "C" bool_t xdr_unixcred(XDR *, unixcred*); +#elif __STDC__ +extern bool_t xdr_unixcred(XDR *, unixcred*); +#else /* Old Style C */ +bool_t xdr_unixcred(); +#endif /* Old Style C */ + + +struct getcredres { + keystatus status; + union { + unixcred cred; + } getcredres_u; +}; +typedef struct getcredres getcredres; +#ifdef __cplusplus +extern "C" bool_t xdr_getcredres(XDR *, getcredres*); +#elif __STDC__ +extern bool_t xdr_getcredres(XDR *, getcredres*); +#else /* Old Style C */ +bool_t xdr_getcredres(); +#endif /* Old Style C */ + + +struct key_netstarg { + keybuf st_priv_key; + keybuf st_pub_key; + netnamestr st_netname; +}; +typedef struct key_netstarg key_netstarg; +#ifdef __cplusplus +extern "C" bool_t xdr_key_netstarg(XDR *, key_netstarg*); +#elif __STDC__ +extern bool_t xdr_key_netstarg(XDR *, key_netstarg*); +#else /* Old Style C */ +bool_t xdr_key_netstarg(); +#endif /* Old Style C */ + + +struct key_netstres { + keystatus status; + union { + key_netstarg knet; + } key_netstres_u; +}; +typedef struct key_netstres key_netstres; +#ifdef __cplusplus +extern "C" bool_t xdr_key_netstres(XDR *, key_netstres*); +#elif __STDC__ +extern bool_t xdr_key_netstres(XDR *, key_netstres*); +#else /* Old Style C */ +bool_t xdr_key_netstres(); +#endif /* Old Style C */ + + +#ifndef opaque +#define opaque char +#endif + + +#define KEY_PROG ((u_long)100029) +#define KEY_VERS ((u_long)1) + +#ifdef __cplusplus +#define KEY_SET ((u_long)1) +extern "C" keystatus * key_set_1(opaque *, CLIENT *); +extern "C" keystatus * key_set_1_svc(opaque *, struct svc_req *); +#define KEY_ENCRYPT ((u_long)2) +extern "C" cryptkeyres * key_encrypt_1(cryptkeyarg *, CLIENT *); +extern "C" cryptkeyres * key_encrypt_1_svc(cryptkeyarg *, struct svc_req *); +#define KEY_DECRYPT ((u_long)3) +extern "C" cryptkeyres * key_decrypt_1(cryptkeyarg *, CLIENT *); +extern "C" cryptkeyres * key_decrypt_1_svc(cryptkeyarg *, struct svc_req *); +#define KEY_GEN ((u_long)4) +extern "C" des_block * key_gen_1(void *, CLIENT *); +extern "C" des_block * key_gen_1_svc(void *, struct svc_req *); +#define KEY_GETCRED ((u_long)5) +extern "C" getcredres * key_getcred_1(netnamestr *, CLIENT *); +extern "C" getcredres * key_getcred_1_svc(netnamestr *, struct svc_req *); + +#elif __STDC__ +#define KEY_SET ((u_long)1) +extern keystatus * key_set_1(opaque *, CLIENT *); +extern keystatus * key_set_1_svc(opaque *, struct svc_req *); +#define KEY_ENCRYPT ((u_long)2) +extern cryptkeyres * key_encrypt_1(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_encrypt_1_svc(cryptkeyarg *, struct svc_req *); +#define KEY_DECRYPT ((u_long)3) +extern cryptkeyres * key_decrypt_1(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_decrypt_1_svc(cryptkeyarg *, struct svc_req *); +#define KEY_GEN ((u_long)4) +extern des_block * key_gen_1(void *, CLIENT *); +extern des_block * key_gen_1_svc(void *, struct svc_req *); +#define KEY_GETCRED ((u_long)5) +extern getcredres * key_getcred_1(netnamestr *, CLIENT *); +extern getcredres * key_getcred_1_svc(netnamestr *, struct svc_req *); + +#else /* Old Style C */ +#define KEY_SET ((u_long)1) +extern keystatus * key_set_1(); +extern keystatus * key_set_1_svc(); +#define KEY_ENCRYPT ((u_long)2) +extern cryptkeyres * key_encrypt_1(); +extern cryptkeyres * key_encrypt_1_svc(); +#define KEY_DECRYPT ((u_long)3) +extern cryptkeyres * key_decrypt_1(); +extern cryptkeyres * key_decrypt_1_svc(); +#define KEY_GEN ((u_long)4) +extern des_block * key_gen_1(); +extern des_block * key_gen_1_svc(); +#define KEY_GETCRED ((u_long)5) +extern getcredres * key_getcred_1(); +extern getcredres * key_getcred_1_svc(); +#endif /* Old Style C */ +#define KEY_VERS2 ((u_long)2) + +#ifdef __cplusplus +extern "C" keystatus * key_set_2(opaque *, CLIENT *); +extern "C" keystatus * key_set_2_svc(opaque *, struct svc_req *); +extern "C" cryptkeyres * key_encrypt_2(cryptkeyarg *, CLIENT *); +extern "C" cryptkeyres * key_encrypt_2_svc(cryptkeyarg *, struct svc_req *); +extern "C" cryptkeyres * key_decrypt_2(cryptkeyarg *, CLIENT *); +extern "C" cryptkeyres * key_decrypt_2_svc(cryptkeyarg *, struct svc_req *); +extern "C" des_block * key_gen_2(void *, CLIENT *); +extern "C" des_block * key_gen_2_svc(void *, struct svc_req *); +extern "C" getcredres * key_getcred_2(netnamestr *, CLIENT *); +extern "C" getcredres * key_getcred_2_svc(netnamestr *, struct svc_req *); +#define KEY_ENCRYPT_PK ((u_long)6) +extern "C" cryptkeyres * key_encrypt_pk_2(cryptkeyarg2 *, CLIENT *); +extern "C" cryptkeyres * key_encrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); +#define KEY_DECRYPT_PK ((u_long)7) +extern "C" cryptkeyres * key_decrypt_pk_2(cryptkeyarg2 *, CLIENT *); +extern "C" cryptkeyres * key_decrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); +#define KEY_NET_PUT ((u_long)8) +extern "C" keystatus * key_net_put_2(key_netstarg *, CLIENT *); +extern "C" keystatus * key_net_put_2_svc(key_netstarg *, struct svc_req *); +#define KEY_NET_GET ((u_long)9) +extern "C" key_netstres * key_net_get_2(void *, CLIENT *); +extern "C" key_netstres * key_net_get_2_svc(void *, struct svc_req *); +#define KEY_GET_CONV ((u_long)10) +extern "C" cryptkeyres * key_get_conv_2(opaque *, CLIENT *); +extern "C" cryptkeyres * key_get_conv_2_svc(opaque *, struct svc_req *); + +#elif __STDC__ +extern keystatus * key_set_2(opaque *, CLIENT *); +extern keystatus * key_set_2_svc(opaque *, struct svc_req *); +extern cryptkeyres * key_encrypt_2(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_encrypt_2_svc(cryptkeyarg *, struct svc_req *); +extern cryptkeyres * key_decrypt_2(cryptkeyarg *, CLIENT *); +extern cryptkeyres * key_decrypt_2_svc(cryptkeyarg *, struct svc_req *); +extern des_block * key_gen_2(void *, CLIENT *); +extern des_block * key_gen_2_svc(void *, struct svc_req *); +extern getcredres * key_getcred_2(netnamestr *, CLIENT *); +extern getcredres * key_getcred_2_svc(netnamestr *, struct svc_req *); +#define KEY_ENCRYPT_PK ((u_long)6) +extern cryptkeyres * key_encrypt_pk_2(cryptkeyarg2 *, CLIENT *); +extern cryptkeyres * key_encrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); +#define KEY_DECRYPT_PK ((u_long)7) +extern cryptkeyres * key_decrypt_pk_2(cryptkeyarg2 *, CLIENT *); +extern cryptkeyres * key_decrypt_pk_2_svc(cryptkeyarg2 *, struct svc_req *); +#define KEY_NET_PUT ((u_long)8) +extern keystatus * key_net_put_2(key_netstarg *, CLIENT *); +extern keystatus * key_net_put_2_svc(key_netstarg *, struct svc_req *); +#define KEY_NET_GET ((u_long)9) +extern key_netstres * key_net_get_2(void *, CLIENT *); +extern key_netstres * key_net_get_2_svc(void *, struct svc_req *); +#define KEY_GET_CONV ((u_long)10) +extern cryptkeyres * key_get_conv_2(opaque *, CLIENT *); +extern cryptkeyres * key_get_conv_2_svc(opaque *, struct svc_req *); + +#else /* Old Style C */ +extern keystatus * key_set_2(); +extern keystatus * key_set_2_svc(); +extern cryptkeyres * key_encrypt_2(); +extern cryptkeyres * key_encrypt_2_svc(); +extern cryptkeyres * key_decrypt_2(); +extern cryptkeyres * key_decrypt_2_svc(); +extern des_block * key_gen_2(); +extern des_block * key_gen_2_svc(); +extern getcredres * key_getcred_2(); +extern getcredres * key_getcred_2_svc(); +#define KEY_ENCRYPT_PK ((u_long)6) +extern cryptkeyres * key_encrypt_pk_2(); +extern cryptkeyres * key_encrypt_pk_2_svc(); +#define KEY_DECRYPT_PK ((u_long)7) +extern cryptkeyres * key_decrypt_pk_2(); +extern cryptkeyres * key_decrypt_pk_2_svc(); +#define KEY_NET_PUT ((u_long)8) +extern keystatus * key_net_put_2(); +extern keystatus * key_net_put_2_svc(); +#define KEY_NET_GET ((u_long)9) +extern key_netstres * key_net_get_2(); +extern key_netstres * key_net_get_2_svc(); +#define KEY_GET_CONV ((u_long)10) +extern cryptkeyres * key_get_conv_2(); +extern cryptkeyres * key_get_conv_2_svc(); +#endif /* Old Style C */ + +#endif /* !_KEY_PROT_H_RPCGEN */ diff --git a/conts/posix/libposix/include/posix/rpc/netdb.h b/conts/posix/libposix/include/posix/rpc/netdb.h new file mode 100644 index 0000000..8671737 --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/netdb.h @@ -0,0 +1,74 @@ +/* @(#)netdb.h 2.1 88/07/29 3.9 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)rpc.h 1.8 87/07/24 SMI */ + +/* Cleaned up for GNU C library roland@gnu.ai.mit.edu: + added multiple inclusion protection and use of . + In GNU this file is #include'd by . */ + +#ifndef _RPC_NETDB_H +#define _RPC_NETDB_H 1 + +#include + +#define __need_size_t +#include + +__BEGIN_DECLS + +struct rpcent +{ + char *r_name; /* Name of server for this rpc program. */ + char **r_aliases; /* Alias list. */ + int r_number; /* RPC program number. */ +}; + +extern void setrpcent (int __stayopen) __THROW; +extern void endrpcent (void) __THROW; +extern struct rpcent *getrpcbyname (__const char *__name) __THROW; +extern struct rpcent *getrpcbynumber (int __number) __THROW; +extern struct rpcent *getrpcent (void) __THROW; + +#if defined __USE_MISC && defined __UCLIBC_HAS_REENTRANT_RPC__ +extern int getrpcbyname_r (__const char *__name, struct rpcent *__result_buf, + char *__buffer, size_t __buflen, + struct rpcent **__result) __THROW; + +extern int getrpcbynumber_r (int __number, struct rpcent *__result_buf, + char *__buffer, size_t __buflen, + struct rpcent **__result) __THROW; + +extern int getrpcent_r (struct rpcent *__result_buf, char *__buffer, + size_t __buflen, struct rpcent **__result) __THROW; +#endif + +__END_DECLS + +#endif /* rpc/netdb.h */ diff --git a/conts/posix/libposix/include/posix/rpc/pmap_clnt.h b/conts/posix/libposix/include/posix/rpc/pmap_clnt.h new file mode 100644 index 0000000..1b1c452 --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/pmap_clnt.h @@ -0,0 +1,98 @@ +/* @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.11 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * pmap_clnt.h + * Supplies C routines to get to portmap services. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_PMAP_CLNT_H +#define _RPC_PMAP_CLNT_H 1 + +#include +#include +#include +#include + +__BEGIN_DECLS + +typedef bool_t (*resultproc_t) (caddr_t resp, struct sockaddr_in *raddr); + +/* + * Usage: + * success = pmap_set(program, version, protocol, port); + * success = pmap_unset(program, version); + * port = pmap_getport(address, program, version, protocol); + * head = pmap_getmaps(address); + * clnt_stat = pmap_rmtcall(address, program, version, procedure, + * xdrargs, argsp, xdrres, resp, tout, port_ptr) + * (works for udp only.) + * clnt_stat = clnt_broadcast(program, version, procedure, + * xdrargs, argsp, xdrres, resp, eachresult) + * (like pmap_rmtcall, except the call is broadcasted to all + * locally connected nets. For each valid response received, + * the procedure eachresult is called. Its form is: + * done = eachresult(resp, raddr) + * bool_t done; + * caddr_t resp; + * struct sockaddr_in raddr; + * where resp points to the results of the call and raddr is the + * address if the responder to the broadcast. + */ + +extern bool_t pmap_set (__const u_long __program, __const u_long __vers, + int __protocol, u_short __port) __THROW; +extern bool_t pmap_unset (__const u_long __program, __const u_long __vers) + __THROW; +extern struct pmaplist *pmap_getmaps (struct sockaddr_in *__address) __THROW; +extern enum clnt_stat pmap_rmtcall (struct sockaddr_in *__addr, + __const u_long __prog, + __const u_long __vers, + __const u_long __proc, + xdrproc_t __xdrargs, + caddr_t __argsp, xdrproc_t __xdrres, + caddr_t __resp, struct timeval __tout, + u_long *__port_ptr) __THROW; +extern enum clnt_stat clnt_broadcast (__const u_long __prog, + __const u_long __vers, + __const u_long __proc, xdrproc_t __xargs, + caddr_t __argsp, xdrproc_t __xresults, + caddr_t __resultsp, + resultproc_t __eachresult) __THROW; +extern u_short pmap_getport (struct sockaddr_in *__address, + __const u_long __program, + __const u_long __version, u_int __protocol) + __THROW; + +__END_DECLS + +#endif /* rpc/pmap_clnt.h */ diff --git a/conts/posix/libposix/include/posix/rpc/pmap_prot.h b/conts/posix/libposix/include/posix/rpc/pmap_prot.h new file mode 100644 index 0000000..cd64e36 --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/pmap_prot.h @@ -0,0 +1,108 @@ +/* @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC; from 1.14 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * pmap_prot.h + * Protocol for the local binder service, or pmap. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_PMAP_PROT_H +#define _RPC_PMAP_PROT_H 1 + +#include + +#include + +__BEGIN_DECLS + +/* The following procedures are supported by the protocol: + * + * PMAPPROC_NULL() returns () + * takes nothing, returns nothing + * + * PMAPPROC_SET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Registers the tuple + * [prog, vers, prot, port]. + * + * PMAPPROC_UNSET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Un-registers pair + * [prog, vers]. prot and port are ignored. + * + * PMAPPROC_GETPORT(struct pmap) returns (long unsigned). + * 0 is failure. Otherwise returns the port number where the pair + * [prog, vers] is registered. It may lie! + * + * PMAPPROC_DUMP() RETURNS (struct pmaplist *) + * + * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) + * RETURNS (port, string<>); + * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs); + * Calls the procedure on the local machine. If it is not registered, + * this procedure is quite; ie it does not return error information!!! + * This procedure only is supported on rpc/udp and calls via + * rpc/udp. This routine only passes null authentication parameters. + * This file has no interface to xdr routines for PMAPPROC_CALLIT. + * + * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. + */ + +#define PMAPPORT ((u_short)111) +#define PMAPPROG ((u_long)100000) +#define PMAPVERS ((u_long)2) +#define PMAPVERS_PROTO ((u_long)2) +#define PMAPVERS_ORIG ((u_long)1) +#define PMAPPROC_NULL ((u_long)0) +#define PMAPPROC_SET ((u_long)1) +#define PMAPPROC_UNSET ((u_long)2) +#define PMAPPROC_GETPORT ((u_long)3) +#define PMAPPROC_DUMP ((u_long)4) +#define PMAPPROC_CALLIT ((u_long)5) + +struct pmap { + long unsigned pm_prog; + long unsigned pm_vers; + long unsigned pm_prot; + long unsigned pm_port; +}; + +extern bool_t xdr_pmap (XDR *__xdrs, struct pmap *__regs) __THROW; + +struct pmaplist { + struct pmap pml_map; + struct pmaplist *pml_next; +}; + +extern bool_t xdr_pmaplist (XDR *__xdrs, struct pmaplist **__rp) __THROW; + +__END_DECLS + +#endif /* rpc/pmap_prot.h */ diff --git a/conts/posix/libposix/include/posix/rpc/pmap_rmt.h b/conts/posix/libposix/include/posix/rpc/pmap_rmt.h new file mode 100644 index 0000000..7a38b5f --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/pmap_rmt.h @@ -0,0 +1,68 @@ +/* @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC; from 1.2 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * Structures and XDR routines for parameters to and replies from + * the portmapper remote-call-service. + * + * Copyright (C) 1986, Sun Microsystems, Inc. + */ + +#ifndef _RPC_PMAP_RMT_H +#define _RPC_PMAP_RMT_H 1 + +#include +#include +#include +#include + +__BEGIN_DECLS + +struct rmtcallargs { + u_long prog, vers, proc, arglen; + caddr_t args_ptr; + xdrproc_t xdr_args; +}; + +extern bool_t xdr_rmtcall_args (XDR *__xdrs, struct rmtcallargs *__crp) + __THROW; + +struct rmtcallres { + u_long *port_ptr; + u_long resultslen; + caddr_t results_ptr; + xdrproc_t xdr_results; +}; + +extern bool_t xdr_rmtcallres (XDR *__xdrs, struct rmtcallres *__crp) __THROW; + +__END_DECLS + +#endif /* rpc/pmap_rmt.h */ diff --git a/conts/posix/libposix/include/posix/rpc/rpc.h b/conts/posix/libposix/include/posix/rpc/rpc.h new file mode 100644 index 0000000..9236e72 --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/rpc.h @@ -0,0 +1,110 @@ +/* @(#)rpc.h 2.3 88/08/10 4.0 RPCSRC; from 1.9 88/02/08 SMI */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * rpc.h, Just includes the billions of rpc header files necessary to + * do remote procedure calling. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_RPC_H +#define _RPC_RPC_H 1 + +#ifdef _LIBC +/* Some adjustments to make the libc source from glibc + * compile more easily with uClibc... */ +#ifndef __FORCE_GLIBC +#define __FORCE_GLIBC +#endif +#ifndef _GNU_SOUCE +#define _GNU_SOUCE +#endif +#define _(X) X +#include +#endif + +#include /* some typedefs */ +#include + +/* external data representation interfaces */ +#include /* generic (de)serializer */ + +/* Client side only authentication */ +#include /* generic authenticator (client side) */ + +/* Client side (mostly) remote procedure call */ +#include /* generic rpc stuff */ + +/* semi-private protocol headers */ +#include /* protocol for rpc messages */ +#include /* protocol for unix style cred */ +#include /* protocol for des style cred */ + +/* Server side only remote procedure callee */ +#include /* service manager and multiplexer */ +#include /* service side authenticator */ + +/* + * COMMENT OUT THE NEXT INCLUDE IF RUNNING ON SUN OS OR ON A VERSION + * OF UNIX BASED ON NFSSRC. These systems will already have the structures + * defined by included in . + */ +/* routines for parsing /etc/rpc */ +#include /* structures and routines to parse /etc/rpc */ + +__BEGIN_DECLS + +/* Global variables, protected for multi-threaded applications. */ +extern fd_set *__rpc_thread_svc_fdset (void) __attribute__ ((__const__)); +#define svc_fdset (*__rpc_thread_svc_fdset ()) + +extern struct rpc_createerr *__rpc_thread_createerr (void) + __attribute__ ((__const__)); +#define get_rpc_createerr() (*__rpc_thread_createerr ()) +/* The people who "engineered" RPC should bee punished for naming the + data structure and the variable the same. We cannot always define the + macro 'rpc_createerr' because this would prevent people from defining + object of type 'struct rpc_createerr'. So we leave it up to the user + to select transparent replacement also of this variable. */ +#ifdef _RPC_MT_VARS +# define rpc_createerr (*__rpc_thread_createerr ()) +#endif + +extern struct pollfd **__rpc_thread_svc_pollfd (void) + __attribute__ ((__const__)); +#define svc_pollfd (*__rpc_thread_svc_pollfd ()) + +extern int *__rpc_thread_svc_max_pollfd (void) __attribute__ ((__const__)); +#define svc_max_pollfd (*__rpc_thread_svc_max_pollfd ()) + +__END_DECLS + +#endif /* rpc/rpc.h */ diff --git a/conts/posix/libposix/include/posix/rpc/rpc_des.h b/conts/posix/libposix/include/posix/rpc/rpc_des.h new file mode 100644 index 0000000..0f36d16 --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/rpc_des.h @@ -0,0 +1,72 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* + * Generic DES driver interface + * Keep this file hardware independent! + * Copyright (c) 1986 by Sun Microsystems, Inc. + */ + +#ifndef _DES_H +#define _DES_H + +#include + +#define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */ +#define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */ + +enum desdir + { + ENCRYPT, DECRYPT + }; +enum desmode + { + CBC, ECB + }; + +/* + * parameters to ioctl call + */ +struct desparams + { + u_char des_key[8]; /* key (with low bit parity) */ + enum desdir des_dir; /* direction */ + enum desmode des_mode; /* mode */ + u_char des_ivec[8]; /* input vector */ + unsigned des_len; /* number of bytes to crypt */ + union + { + u_char UDES_data[DES_QUICKLEN]; + u_char *UDES_buf; + } + UDES; +#define des_data UDES.UDES_data /* direct data here if quick */ +#define des_buf UDES.UDES_buf /* otherwise, pointer to data */ + }; + +#endif diff --git a/conts/posix/libposix/include/posix/rpc/rpc_msg.h b/conts/posix/libposix/include/posix/rpc/rpc_msg.h new file mode 100644 index 0000000..636d60e --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/rpc_msg.h @@ -0,0 +1,202 @@ +/* @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)rpc_msg.h 1.7 86/07/16 SMI */ + +#ifndef _RPC_MSG_H +#define _RPC_MSG_H 1 + +#include + +#include +#include + +/* + * rpc_msg.h + * rpc message definition + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#define RPC_MSG_VERSION ((u_long) 2) +#define RPC_SERVICE_PORT ((u_short) 2048) + +__BEGIN_DECLS + +/* + * Bottom up definition of an rpc message. + * NOTE: call and reply use the same overall struct but + * different parts of unions within it. + */ + +enum msg_type { + CALL=0, + REPLY=1 +}; + +enum reply_stat { + MSG_ACCEPTED=0, + MSG_DENIED=1 +}; + +enum accept_stat { + SUCCESS=0, + PROG_UNAVAIL=1, + PROG_MISMATCH=2, + PROC_UNAVAIL=3, + GARBAGE_ARGS=4, + SYSTEM_ERR=5 +}; + +enum reject_stat { + RPC_MISMATCH=0, + AUTH_ERROR=1 +}; + +/* + * Reply part of an rpc exchange + */ + +/* + * Reply to an rpc request that was accepted by the server. + * Note: there could be an error even though the request was + * accepted. + */ +struct accepted_reply { + struct opaque_auth ar_verf; + enum accept_stat ar_stat; + union { + struct { + u_long low; + u_long high; + } AR_versions; + struct { + caddr_t where; + xdrproc_t proc; + } AR_results; + /* and many other null cases */ + } ru; +#define ar_results ru.AR_results +#define ar_vers ru.AR_versions +}; + +/* + * Reply to an rpc request that was rejected by the server. + */ +struct rejected_reply { + enum reject_stat rj_stat; + union { + struct { + u_long low; + u_long high; + } RJ_versions; + enum auth_stat RJ_why; /* why authentication did not work */ + } ru; +#define rj_vers ru.RJ_versions +#define rj_why ru.RJ_why +}; + +/* + * Body of a reply to an rpc request. + */ +struct reply_body { + enum reply_stat rp_stat; + union { + struct accepted_reply RP_ar; + struct rejected_reply RP_dr; + } ru; +#define rp_acpt ru.RP_ar +#define rp_rjct ru.RP_dr +}; + +/* + * Body of an rpc request call. + */ +struct call_body { + u_long cb_rpcvers; /* must be equal to two */ + u_long cb_prog; + u_long cb_vers; + u_long cb_proc; + struct opaque_auth cb_cred; + struct opaque_auth cb_verf; /* protocol specific - provided by client */ +}; + +/* + * The rpc message + */ +struct rpc_msg { + u_long rm_xid; + enum msg_type rm_direction; + union { + struct call_body RM_cmb; + struct reply_body RM_rmb; + } ru; +#define rm_call ru.RM_cmb +#define rm_reply ru.RM_rmb +}; +#define acpted_rply ru.RM_rmb.ru.RP_ar +#define rjcted_rply ru.RM_rmb.ru.RP_dr + + +/* + * XDR routine to handle a rpc message. + * xdr_callmsg(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +extern bool_t xdr_callmsg (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW; + +/* + * XDR routine to pre-serialize the static part of a rpc message. + * xdr_callhdr(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +extern bool_t xdr_callhdr (XDR *__xdrs, struct rpc_msg *__cmsg) __THROW; + +/* + * XDR routine to handle a rpc reply. + * xdr_replymsg(xdrs, rmsg) + * XDR *xdrs; + * struct rpc_msg *rmsg; + */ +extern bool_t xdr_replymsg (XDR *__xdrs, struct rpc_msg *__rmsg) __THROW; + +/* + * Fills in the error part of a reply message. + * _seterr_reply(msg, error) + * struct rpc_msg *msg; + * struct rpc_err *error; + */ +extern void _seterr_reply (struct rpc_msg *__msg, struct rpc_err *__error) + __THROW; + +__END_DECLS + +#endif /* rpc/rpc_msg.h */ diff --git a/conts/posix/libposix/include/posix/rpc/svc.h b/conts/posix/libposix/include/posix/rpc/svc.h new file mode 100644 index 0000000..3ffca50 --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/svc.h @@ -0,0 +1,316 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * svc.h, Server-side remote procedure call interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_SVC_H +#define _RPC_SVC_H 1 + +#include +#include + +__BEGIN_DECLS + +/* + * This interface must manage two items concerning remote procedure calling: + * + * 1) An arbitrary number of transport connections upon which rpc requests + * are received. The two most notable transports are TCP and UDP; they are + * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; + * they in turn call xprt_register and xprt_unregister. + * + * 2) An arbitrary number of locally registered services. Services are + * described by the following four data: program number, version number, + * "service dispatch" function, a transport handle, and a boolean that + * indicates whether or not the exported program should be registered with a + * local binder service; if true the program's number and version and the + * port number from the transport handle are registered with the binder. + * These data are registered with the rpc svc system via svc_register. + * + * A service's dispatch function is called whenever an rpc request comes in + * on a transport. The request's program and version numbers must match + * those of the registered service. The dispatch function is passed two + * parameters, struct svc_req * and SVCXPRT *, defined below. + */ + +enum xprt_stat { + XPRT_DIED, + XPRT_MOREREQS, + XPRT_IDLE +}; + +/* + * Server side transport handle + */ +typedef struct SVCXPRT SVCXPRT; +struct SVCXPRT { + int xp_sock; + u_short xp_port; /* associated port number */ + const struct xp_ops { + bool_t (*xp_recv) (SVCXPRT *__xprt, struct rpc_msg *__msg); + /* receive incoming requests */ + enum xprt_stat (*xp_stat) (SVCXPRT *__xprt); + /* get transport status */ + bool_t (*xp_getargs) (SVCXPRT *__xprt, xdrproc_t __xdr_args, + caddr_t args_ptr); /* get arguments */ + bool_t (*xp_reply) (SVCXPRT *__xprt, struct rpc_msg *__msg); + /* send reply */ + bool_t (*xp_freeargs) (SVCXPRT *__xprt, xdrproc_t __xdr_args, + caddr_t args_ptr); + /* free mem allocated for args */ + void (*xp_destroy) (SVCXPRT *__xprt); + /* destroy this struct */ + } *xp_ops; + int xp_addrlen; /* length of remote address */ + struct sockaddr_in xp_raddr; /* remote address */ + struct opaque_auth xp_verf; /* raw response verifier */ + caddr_t xp_p1; /* private */ + caddr_t xp_p2; /* private */ + char xp_pad [256]; /* padding, internal use */ +}; + +/* + * Approved way of getting address of caller + */ +#define svc_getcaller(x) (&(x)->xp_raddr) + +/* + * Operations defined on an SVCXPRT handle + * + * SVCXPRT *xprt; + * struct rpc_msg *msg; + * xdrproc_t xargs; + * caddr_t argsp; + */ +#define SVC_RECV(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) +#define svc_recv(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) + +#define SVC_STAT(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) +#define svc_stat(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) + +#define SVC_GETARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) +#define svc_getargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) + +#define SVC_REPLY(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) +#define svc_reply(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) + +#define SVC_FREEARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) +#define svc_freeargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) + +#define SVC_DESTROY(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) +#define svc_destroy(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) + + +/* + * Service request + */ +struct svc_req { + rpcprog_t rq_prog; /* service program number */ + rpcvers_t rq_vers; /* service protocol version */ + rpcproc_t rq_proc; /* the desired procedure */ + struct opaque_auth rq_cred; /* raw creds from the wire */ + caddr_t rq_clntcred; /* read only cooked cred */ + SVCXPRT *rq_xprt; /* associated transport */ +}; + +#ifndef __DISPATCH_FN_T +#define __DISPATCH_FN_T +typedef void (*__dispatch_fn_t) (struct svc_req*, SVCXPRT*); +#endif + +/* + * Service registration + * + * svc_register(xprt, prog, vers, dispatch, protocol) + * SVCXPRT *xprt; + * rpcprog_t prog; + * rpcvers_t vers; + * void (*dispatch)(struct svc_req*, SVCXPRT*); + * rpcprot_t protocol; like TCP or UDP, zero means do not register + */ +extern bool_t svc_register (SVCXPRT *__xprt, rpcprog_t __prog, + rpcvers_t __vers, __dispatch_fn_t __dispatch, + rpcprot_t __protocol) __THROW; + +/* + * Service un-registration + * + * svc_unregister(prog, vers) + * rpcprog_t prog; + * rpcvers_t vers; + */ +extern void svc_unregister (rpcprog_t __prog, rpcvers_t __vers) __THROW; + +/* + * Transport registration. + * + * xprt_register(xprt) + * SVCXPRT *xprt; + */ +extern void xprt_register (SVCXPRT *__xprt) __THROW; + +/* + * Transport un-register + * + * xprt_unregister(xprt) + * SVCXPRT *xprt; + */ +extern void xprt_unregister (SVCXPRT *__xprt) __THROW; + + +/* + * When the service routine is called, it must first check to see if it + * knows about the procedure; if not, it should call svcerr_noproc + * and return. If so, it should deserialize its arguments via + * SVC_GETARGS (defined above). If the deserialization does not work, + * svcerr_decode should be called followed by a return. Successful + * decoding of the arguments should be followed the execution of the + * procedure's code and a call to svc_sendreply. + * + * Also, if the service refuses to execute the procedure due to too- + * weak authentication parameters, svcerr_weakauth should be called. + * Note: do not confuse access-control failure with weak authentication! + * + * NB: In pure implementations of rpc, the caller always waits for a reply + * msg. This message is sent when svc_sendreply is called. + * Therefore pure service implementations should always call + * svc_sendreply even if the function logically returns void; use + * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows + * for the abuse of pure rpc via batched calling or pipelining. In the + * case of a batched call, svc_sendreply should NOT be called since + * this would send a return message, which is what batching tries to avoid. + * It is the service/protocol writer's responsibility to know which calls are + * batched and which are not. Warning: responding to batch calls may + * deadlock the caller and server processes! + */ + +extern bool_t svc_sendreply (SVCXPRT *xprt, xdrproc_t __xdr_results, + caddr_t __xdr_location) __THROW; + +extern void svcerr_decode (SVCXPRT *__xprt) __THROW; + +extern void svcerr_weakauth (SVCXPRT *__xprt) __THROW; + +extern void svcerr_noproc (SVCXPRT *__xprt) __THROW; + +extern void svcerr_progvers (SVCXPRT *__xprt, rpcvers_t __low_vers, + rpcvers_t __high_vers) __THROW; + +extern void svcerr_auth (SVCXPRT *__xprt, enum auth_stat __why) __THROW; + +extern void svcerr_noprog (SVCXPRT *__xprt) __THROW; + +extern void svcerr_systemerr (SVCXPRT *__xprt) __THROW; + +/* + * Lowest level dispatching -OR- who owns this process anyway. + * Somebody has to wait for incoming requests and then call the correct + * service routine. The routine svc_run does infinite waiting; i.e., + * svc_run never returns. + * Since another (coexistent) package may wish to selectively wait for + * incoming calls or other events outside of the rpc architecture, the + * routine svc_getreq is provided. It must be passed readfds, the + * "in-place" results of a select system call (see select, section 2). + */ + +/* + * Global keeper of rpc service descriptors in use + * dynamic; must be inspected before each call to select + */ + +extern struct pollfd *svc_pollfd; +extern int svc_max_pollfd; +extern fd_set svc_fdset; +#define svc_fds svc_fdset.fds_bits[0] /* compatibility */ + +/* + * a small program implemented by the svc_rpc implementation itself; + * also see clnt.h for protocol numbers. + */ +extern void svc_getreq (int __rdfds) __THROW; +extern void svc_getreq_common (const int __fd) __THROW; +extern void svc_getreqset (fd_set *__readfds) __THROW; +extern void svc_getreq_poll (struct pollfd *, const int) __THROW; +extern void svc_exit (void) __THROW; +extern void svc_run (void) __THROW; + +/* + * Socket to use on svcxxx_create call to get default socket + */ +#define RPC_ANYSOCK -1 + +/* + * These are the existing service side transport implementations + */ + +/* + * Memory based rpc for testing and timing. + */ +extern SVCXPRT *svcraw_create (void) __THROW; + +/* + * Udp based rpc. + */ +extern SVCXPRT *svcudp_create (int __sock) __THROW; +extern SVCXPRT *svcudp_bufcreate (int __sock, u_int __sendsz, u_int __recvsz) + __THROW; + +/* + * Tcp based rpc. + */ +extern SVCXPRT *svctcp_create (int __sock, u_int __sendsize, u_int __recvsize) + __THROW; + + +/* + * Unix based rpc. + */ +extern SVCXPRT *svcunix_create (int __sock, u_int __sendsize, u_int __recvsize, + char *__path) __THROW; + + +__END_DECLS + +#endif /* rpc/svc.h */ diff --git a/conts/posix/libposix/include/posix/rpc/svc_auth.h b/conts/posix/libposix/include/posix/rpc/svc_auth.h new file mode 100644 index 0000000..1c1a715 --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/svc_auth.h @@ -0,0 +1,54 @@ +/* @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC */ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* @(#)svc_auth.h 1.6 86/07/16 SMI */ + +/* + * svc_auth.h, Service side of rpc authentication. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_SVC_AUTH_H +#define _RPC_SVC_AUTH_H 1 + +#include +#include + +__BEGIN_DECLS + +/* + * Server side authenticator + */ +extern enum auth_stat _authenticate (struct svc_req *__rqst, + struct rpc_msg *__msg) __THROW; + +__END_DECLS + +#endif /* rpc/svc_auth.h */ diff --git a/conts/posix/libposix/include/posix/rpc/types.h b/conts/posix/libposix/include/posix/rpc/types.h new file mode 100644 index 0000000..469576e --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/types.h @@ -0,0 +1,108 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ +/* fixincludes should not add extern "C" to this file */ +/* + * Rpc additions to + */ +#ifndef _RPC_TYPES_H +#define _RPC_TYPES_H 1 + +#ifdef _LIBC +/* Some adjustments to make the libc source from glibc + * compile more easily with uClibc... */ +#ifndef __FORCE_GLIBC +#define __FORCE_GLIBC +#endif +#ifndef _GNU_SOUCE +#define _GNU_SOUCE +#endif +#define _(X) X +#endif +#include + +typedef int bool_t; +typedef int enum_t; +/* This needs to be changed to uint32_t in the future */ +typedef unsigned long rpcprog_t; +typedef unsigned long rpcvers_t; +typedef unsigned long rpcproc_t; +typedef unsigned long rpcprot_t; +typedef unsigned long rpcport_t; + +#define __dontcare__ -1 + +#ifndef FALSE +# define FALSE (0) +#endif + +#ifndef TRUE +# define TRUE (1) +#endif + +#ifndef NULL +# define NULL 0 +#endif + +#include /* For malloc decl. */ +#define mem_alloc(bsize) malloc(bsize) +#define mem_free(ptr, bsize) free(ptr) + +#ifndef makedev /* ie, we haven't already included it */ +#include +#endif + +#ifndef __u_char_defined +typedef __u_char u_char; +typedef __u_short u_short; +typedef __u_int u_int; +typedef __u_long u_long; +typedef __quad_t quad_t; +typedef __u_quad_t u_quad_t; +typedef __fsid_t fsid_t; +# define __u_char_defined +#endif +#ifndef __daddr_t_defined +typedef __daddr_t daddr_t; +typedef __caddr_t caddr_t; +# define __daddr_t_defined +#endif + +#include +#include + +#include + +#ifndef INADDR_LOOPBACK +#define INADDR_LOOPBACK (u_long)0x7F000001 +#endif +#ifndef MAXHOSTNAMELEN +#define MAXHOSTNAMELEN 64 +#endif + +#endif /* rpc/types.h */ diff --git a/conts/posix/libposix/include/posix/rpc/xdr.h b/conts/posix/libposix/include/posix/rpc/xdr.h new file mode 100644 index 0000000..25dd214 --- /dev/null +++ b/conts/posix/libposix/include/posix/rpc/xdr.h @@ -0,0 +1,385 @@ +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + */ + +/* + * xdr.h, External Data Representation Serialization Routines. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_XDR_H +#define _RPC_XDR_H 1 + +#ifdef _LIBC +/* Some adjustments to make the libc source from glibc + * compile more easily with uClibc... */ +# ifndef __FORCE_GLIBC +# define __FORCE_GLIBC +# endif +# define _(X) X +#endif +#include +#include +#include + +/* We need FILE. */ +#include + +__BEGIN_DECLS + +/* + * XDR provides a conventional way for converting between C data + * types and an external bit-string representation. Library supplied + * routines provide for the conversion on built-in C data types. These + * routines and utility routines defined here are used to help implement + * a type encode/decode routine for each user-defined type. + * + * Each data type provides a single procedure which takes two arguments: + * + * bool_t + * xdrproc(xdrs, argresp) + * XDR *xdrs; + * *argresp; + * + * xdrs is an instance of a XDR handle, to which or from which the data + * type is to be converted. argresp is a pointer to the structure to be + * converted. The XDR handle contains an operation field which indicates + * which of the operations (ENCODE, DECODE * or FREE) is to be performed. + * + * XDR_DECODE may allocate space if the pointer argresp is null. This + * data can be freed with the XDR_FREE operation. + * + * We write only one procedure per data type to make it easy + * to keep the encode and decode procedures for a data type consistent. + * In many cases the same code performs all operations on a user defined type, + * because all the hard work is done in the component type routines. + * decode as a series of calls on the nested data types. + */ + +/* + * Xdr operations. XDR_ENCODE causes the type to be encoded into the + * stream. XDR_DECODE causes the type to be extracted from the stream. + * XDR_FREE can be used to release the space allocated by an XDR_DECODE + * request. + */ +enum xdr_op { + XDR_ENCODE = 0, + XDR_DECODE = 1, + XDR_FREE = 2 +}; + +/* + * This is the number of bytes per unit of external data. + */ +#define BYTES_PER_XDR_UNIT (4) +/* + * This only works if the above is a power of 2. But it's defined to be + * 4 by the appropriate RFCs. So it will work. And it's normally quicker + * than the old routine. + */ +#if 1 +#define RNDUP(x) (((x) + BYTES_PER_XDR_UNIT - 1) & ~(BYTES_PER_XDR_UNIT - 1)) +#else /* this is the old routine */ +#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ + * BYTES_PER_XDR_UNIT) +#endif + +/* + * The XDR handle. + * Contains operation which is being applied to the stream, + * an operations vector for the particular implementation (e.g. see xdr_mem.c), + * and two private fields for the use of the particular implementation. + */ +typedef struct XDR XDR; +struct XDR + { + enum xdr_op x_op; /* operation; fast additional param */ + struct xdr_ops + { + bool_t (*x_getlong) (XDR *__xdrs, long *__lp); + /* get a long from underlying stream */ + bool_t (*x_putlong) (XDR *__xdrs, __const long *__lp); + /* put a long to " */ + bool_t (*x_getbytes) (XDR *__xdrs, caddr_t __addr, u_int __len); + /* get some bytes from " */ + bool_t (*x_putbytes) (XDR *__xdrs, __const char *__addr, u_int __len); + /* put some bytes to " */ + u_int (*x_getpostn) (__const XDR *__xdrs); + /* returns bytes off from beginning */ + bool_t (*x_setpostn) (XDR *__xdrs, u_int __pos); + /* lets you reposition the stream */ + int32_t *(*x_inline) (XDR *__xdrs, u_int __len); + /* buf quick ptr to buffered data */ + void (*x_destroy) (XDR *__xdrs); + /* free privates of this xdr_stream */ + bool_t (*x_getint32) (XDR *__xdrs, int32_t *__ip); + /* get a int from underlying stream */ + bool_t (*x_putint32) (XDR *__xdrs, __const int32_t *__ip); + /* put a int to " */ + } + *x_ops; + caddr_t x_public; /* users' data */ + caddr_t x_private; /* pointer to private data */ + caddr_t x_base; /* private used for position info */ + u_int x_handy; /* extra private word */ + }; + +/* + * A xdrproc_t exists for each data type which is to be encoded or decoded. + * + * The second argument to the xdrproc_t is a pointer to an opaque pointer. + * The opaque pointer generally points to a structure of the data type + * to be decoded. If this pointer is 0, then the type routines should + * allocate dynamic storage of the appropriate size and return it. + * bool_t (*xdrproc_t)(XDR *, caddr_t *); + */ +typedef bool_t (*xdrproc_t) (XDR *, void *,...); + + +/* + * Operations defined on a XDR handle + * + * XDR *xdrs; + * int32_t *int32p; + * long *longp; + * caddr_t addr; + * u_int len; + * u_int pos; + */ +#define XDR_GETINT32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) +#define xdr_getint32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) + +#define XDR_PUTINT32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) +#define xdr_putint32(xdrs, int32p) \ + (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) + +#define XDR_GETLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) +#define xdr_getlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) + +#define XDR_PUTLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) +#define xdr_putlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) + +#define XDR_GETBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) +#define xdr_getbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) + +#define XDR_PUTBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) +#define xdr_putbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) + +#define XDR_GETPOS(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) +#define xdr_getpos(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) + +#define XDR_SETPOS(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) +#define xdr_setpos(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) + +#define XDR_INLINE(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) +#define xdr_inline(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) + +#define XDR_DESTROY(xdrs) \ + do { \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs); \ + } while (0) +#define xdr_destroy(xdrs) \ + do { \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs); \ + } while (0) + +/* + * Support struct for discriminated unions. + * You create an array of xdrdiscrim structures, terminated with + * a entry with a null procedure pointer. The xdr_union routine gets + * the discriminant value and then searches the array of structures + * for a matching value. If a match is found the associated xdr routine + * is called to handle that part of the union. If there is + * no match, then a default routine may be called. + * If there is no match and no default routine it is an error. + */ +#define NULL_xdrproc_t ((xdrproc_t)0) +struct xdr_discrim +{ + int value; + xdrproc_t proc; +}; + +/* + * Inline routines for fast encode/decode of primitive data types. + * Caveat emptor: these use single memory cycles to get the + * data from the underlying buffer, and will fail to operate + * properly if the data is not aligned. The standard way to use these + * is to say: + * if ((buf = XDR_INLINE(xdrs, count)) == NULL) + * return (FALSE); + * <<< macro calls >>> + * where ``count'' is the number of bytes of data occupied + * by the primitive data types. + * + * N.B. and frozen for all time: each data type here uses 4 bytes + * of external representation. + */ + +#define IXDR_GET_INT32(buf) ((int32_t)ntohl((uint32_t)*(buf)++)) +#define IXDR_PUT_INT32(buf, v) (*(buf)++ = (int32_t)htonl((uint32_t)(v))) +#define IXDR_GET_U_INT32(buf) ((uint32_t)IXDR_GET_INT32(buf)) +#define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32(buf, (int32_t)(v)) + +/* WARNING: The IXDR_*_LONG defines are removed by Sun for new platforms + * and shouldn't be used any longer. Code which use this defines or longs + * in the RPC code will not work on 64bit Solaris platforms ! + */ +#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf)) +#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v))) +#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) +#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG(buf, (long)(v)) + + +#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) +#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) +#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) +#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) + +#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG(buf, (long)(v)) +#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG(buf, (long)(v)) +#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG(buf, (long)(v)) +#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG(buf, (long)(v)) + +/* + * These are the "generic" xdr routines. + * None of these can have const applied because it's not possible to + * know whether the call is a read or a write to the passed parameter + * also, the XDR structure is always updated by some of these calls. + */ +extern bool_t xdr_void (void) __THROW; +extern bool_t xdr_short (XDR *__xdrs, short *__sp) __THROW; +extern bool_t xdr_u_short (XDR *__xdrs, u_short *__usp) __THROW; +extern bool_t xdr_int (XDR *__xdrs, int *__ip) __THROW; +extern bool_t xdr_u_int (XDR *__xdrs, u_int *__up) __THROW; +extern bool_t xdr_long (XDR *__xdrs, long *__lp) __THROW; +extern bool_t xdr_u_long (XDR *__xdrs, u_long *__ulp) __THROW; +extern bool_t xdr_hyper (XDR *__xdrs, quad_t *__llp) __THROW; +extern bool_t xdr_u_hyper (XDR *__xdrs, u_quad_t *__ullp) __THROW; +extern bool_t xdr_longlong_t (XDR *__xdrs, quad_t *__llp) __THROW; +extern bool_t xdr_u_longlong_t (XDR *__xdrs, u_quad_t *__ullp) __THROW; +extern bool_t xdr_int8_t (XDR *__xdrs, int8_t *__ip) __THROW; +extern bool_t xdr_uint8_t (XDR *__xdrs, uint8_t *__up) __THROW; +extern bool_t xdr_int16_t (XDR *__xdrs, int16_t *__ip) __THROW; +extern bool_t xdr_uint16_t (XDR *__xdrs, uint16_t *__up) __THROW; +extern bool_t xdr_int32_t (XDR *__xdrs, int32_t *__ip) __THROW; +extern bool_t xdr_uint32_t (XDR *__xdrs, uint32_t *__up) __THROW; +extern bool_t xdr_int64_t (XDR *__xdrs, int64_t *__ip) __THROW; +extern bool_t xdr_uint64_t (XDR *__xdrs, uint64_t *__up) __THROW; +extern bool_t xdr_bool (XDR *__xdrs, bool_t *__bp) __THROW; +extern bool_t xdr_enum (XDR *__xdrs, enum_t *__ep) __THROW; +extern bool_t xdr_array (XDR * _xdrs, caddr_t *__addrp, u_int *__sizep, + u_int __maxsize, u_int __elsize, xdrproc_t __elproc) + __THROW; +extern bool_t xdr_bytes (XDR *__xdrs, char **__cpp, u_int *__sizep, + u_int __maxsize) __THROW; +extern bool_t xdr_opaque (XDR *__xdrs, caddr_t __cp, u_int __cnt) __THROW; +extern bool_t xdr_string (XDR *__xdrs, char **__cpp, u_int __maxsize) __THROW; +extern bool_t xdr_union (XDR *__xdrs, enum_t *__dscmp, char *__unp, + __const struct xdr_discrim *__choices, + xdrproc_t dfault) __THROW; +extern bool_t xdr_char (XDR *__xdrs, char *__cp) __THROW; +extern bool_t xdr_u_char (XDR *__xdrs, u_char *__cp) __THROW; +extern bool_t xdr_vector (XDR *__xdrs, char *__basep, u_int __nelem, + u_int __elemsize, xdrproc_t __xdr_elem) __THROW; +extern bool_t xdr_float (XDR *__xdrs, float *__fp) __THROW; +extern bool_t xdr_double (XDR *__xdrs, double *__dp) __THROW; +extern bool_t xdr_reference (XDR *__xdrs, caddr_t *__xpp, u_int __size, + xdrproc_t __proc) __THROW; +extern bool_t xdr_pointer (XDR *__xdrs, char **__objpp, + u_int __obj_size, xdrproc_t __xdr_obj) __THROW; +extern bool_t xdr_wrapstring (XDR *__xdrs, char **__cpp) __THROW; +extern u_long xdr_sizeof (xdrproc_t, void *) __THROW; + +/* + * Common opaque bytes objects used by many rpc protocols; + * declared here due to commonality. + */ +#define MAX_NETOBJ_SZ 1024 +struct netobj +{ + u_int n_len; + char *n_bytes; +}; +typedef struct netobj netobj; +extern bool_t xdr_netobj (XDR *__xdrs, struct netobj *__np) __THROW; + +/* + * These are the public routines for the various implementations of + * xdr streams. + */ + +/* XDR using memory buffers */ +extern void xdrmem_create (XDR *__xdrs, __const caddr_t __addr, + u_int __size, enum xdr_op __xop) __THROW; + +/* XDR using stdio library */ +extern void xdrstdio_create (XDR *__xdrs, FILE *__file, enum xdr_op __xop) + __THROW; + +/* XDR pseudo records for tcp */ +extern void xdrrec_create (XDR *__xdrs, u_int __sendsize, + u_int __recvsize, caddr_t __tcp_handle, + int (*__readit) (char *, char *, int), + int (*__writeit) (char *, char *, int)) __THROW; + +/* make end of xdr record */ +extern bool_t xdrrec_endofrecord (XDR *__xdrs, bool_t __sendnow) __THROW; + +/* move to beginning of next record */ +extern bool_t xdrrec_skiprecord (XDR *__xdrs) __THROW; + +/* true if no more input */ +extern bool_t xdrrec_eof (XDR *__xdrs) __THROW; + +/* free memory buffers for xdr */ +extern void xdr_free (xdrproc_t __proc, char *__objp) __THROW; + +__END_DECLS + +#endif /* rpc/xdr.h */ diff --git a/conts/posix/libposix/include/posix/sched.h b/conts/posix/libposix/include/posix/sched.h new file mode 100644 index 0000000..7cfdbf1 --- /dev/null +++ b/conts/posix/libposix/include/posix/sched.h @@ -0,0 +1,86 @@ +/* Definitions for POSIX 1003.1b-1993 (aka POSIX.4) scheduling interface. + Copyright (C) 1996,1997,1999,2001-2003,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SCHED_H +#define _SCHED_H 1 + +#include + +/* Get type definitions. */ +#include + +#define __need_timespec +#include + +/* Get system specific constant and data structure definitions. */ +#include +/* Define the real names for the elements of `struct sched_param'. */ +#define sched_priority __sched_priority + + +__BEGIN_DECLS + +/* Set scheduling parameters for a process. */ +extern int sched_setparam (__pid_t __pid, __const struct sched_param *__param) + __THROW; + +/* Retrieve scheduling parameters for a particular process. */ +extern int sched_getparam (__pid_t __pid, struct sched_param *__param) __THROW; + +/* Set scheduling algorithm and/or parameters for a process. */ +extern int sched_setscheduler (__pid_t __pid, int __policy, + __const struct sched_param *__param) __THROW; + +/* Retrieve scheduling algorithm for a particular purpose. */ +extern int sched_getscheduler (__pid_t __pid) __THROW; + +/* Yield the processor. */ +extern int sched_yield (void) __THROW; + +/* Get maximum priority value for a scheduler. */ +extern int sched_get_priority_max (int __algorithm) __THROW; + +/* Get minimum priority value for a scheduler. */ +extern int sched_get_priority_min (int __algorithm) __THROW; + +/* Get the SCHED_RR interval for the named process. */ +extern int sched_rr_get_interval (__pid_t __pid, struct timespec *__t) __THROW; + + +#ifdef __USE_GNU +/* Access macros for `cpu_set'. */ +#define CPU_SETSIZE __CPU_SETSIZE +#define CPU_SET(cpu, cpusetp) __CPU_SET (cpu, cpusetp) +#define CPU_CLR(cpu, cpusetp) __CPU_CLR (cpu, cpusetp) +#define CPU_ISSET(cpu, cpusetp) __CPU_ISSET (cpu, cpusetp) +#define CPU_ZERO(cpusetp) __CPU_ZERO (cpusetp) + + +/* Set the CPU affinity for a task */ +extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize, + __const cpu_set_t *__cpuset) __THROW; + +/* Get the CPU affinity for a task */ +extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize, + cpu_set_t *__cpuset) __THROW; +#endif + +__END_DECLS + +#endif /* sched.h */ diff --git a/conts/posix/libposix/include/posix/scsi/scsi.h b/conts/posix/libposix/include/posix/scsi/scsi.h new file mode 100644 index 0000000..49ab758 --- /dev/null +++ b/conts/posix/libposix/include/posix/scsi/scsi.h @@ -0,0 +1,226 @@ +/* Copyright (C) 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * This header file contains public constants and structures used by + * the scsi code for linux. + */ + +#ifndef _SCSI_SCSI_H +#define _SCSI_SCSI_H 1 + +#include + +/* + * SCSI opcodes + */ + +#define TEST_UNIT_READY 0x00 +#define REZERO_UNIT 0x01 +#define REQUEST_SENSE 0x03 +#define FORMAT_UNIT 0x04 +#define READ_BLOCK_LIMITS 0x05 +#define REASSIGN_BLOCKS 0x07 +#define READ_6 0x08 +#define WRITE_6 0x0a +#define SEEK_6 0x0b +#define READ_REVERSE 0x0f +#define WRITE_FILEMARKS 0x10 +#define SPACE 0x11 +#define INQUIRY 0x12 +#define RECOVER_BUFFERED_DATA 0x14 +#define MODE_SELECT 0x15 +#define RESERVE 0x16 +#define RELEASE 0x17 +#define COPY 0x18 +#define ERASE 0x19 +#define MODE_SENSE 0x1a +#define START_STOP 0x1b +#define RECEIVE_DIAGNOSTIC 0x1c +#define SEND_DIAGNOSTIC 0x1d +#define ALLOW_MEDIUM_REMOVAL 0x1e + +#define SET_WINDOW 0x24 +#define READ_CAPACITY 0x25 +#define READ_10 0x28 +#define WRITE_10 0x2a +#define SEEK_10 0x2b +#define WRITE_VERIFY 0x2e +#define VERIFY 0x2f +#define SEARCH_HIGH 0x30 +#define SEARCH_EQUAL 0x31 +#define SEARCH_LOW 0x32 +#define SET_LIMITS 0x33 +#define PRE_FETCH 0x34 +#define READ_POSITION 0x34 +#define SYNCHRONIZE_CACHE 0x35 +#define LOCK_UNLOCK_CACHE 0x36 +#define READ_DEFECT_DATA 0x37 +#define MEDIUM_SCAN 0x38 +#define COMPARE 0x39 +#define COPY_VERIFY 0x3a +#define WRITE_BUFFER 0x3b +#define READ_BUFFER 0x3c +#define UPDATE_BLOCK 0x3d +#define READ_LONG 0x3e +#define WRITE_LONG 0x3f +#define CHANGE_DEFINITION 0x40 +#define WRITE_SAME 0x41 +#define READ_TOC 0x43 +#define LOG_SELECT 0x4c +#define LOG_SENSE 0x4d +#define MODE_SELECT_10 0x55 +#define RESERVE_10 0x56 +#define RELEASE_10 0x57 +#define MODE_SENSE_10 0x5a +#define PERSISTENT_RESERVE_IN 0x5e +#define PERSISTENT_RESERVE_OUT 0x5f +#define MOVE_MEDIUM 0xa5 +#define READ_12 0xa8 +#define WRITE_12 0xaa +#define WRITE_VERIFY_12 0xae +#define SEARCH_HIGH_12 0xb0 +#define SEARCH_EQUAL_12 0xb1 +#define SEARCH_LOW_12 0xb2 +#define READ_ELEMENT_STATUS 0xb8 +#define SEND_VOLUME_TAG 0xb6 +#define WRITE_LONG_2 0xea + +/* + * Status codes + */ + +#define GOOD 0x00 +#define CHECK_CONDITION 0x01 +#define CONDITION_GOOD 0x02 +#define BUSY 0x04 +#define INTERMEDIATE_GOOD 0x08 +#define INTERMEDIATE_C_GOOD 0x0a +#define RESERVATION_CONFLICT 0x0c +#define COMMAND_TERMINATED 0x11 +#define QUEUE_FULL 0x14 + +#define STATUS_MASK 0x3e + +/* + * SENSE KEYS + */ + +#define NO_SENSE 0x00 +#define RECOVERED_ERROR 0x01 +#define NOT_READY 0x02 +#define MEDIUM_ERROR 0x03 +#define HARDWARE_ERROR 0x04 +#define ILLEGAL_REQUEST 0x05 +#define UNIT_ATTENTION 0x06 +#define DATA_PROTECT 0x07 +#define BLANK_CHECK 0x08 +#define COPY_ABORTED 0x0a +#define ABORTED_COMMAND 0x0b +#define VOLUME_OVERFLOW 0x0d +#define MISCOMPARE 0x0e + + +/* + * DEVICE TYPES + */ + +#define TYPE_DISK 0x00 +#define TYPE_TAPE 0x01 +#define TYPE_PROCESSOR 0x03 /* HP scanners use this */ +#define TYPE_WORM 0x04 /* Treated as ROM by our system */ +#define TYPE_ROM 0x05 +#define TYPE_SCANNER 0x06 +#define TYPE_MOD 0x07 /* Magneto-optical disk - + * - treated as TYPE_DISK */ +#define TYPE_MEDIUM_CHANGER 0x08 +#define TYPE_ENCLOSURE 0x0d /* Enclosure Services Device */ +#define TYPE_NO_LUN 0x7f + +/* + * standard mode-select header prepended to all mode-select commands + * + * moved here from cdrom.h -- kraxel + */ + +struct ccs_modesel_head + { + unsigned char _r1; /* reserved. */ + unsigned char medium; /* device-specific medium type. */ + unsigned char _r2; /* reserved. */ + unsigned char block_desc_length; /* block descriptor length. */ + unsigned char density; /* device-specific density code. */ + unsigned char number_blocks_hi; /* number of blocks in this block + desc. */ + unsigned char number_blocks_med; + unsigned char number_blocks_lo; + unsigned char _r3; + unsigned char block_length_hi; /* block length for blocks in this + desc. */ + unsigned char block_length_med; + unsigned char block_length_lo; + }; + +/* + * MESSAGE CODES + */ + +#define COMMAND_COMPLETE 0x00 +#define EXTENDED_MESSAGE 0x01 +#define EXTENDED_MODIFY_DATA_POINTER 0x00 +#define EXTENDED_SDTR 0x01 +#define EXTENDED_EXTENDED_IDENTIFY 0x02 /* SCSI-I only */ +#define EXTENDED_WDTR 0x03 +#define SAVE_POINTERS 0x02 +#define RESTORE_POINTERS 0x03 +#define DISCONNECT 0x04 +#define INITIATOR_ERROR 0x05 +#define ABORT 0x06 +#define MESSAGE_REJECT 0x07 +#define NOP 0x08 +#define MSG_PARITY_ERROR 0x09 +#define LINKED_CMD_COMPLETE 0x0a +#define LINKED_FLG_CMD_COMPLETE 0x0b +#define BUS_DEVICE_RESET 0x0c + +#define INITIATE_RECOVERY 0x0f /* SCSI-II only */ +#define RELEASE_RECOVERY 0x10 /* SCSI-II only */ + +#define SIMPLE_QUEUE_TAG 0x20 +#define HEAD_OF_QUEUE_TAG 0x21 +#define ORDERED_QUEUE_TAG 0x22 + +/* + * Here are some scsi specific ioctl commands which are sometimes useful. + */ +/* These are a few other constants only used by scsi devices. */ + +#define SCSI_IOCTL_GET_IDLUN 0x5382 + +/* Used to turn on and off tagged queuing for scsi devices. */ + +#define SCSI_IOCTL_TAGGED_ENABLE 0x5383 +#define SCSI_IOCTL_TAGGED_DISABLE 0x5384 + +/* Used to obtain the host number of a device. */ +#define SCSI_IOCTL_PROBE_HOST 0x5385 + +/* Used to get the bus number for a device. */ +#define SCSI_IOCTL_GET_BUS_NUMBER 0x5386 + +#endif /* scsi/scsi.h */ diff --git a/conts/posix/libposix/include/posix/scsi/scsi_ioctl.h b/conts/posix/libposix/include/posix/scsi/scsi_ioctl.h new file mode 100644 index 0000000..11f0161 --- /dev/null +++ b/conts/posix/libposix/include/posix/scsi/scsi_ioctl.h @@ -0,0 +1,34 @@ +/* Copyright (C) 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SCSI_IOCTL_H +#define _SCSI_IOCTL_H + +/* IOCTLs for SCSI. */ +#define SCSI_IOCTL_SEND_COMMAND 1 /* Send a command to the SCSI host. */ +#define SCSI_IOCTL_TEST_UNIT_READY 2 /* Test if unit is ready. */ +#define SCSI_IOCTL_BENCHMARK_COMMAND 3 +#define SCSI_IOCTL_SYNC 4 /* Request synchronous parameters. */ +#define SCSI_IOCTL_START_UNIT 5 +#define SCSI_IOCTL_STOP_UNIT 6 +#define SCSI_IOCTL_DOORLOCK 0x5380 /* Lock the eject mechanism. */ +#define SCSI_IOCTL_DOORUNLOCK 0x5381 /* Unlock the mechanism. */ + +#endif + + diff --git a/conts/posix/libposix/include/posix/scsi/sg.h b/conts/posix/libposix/include/posix/scsi/sg.h new file mode 100644 index 0000000..b0dc0ad --- /dev/null +++ b/conts/posix/libposix/include/posix/scsi/sg.h @@ -0,0 +1,275 @@ +/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + History: + Started: Aug 9 by Lawrence Foard (entropy@world.std.com), to allow user + process control of SCSI devices. + Development Sponsored by Killy Corp. NY NY +*/ + +#ifndef _SCSI_SG_H +#define _SCSI_SG_H 1 + +#include + + +/* New interface introduced in the 3.x SG drivers follows */ + +/* Same structure as used by readv() Linux system call. It defines one + scatter-gather element. */ +typedef struct sg_iovec +{ + void * iov_base; /* Starting address */ + size_t iov_len; /* Length in bytes */ +} sg_iovec_t; + + +typedef struct sg_io_hdr +{ + int interface_id; /* [i] 'S' for SCSI generic (required) */ + int dxfer_direction; /* [i] data transfer direction */ + unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */ + unsigned char mx_sb_len; /* [i] max length to write to sbp */ + unsigned short int iovec_count; /* [i] 0 implies no scatter gather */ + unsigned int dxfer_len; /* [i] byte count of data transfer */ + void * dxferp; /* [i], [*io] points to data transfer memory + or scatter gather list */ + unsigned char * cmdp; /* [i], [*i] points to command to perform */ + unsigned char * sbp; /* [i], [*o] points to sense_buffer memory */ + unsigned int timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */ + unsigned int flags; /* [i] 0 -> default, see SG_FLAG... */ + int pack_id; /* [i->o] unused internally (normally) */ + void * usr_ptr; /* [i->o] unused internally */ + unsigned char status; /* [o] scsi status */ + unsigned char masked_status;/* [o] shifted, masked scsi status */ + unsigned char msg_status; /* [o] messaging level data (optional) */ + unsigned char sb_len_wr; /* [o] byte count actually written to sbp */ + unsigned short int host_status; /* [o] errors from host adapter */ + unsigned short int driver_status;/* [o] errors from software driver */ + int resid; /* [o] dxfer_len - actual_transferred */ + unsigned int duration; /* [o] time taken by cmd (unit: millisec) */ + unsigned int info; /* [o] auxiliary information */ +} sg_io_hdr_t; + + +/* Use negative values to flag difference from original sg_header structure. */ +#define SG_DXFER_NONE -1 /* e.g. a SCSI Test Unit Ready command */ +#define SG_DXFER_TO_DEV -2 /* e.g. a SCSI WRITE command */ +#define SG_DXFER_FROM_DEV -3 /* e.g. a SCSI READ command */ +#define SG_DXFER_TO_FROM_DEV -4 /* treated like SG_DXFER_FROM_DEV with the + additional property than during indirect + IO the user buffer is copied into the + kernel buffers before the transfer */ + + +/* following flag values can be "or"-ed together */ +#define SG_FLAG_DIRECT_IO 1 /* default is indirect IO */ +#define SG_FLAG_LUN_INHIBIT 2 /* default is to put device's lun into */ + /* the 2nd byte of SCSI command */ +#define SG_FLAG_NO_DXFER 0x10000 /* no transfer of kernel buffers to/from */ + /* user space (debug indirect IO) */ + +/* The following 'info' values are "or"-ed together. */ +#define SG_INFO_OK_MASK 0x1 +#define SG_INFO_OK 0x0 /* no sense, host nor driver "noise" */ +#define SG_INFO_CHECK 0x1 /* something abnormal happened */ + +#define SG_INFO_DIRECT_IO_MASK 0x6 +#define SG_INFO_INDIRECT_IO 0x0 /* data xfer via kernel buffers (or no xfer) */ +#define SG_INFO_DIRECT_IO 0x2 /* direct IO requested and performed */ +#define SG_INFO_MIXED_IO 0x4 /* part direct, part indirect IO */ + + +/* Request information about a specific SG device, used by + SG_GET_SCSI_ID ioctl (). */ +struct sg_scsi_id { + /* Host number as in "scsi" where 'n' is one of 0, 1, 2 etc. */ + int host_no; + int channel; + /* SCSI id of target device. */ + int scsi_id; + int lun; + /* TYPE_... defined in . */ + int scsi_type; + /* Host (adapter) maximum commands per lun. */ + short int h_cmd_per_lun; + /* Device (or adapter) maximum queue length. */ + short int d_queue_depth; + /* Unused, set to 0 for now. */ + int unused[2]; +}; + +/* Used by SG_GET_REQUEST_TABLE ioctl(). */ +typedef struct sg_req_info { + char req_state; /* 0 -> not used, 1 -> written, 2 -> ready to read */ + char orphan; /* 0 -> normal request, 1 -> from interruped SG_IO */ + char sg_io_owned; /* 0 -> complete with read(), 1 -> owned by SG_IO */ + char problem; /* 0 -> no problem detected, 1 -> error to report */ + int pack_id; /* pack_id associated with request */ + void * usr_ptr; /* user provided pointer (in new interface) */ + unsigned int duration; /* millisecs elapsed since written (req_state==1) + or request duration (req_state==2) */ + int unused; +} sg_req_info_t; + + +/* IOCTLs: Those ioctls that are relevant to the SG 3.x drivers follow. + [Those that only apply to the SG 2.x drivers are at the end of the file.] + (_GET_s yield result via 'int *' 3rd argument unless otherwise indicated) */ + +#define SG_EMULATED_HOST 0x2203 /* true for emulated host adapter (ATAPI) */ + +/* Used to configure SCSI command transformation layer for ATAPI devices */ +/* Only supported by the ide-scsi driver */ +#define SG_SET_TRANSFORM 0x2204 /* N.B. 3rd arg is not pointer but value: */ + /* 3rd arg = 0 to disable transform, 1 to enable it */ +#define SG_GET_TRANSFORM 0x2205 + +#define SG_SET_RESERVED_SIZE 0x2275 /* request a new reserved buffer size */ +#define SG_GET_RESERVED_SIZE 0x2272 /* actual size of reserved buffer */ + +/* The following ioctl has a 'sg_scsi_id_t *' object as its 3rd argument. */ +#define SG_GET_SCSI_ID 0x2276 /* Yields fd's bus, chan, dev, lun + type */ +/* SCSI id information can also be obtained from SCSI_IOCTL_GET_IDLUN */ + +/* Override host setting and always DMA using low memory ( <16MB on i386) */ +#define SG_SET_FORCE_LOW_DMA 0x2279 /* 0-> use adapter setting, 1-> force */ +#define SG_GET_LOW_DMA 0x227a /* 0-> use all ram for dma; 1-> low dma ram */ + +/* When SG_SET_FORCE_PACK_ID set to 1, pack_id is input to read() which + tries to fetch a packet with a matching pack_id, waits, or returns EAGAIN. + If pack_id is -1 then read oldest waiting. When ...FORCE_PACK_ID set to 0 + then pack_id ignored by read() and oldest readable fetched. */ +#define SG_SET_FORCE_PACK_ID 0x227b +#define SG_GET_PACK_ID 0x227c /* Yields oldest readable pack_id (or -1) */ + +#define SG_GET_NUM_WAITING 0x227d /* Number of commands awaiting read() */ + +/* Yields max scatter gather tablesize allowed by current host adapter */ +#define SG_GET_SG_TABLESIZE 0x227F /* 0 implies can't do scatter gather */ + +#define SG_GET_VERSION_NUM 0x2282 /* Example: version 2.1.34 yields 20134 */ + +/* Returns -EBUSY if occupied. 3rd argument pointer to int (see next) */ +#define SG_SCSI_RESET 0x2284 +/* Associated values that can be given to SG_SCSI_RESET follow */ +#define SG_SCSI_RESET_NOTHING 0 +#define SG_SCSI_RESET_DEVICE 1 +#define SG_SCSI_RESET_BUS 2 +#define SG_SCSI_RESET_HOST 3 + +/* synchronous SCSI command ioctl, (only in version 3 interface) */ +#define SG_IO 0x2285 /* similar effect as write() followed by read() */ + +#define SG_GET_REQUEST_TABLE 0x2286 /* yields table of active requests */ + +/* How to treat EINTR during SG_IO ioctl(), only in SG 3.x series */ +#define SG_SET_KEEP_ORPHAN 0x2287 /* 1 -> hold for read(), 0 -> drop (def) */ +#define SG_GET_KEEP_ORPHAN 0x2288 + + +#define SG_SCATTER_SZ (8 * 4096) /* PAGE_SIZE not available to user */ +/* Largest size (in bytes) a single scatter-gather list element can have. + The value must be a power of 2 and <= (PAGE_SIZE * 32) [131072 bytes on + i386]. The minimum value is PAGE_SIZE. If scatter-gather not supported + by adapter then this value is the largest data block that can be + read/written by a single scsi command. The user can find the value of + PAGE_SIZE by calling getpagesize() defined in unistd.h . */ + +#define SG_DEFAULT_RETRIES 1 + +/* Defaults, commented if they differ from original sg driver */ +#define SG_DEF_FORCE_LOW_DMA 0 /* was 1 -> memory below 16MB on i386 */ +#define SG_DEF_FORCE_PACK_ID 0 +#define SG_DEF_KEEP_ORPHAN 0 +#define SG_DEF_RESERVED_SIZE SG_SCATTER_SZ /* load time option */ + +/* maximum outstanding requests, write() yields EDOM if exceeded */ +#define SG_MAX_QUEUE 16 + +#define SG_BIG_BUFF SG_DEF_RESERVED_SIZE /* for backward compatibility */ + +/* Alternate style type names, "..._t" variants preferred */ +typedef struct sg_io_hdr Sg_io_hdr; +typedef struct sg_io_vec Sg_io_vec; +typedef struct sg_scsi_id Sg_scsi_id; +typedef struct sg_req_info Sg_req_info; + + +/* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ +/* The older SG interface based on the 'sg_header' structure follows. */ +/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */ + +#define SG_MAX_SENSE 16 /* this only applies to the sg_header interface */ + +struct sg_header + { + /* Length of incoming packet (including header). */ + int pack_len; + /* Maximal length of expected reply. */ + int reply_len; + /* Id number of packet. */ + int pack_id; + /* 0==ok, otherwise error number. */ + int result; + /* Force 12 byte command length for group 6 & 7 commands. */ + unsigned int twelve_byte:1; + /* SCSI status from target. */ + unsigned int target_status:5; + /* Host status (see "DID" codes). */ + unsigned int host_status:8; + /* Driver status+suggestion. */ + unsigned int driver_status:8; + /* Unused. */ + unsigned int other_flags:10; + /* Output in 3 cases: + when target_status is CHECK_CONDITION or + when target_status is COMMAND_TERMINATED or + when (driver_status & DRIVER_SENSE) is true. */ + unsigned char sense_buffer[SG_MAX_SENSE]; + }; + + +/* IOCTLs: The following are not required (or ignored) when the sg_io_hdr_t + interface is used. They are kept for backward compatibility with + the original and version 2 drivers. */ + +#define SG_SET_TIMEOUT 0x2201 /* Set timeout; *(int *)arg==timeout. */ +#define SG_GET_TIMEOUT 0x2202 /* Get timeout; return timeout. */ + +/* Get/set command queuing state per fd (default is SG_DEF_COMMAND_Q). */ +#define SG_GET_COMMAND_Q 0x2270 /* Yields 0 (queuing off) or 1 (on). */ +#define SG_SET_COMMAND_Q 0x2271 /* Change queuing state with 0 or 1. */ + +/* Turn on error sense trace (1..8), dump this device to log/console (9) + or dump all sg device states ( >9 ) to log/console. */ +#define SG_SET_DEBUG 0x227e /* 0 -> turn off debug */ + +#define SG_NEXT_CMD_LEN 0x2283 /* Override SCSI command length with given + number on the next write() on this file + descriptor. */ + +/* Defaults, commented if they differ from original sg driver */ +#define SG_DEFAULT_TIMEOUT (60*HZ) /* HZ == 'jiffies in 1 second' */ +#define SG_DEF_COMMAND_Q 0 /* command queuing is always on when + the new interface is used */ +#define SG_DEF_UNDERRUN_FLAG 0 + + +#endif /* scsi/sg.h */ diff --git a/conts/posix/libposix/include/posix/search.h b/conts/posix/libposix/include/posix/search.h new file mode 100644 index 0000000..2ffba69 --- /dev/null +++ b/conts/posix/libposix/include/posix/search.h @@ -0,0 +1,175 @@ +/* Declarations for System V style searching functions. + Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SEARCH_H +#define _SEARCH_H 1 + +#include + +#define __need_size_t +#include + +__BEGIN_DECLS + +#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED +/* Prototype structure for a linked-list data structure. + This is the type used by the `insque' and `remque' functions. */ + +# ifdef __USE_GNU +struct qelem + { + struct qelem *q_forw; + struct qelem *q_back; + char q_data[1]; + }; +# endif + + +/* Insert ELEM into a doubly-linked list, after PREV. */ +extern void insque (void *__elem, void *__prev) __THROW; + +/* Unlink ELEM from the doubly-linked list that it is in. */ +extern void remque (void *__elem) __THROW; +#endif + + +/* For use with hsearch(3). */ +#ifndef __COMPAR_FN_T +# define __COMPAR_FN_T +typedef int (*__compar_fn_t) (__const void *, __const void *); + +# ifdef __USE_GNU +typedef __compar_fn_t comparison_fn_t; +# endif +#endif + +/* Action which shall be performed in the call the hsearch. */ +typedef enum + { + FIND, + ENTER + } +ACTION; + +typedef struct entry + { + char *key; + void *data; + } +ENTRY; + +/* Opaque type for internal use. */ +struct _ENTRY; + +/* Family of hash table handling functions. The functions also + have reentrant counterparts ending with _r. The non-reentrant + functions all work on a signle internal hashing table. */ + +/* Search for entry matching ITEM.key in internal hash table. If + ACTION is `FIND' return found entry or signal error by returning + NULL. If ACTION is `ENTER' replace existing data (if any) with + ITEM.data. */ +extern ENTRY *hsearch (ENTRY __item, ACTION __action) __THROW; + +/* Create a new hashing table which will at most contain NEL elements. */ +extern int hcreate (size_t __nel) __THROW; + +/* Destroy current internal hashing table. */ +extern void hdestroy (void) __THROW; + +#ifdef __USE_GNU +/* Data type for reentrant functions. */ +struct hsearch_data + { + struct _ENTRY *table; + unsigned int size; + unsigned int filled; + }; + +/* Reentrant versions which can handle multiple hashing tables at the + same time. */ +extern int hsearch_r (ENTRY __item, ACTION __action, ENTRY **__retval, + struct hsearch_data *__htab) __THROW; +extern int hcreate_r (size_t __nel, struct hsearch_data *__htab) __THROW; +extern void hdestroy_r (struct hsearch_data *__htab) __THROW; +#endif + + +/* The tsearch routines are very interesting. They make many + assumptions about the compiler. It assumes that the first field + in node must be the "key" field, which points to the datum. + Everything depends on that. */ +/* For tsearch */ +typedef enum +{ + preorder, + postorder, + endorder, + leaf +} +VISIT; + +/* Search for an entry matching the given KEY in the tree pointed to + by *ROOTP and insert a new element if not found. */ +extern void *tsearch (__const void *__key, void **__rootp, + __compar_fn_t __compar); + +/* Search for an entry matching the given KEY in the tree pointed to + by *ROOTP. If no matching entry is available return NULL. */ +extern void *tfind (__const void *__key, void *__const *__rootp, + __compar_fn_t __compar); + +/* Remove the element matching KEY from the tree pointed to by *ROOTP. */ +extern void *tdelete (__const void *__restrict __key, + void **__restrict __rootp, + __compar_fn_t __compar); + +#ifndef __ACTION_FN_T +# define __ACTION_FN_T +typedef void (*__action_fn_t) (__const void *__nodep, VISIT __value, + int __level); +#endif + +/* Walk through the whole tree and call the ACTION callback for every node + or leaf. */ +extern void twalk (__const void *__root, __action_fn_t __action); + +#ifdef __USE_GNU +/* Callback type for function to free a tree node. If the keys are atomic + data this function should do nothing. */ +typedef void (*__free_fn_t) (void *__nodep); + +/* Destroy the whole tree, call FREEFCT for each node or leaf. */ +extern void tdestroy (void *__root, __free_fn_t __freefct); +#endif + + +/* Perform linear search for KEY by comparing by COMPAR in an array + [BASE,BASE+NMEMB*SIZE). */ +extern void *lfind (__const void *__key, __const void *__base, + size_t *__nmemb, size_t __size, __compar_fn_t __compar); + +/* Perform linear search for KEY by comparing by COMPAR function in + array [BASE,BASE+NMEMB*SIZE) and insert entry if not found. */ +extern void *lsearch (__const void *__key, void *__base, + size_t *__nmemb, size_t __size, __compar_fn_t __compar); + +__END_DECLS + +#endif /* search.h */ diff --git a/conts/posix/libposix/include/posix/setjmp.h b/conts/posix/libposix/include/posix/setjmp.h new file mode 100644 index 0000000..99e3dc8 --- /dev/null +++ b/conts/posix/libposix/include/posix/setjmp.h @@ -0,0 +1,104 @@ +/* Copyright (C) 1991-1999, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard: 7.13 Nonlocal jumps + */ + +#ifndef _SETJMP_H +#define _SETJMP_H 1 + +#include + +__BEGIN_DECLS + +#include /* Get `__jmp_buf'. */ +#include /* Get `__sigset_t'. */ + +/* Calling environment, plus possibly a saved signal mask. */ +typedef struct __jmp_buf_tag /* C++ doesn't like tagless structs. */ + { + /* NOTE: The machine-dependent definitions of `__sigsetjmp' + assume that a `jmp_buf' begins with a `__jmp_buf' and that + `__mask_was_saved' follows it. Do not move these members + or add others before it. */ + __jmp_buf __jmpbuf; /* Calling environment. */ + int __mask_was_saved; /* Saved the signal mask? */ + __sigset_t __saved_mask; /* Saved signal mask. */ + } jmp_buf[1]; + + +/* Store the calling environment in ENV, also saving the signal mask. + Return 0. */ +extern int setjmp (jmp_buf __env) __THROW; + +/* Store the calling environment in ENV, not saving the signal mask. + Return 0. */ +extern int _setjmp (jmp_buf __env) __THROW; + +/* Store the calling environment in ENV, also saving the + signal mask if SAVEMASK is nonzero. Return 0. + This is the internal name for `sigsetjmp'. */ +extern int __sigsetjmp (jmp_buf __env, int __savemask) __THROW; + +#ifndef __FAVOR_BSD +/* Do not save the signal mask. This is equivalent to the `_setjmp' + BSD function. */ +# define setjmp(env) _setjmp (env) +#else +/* We are in 4.3 BSD-compatibility mode in which `setjmp' + saves the signal mask like `sigsetjmp (ENV, 1)'. We have to + define a macro since ISO C says `setjmp' is one. */ +# define setjmp(env) setjmp (env) +#endif /* Favor BSD. */ + + +/* Jump to the environment saved in ENV, making the + `setjmp' call there return VAL, or 1 if VAL is 0. */ +extern void longjmp (jmp_buf __env, int __val) + __THROW __attribute__ ((__noreturn__)); +#if defined __USE_BSD || defined __USE_XOPEN +/* Same. Usually `_longjmp' is used with `_setjmp', which does not save + the signal mask. But it is how ENV was saved that determines whether + `longjmp' restores the mask; `_longjmp' is just an alias. */ +extern void _longjmp (jmp_buf __env, int __val) + __THROW __attribute__ ((__noreturn__)); +#endif + + +#ifdef __USE_POSIX +/* Use the same type for `jmp_buf' and `sigjmp_buf'. + The `__mask_was_saved' flag determines whether + or not `longjmp' will restore the signal mask. */ +typedef jmp_buf sigjmp_buf; + +/* Store the calling environment in ENV, also saving the + signal mask if SAVEMASK is nonzero. Return 0. */ +# define sigsetjmp(env, savemask) __sigsetjmp (env, savemask) + +/* Jump to the environment saved in ENV, making the + sigsetjmp call there return VAL, or 1 if VAL is 0. + Restore the signal mask if that sigsetjmp call saved it. + This is just an alias `longjmp'. */ +extern void siglongjmp (sigjmp_buf __env, int __val) + __THROW __attribute__ ((__noreturn__)); +#endif /* Use POSIX. */ + +__END_DECLS + +#endif /* setjmp.h */ diff --git a/conts/posix/libposix/include/posix/sgtty.h b/conts/posix/libposix/include/posix/sgtty.h new file mode 100644 index 0000000..5b2bc41 --- /dev/null +++ b/conts/posix/libposix/include/posix/sgtty.h @@ -0,0 +1,41 @@ +/* Copyright (C) 1991, 1992, 1996, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SGTTY_H +#define _SGTTY_H 1 + +#include + +#include + +/* On some systems this type is not defined by ; + in that case, the functions are just stubs that return ENOSYS. */ +struct sgttyb; + +__BEGIN_DECLS + +/* Fill in *PARAMS with terminal parameters associated with FD. */ +extern int gtty (int __fd, struct sgttyb *__params) __THROW; + +/* Set the terminal parameters associated with FD to *PARAMS. */ +extern int stty (int __fd, __const struct sgttyb *__params) __THROW; + + +__END_DECLS + +#endif /* sgtty.h */ diff --git a/conts/posix/libposix/include/posix/shadow.h b/conts/posix/libposix/include/posix/shadow.h new file mode 100644 index 0000000..778df52 --- /dev/null +++ b/conts/posix/libposix/include/posix/shadow.h @@ -0,0 +1,149 @@ +/* Copyright (C) 1996, 1997, 1998, 1999, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Declaration of types and functions for shadow password suite. */ + +#ifndef _SHADOW_H +#define _SHADOW_H 1 + +#include + +#include + +#define __need_FILE +#include +#define __need_size_t +#include + +/* Paths to the user database files. */ +#define SHADOW _PATH_SHADOW + + +__BEGIN_DECLS + +/* Structure of the password file. */ +struct spwd + { + char *sp_namp; /* Login name. */ + char *sp_pwdp; /* Encrypted password. */ + long int sp_lstchg; /* Date of last change. */ + long int sp_min; /* Minimum number of days between changes. */ + long int sp_max; /* Maximum number of days between changes. */ + long int sp_warn; /* Number of days to warn user to change + the password. */ + long int sp_inact; /* Number of days the account may be + inactive. */ + long int sp_expire; /* Number of days since 1970-01-01 until + account expires. */ + unsigned long int sp_flag; /* Reserved. */ + }; + + +/* Open database for reading. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern void setspent (void); + +/* Close database. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern void endspent (void); + +/* Get next entry from database, perhaps after opening the file. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern struct spwd *getspent (void); + +/* Get shadow entry matching NAME. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern struct spwd *getspnam (__const char *__name); + +/* Read shadow entry from STRING. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern struct spwd *sgetspent (__const char *__string); + +/* Read next shadow entry from STREAM. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern struct spwd *fgetspent (FILE *__stream); + +/* Write line containing shadow password entry to stream. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int putspent (__const struct spwd *__p, FILE *__stream); + + +#ifdef __USE_MISC +/* Reentrant versions of some of the functions above. + + These functions are not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation they are cancellation points and + therefore not marked with __THROW. */ +extern int getspent_r (struct spwd *__result_buf, char *__buffer, + size_t __buflen, struct spwd **__result); + +extern int getspnam_r (__const char *__name, struct spwd *__result_buf, + char *__buffer, size_t __buflen, + struct spwd **__result); + +extern int sgetspent_r (__const char *__string, struct spwd *__result_buf, + char *__buffer, size_t __buflen, + struct spwd **__result); + +extern int fgetspent_r (FILE *__stream, struct spwd *__result_buf, + char *__buffer, size_t __buflen, + struct spwd **__result); +#endif /* misc */ + + +/* The simple locking functionality provided here is not suitable for + multi-threaded applications. */ + +/* Protect password file against multi writers. */ +extern int lckpwdf (void) __THROW; + +/* Unlock password file. */ +extern int ulckpwdf (void) __THROW; + +__END_DECLS + +#endif /* shadow.h */ diff --git a/conts/posix/libposix/include/posix/shpage.h b/conts/posix/libposix/include/posix/shpage.h new file mode 100644 index 0000000..1d12790 --- /dev/null +++ b/conts/posix/libposix/include/posix/shpage.h @@ -0,0 +1,45 @@ +/* + * A default shared page is used by every thread + * to pass large data for system calls. + * + * This file contains relevant shpage definitions. + */ +#ifndef __LIBPOSIX_SHPAGE_H__ +#define __LIBPOSIX_SHPAGE_H__ + +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) + +extern void *shared_page; + +int shared_page_init(void); + +/* + * Arguments that are too large to fit in message registers are + * copied onto another area that is still on the utcb, and the servers + * map-in the task utcb and read those arguments from there. + */ + +static inline int copy_to_shpage(void *arg, int offset, int size) +{ + if (offset + size > PAGE_SIZE) + return -1; + + memcpy(shared_page + offset, arg, size); + return 0; +} + +static inline int copy_from_shpage(void *buf, int offset, int size) +{ + if (offset + size > PAGE_SIZE) + return -1; + + memcpy(buf, shared_page + offset, size); + return 0; +} + +#endif /* __LIBPOSIX_SHPAGE_H__ */ diff --git a/conts/posix/libposix/include/posix/signal.h b/conts/posix/libposix/include/posix/signal.h new file mode 100644 index 0000000..288febd --- /dev/null +++ b/conts/posix/libposix/include/posix/signal.h @@ -0,0 +1,401 @@ +/* Copyright (C) 1991-2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard: 7.14 Signal handling + */ + +#ifndef _SIGNAL_H + +#if !defined __need_sig_atomic_t && !defined __need_sigset_t +# define _SIGNAL_H +#endif + +#include + +__BEGIN_DECLS + +#include /* __sigset_t, __sig_atomic_t. */ + +/* An integral type that can be modified atomically, without the + possibility of a signal arriving in the middle of the operation. */ +#if defined __need_sig_atomic_t || defined _SIGNAL_H +# ifndef __sig_atomic_t_defined +# define __sig_atomic_t_defined +__BEGIN_NAMESPACE_STD +typedef __sig_atomic_t sig_atomic_t; +__END_NAMESPACE_STD +# endif +# undef __need_sig_atomic_t +#endif + +#if defined __need_sigset_t || (defined _SIGNAL_H && defined __USE_POSIX) +# ifndef __sigset_t_defined +# define __sigset_t_defined +typedef __sigset_t sigset_t; +# endif +# undef __need_sigset_t +#endif + +#ifdef _SIGNAL_H + +#include +#include + +#if defined __USE_XOPEN || defined __USE_XOPEN2K +# ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +#endif +#ifdef __USE_XOPEN +# endif +# ifndef __uid_t_defined +typedef __uid_t uid_t; +# define __uid_t_defined +# endif +#endif /* Unix98 */ + + +/* Type of a signal handler. */ +typedef void (*__sighandler_t) (int); + +/* The X/Open definition of `signal' specifies the SVID semantic. Use + the additional function `sysv_signal' when X/Open compatibility is + requested. */ +extern __sighandler_t __sysv_signal (int __sig, __sighandler_t __handler) + __THROW; +#ifdef __USE_GNU +extern __sighandler_t sysv_signal (int __sig, __sighandler_t __handler) + __THROW; +#endif + +/* Set the handler for the signal SIG to HANDLER, returning the old + handler, or SIG_ERR on error. + By default `signal' has the BSD semantic. */ +__BEGIN_NAMESPACE_STD +#ifdef __USE_BSD +extern __sighandler_t signal (int __sig, __sighandler_t __handler) + __THROW; +#else +/* Make sure the used `signal' implementation is the SVID version. */ +# ifdef __REDIRECT_NTH +extern __sighandler_t __REDIRECT_NTH (signal, + (int __sig, __sighandler_t __handler), + __sysv_signal); +# else +# define signal __sysv_signal +# endif +#endif +__END_NAMESPACE_STD + +#ifdef __USE_XOPEN +/* The X/Open definition of `signal' conflicts with the BSD version. + So they defined another function `bsd_signal'. */ +extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler) + __THROW; +#endif + +/* Send signal SIG to process number PID. If PID is zero, + send SIG to all processes in the current process's process group. + If PID is < -1, send SIG to all processes in process group - PID. */ +#ifdef __USE_POSIX +extern int kill (__pid_t __pid, int __sig) __THROW; +#endif /* Use POSIX. */ + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED +/* Send SIG to all processes in process group PGRP. + If PGRP is zero, send SIG to all processes in + the current process's process group. */ +extern int killpg (__pid_t __pgrp, int __sig) __THROW; +#endif /* Use BSD || X/Open Unix. */ + +__BEGIN_NAMESPACE_STD +/* Raise signal SIG, i.e., send SIG to yourself. */ +extern int raise (int __sig) __THROW; +__END_NAMESPACE_STD + +#ifdef __USE_SVID +/* SVID names for the same things. */ +extern __sighandler_t ssignal (int __sig, __sighandler_t __handler) + __THROW; +extern int gsignal (int __sig) __THROW; +#endif /* Use SVID. */ + +#ifdef __USE_MISC +/* Print a message describing the meaning of the given signal number. */ +extern void psignal (int __sig, __const char *__s); +#endif /* Use misc. */ + + +/* The `sigpause' function has two different interfaces. The original + BSD definition defines the argument as a mask of the signal, while + the more modern interface in X/Open defines it as the signal + number. We go with the BSD version unless the user explicitly + selects the X/Open version. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int __sigpause (int __sig_or_mask, int __is_sig); + +#ifdef __FAVOR_BSD +/* Set the mask of blocked signals to MASK, + wait for a signal to arrive, and then restore the mask. */ +extern int sigpause (int __mask) __THROW __attribute_deprecated__; +# define sigpause(mask) __sigpause ((mask), 0) +#else +# ifdef __USE_XOPEN +/* Remove a signal from the signal mask and suspend the process. */ +# define sigpause(sig) __sigpause ((sig), 1) +# endif +#endif + + +#ifdef __USE_BSD +/* None of the following functions should be used anymore. They are here + only for compatibility. A single word (`int') is not guaranteed to be + enough to hold a complete signal mask and therefore these functions + simply do not work in many situations. Use `sigprocmask' instead. */ + +/* Compute mask for signal SIG. */ +# define sigmask(sig) __sigmask(sig) + +/* Block signals in MASK, returning the old mask. */ +extern int sigblock (int __mask) __THROW __attribute_deprecated__; + +/* Set the mask of blocked signals to MASK, returning the old mask. */ +extern int sigsetmask (int __mask) __THROW __attribute_deprecated__; + +/* Return currently selected signal mask. */ +extern int siggetmask (void) __THROW __attribute_deprecated__; +#endif /* Use BSD. */ + + +#ifdef __USE_MISC +# define NSIG _NSIG +#endif + +#ifdef __USE_GNU +typedef __sighandler_t sighandler_t; +#endif + +/* 4.4 BSD uses the name `sig_t' for this. */ +#ifdef __USE_BSD +typedef __sighandler_t sig_t; +#endif + +#ifdef __USE_POSIX + +# ifdef __USE_POSIX199309 +/* We need `struct timespec' later on. */ +# define __need_timespec +# include + +/* Get the `siginfo_t' type plus the needed symbols. */ +# include +# endif + +/* Clear all signals from SET. */ +extern int sigemptyset (sigset_t *__set) __THROW __nonnull ((1)); + +/* Set all signals in SET. */ +extern int sigfillset (sigset_t *__set) __THROW __nonnull ((1)); + +/* Add SIGNO to SET. */ +extern int sigaddset (sigset_t *__set, int __signo) __THROW __nonnull ((1)); + +/* Remove SIGNO from SET. */ +extern int sigdelset (sigset_t *__set, int __signo) __THROW __nonnull ((1)); + +/* Return 1 if SIGNO is in SET, 0 if not. */ +extern int sigismember (__const sigset_t *__set, int __signo) + __THROW __nonnull ((1)); + +# ifdef __USE_GNU +/* Return non-empty value is SET is not empty. */ +extern int sigisemptyset (__const sigset_t *__set) __THROW __nonnull ((1)); + +/* Build new signal set by combining the two inputs set using logical AND. */ +extern int sigandset (sigset_t *__set, __const sigset_t *__left, + __const sigset_t *__right) __THROW __nonnull ((1, 2, 3)); + +/* Build new signal set by combining the two inputs set using logical OR. */ +extern int sigorset (sigset_t *__set, __const sigset_t *__left, + __const sigset_t *__right) __THROW __nonnull ((1, 2, 3)); +# endif /* GNU */ + +/* Get the system-specific definitions of `struct sigaction' + and the `SA_*' and `SIG_*'. constants. */ +# include + +/* Get and/or change the set of blocked signals. */ +extern int sigprocmask (int __how, __const sigset_t *__restrict __set, + sigset_t *__restrict __oset) __THROW; + +/* Change the set of blocked signals to SET, + wait until a signal arrives, and restore the set of blocked signals. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int sigsuspend (__const sigset_t *__set) __nonnull ((1)); + +/* Get and/or set the action for signal SIG. */ +extern int sigaction (int __sig, __const struct sigaction *__restrict __act, + struct sigaction *__restrict __oact) __THROW; + +/* Put in SET all signals that are blocked and waiting to be delivered. */ +extern int sigpending (sigset_t *__set) __THROW __nonnull ((1)); + + +/* Select any of pending signals from SET or wait for any to arrive. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int sigwait (__const sigset_t *__restrict __set, int *__restrict __sig) + __nonnull ((1, 2)); + +# ifdef __USE_POSIX199309 +/* Select any of pending signals from SET and place information in INFO. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int sigwaitinfo (__const sigset_t *__restrict __set, + siginfo_t *__restrict __info) __nonnull ((1)); + +/* Select any of pending signals from SET and place information in INFO. + Wait the time specified by TIMEOUT if no signal is pending. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int sigtimedwait (__const sigset_t *__restrict __set, + siginfo_t *__restrict __info, + __const struct timespec *__restrict __timeout) + __nonnull ((1)); + +/* Send signal SIG to the process PID. Associate data in VAL with the + signal. */ +extern int sigqueue (__pid_t __pid, int __sig, __const union sigval __val) + __THROW; +# endif /* Use POSIX 199306. */ + +#endif /* Use POSIX. */ + +#ifdef __USE_BSD + +#ifdef __UCLIBC_HAS_SYS_SIGLIST__ +/* Names of the signals. This variable exists only for compatibility. + Use `strsignal' instead (see ). */ +#define _sys_siglist sys_siglist +extern __const char *__const sys_siglist[_NSIG]; +#endif /* __UCLIBC_HAS_SYS_SIGLIST__ */ + +/* Structure passed to `sigvec'. */ +struct sigvec + { + __sighandler_t sv_handler; /* Signal handler. */ + int sv_mask; /* Mask of signals to be blocked. */ + + int sv_flags; /* Flags (see below). */ +# define sv_onstack sv_flags /* 4.2 BSD compatibility. */ + }; + +/* Bits in `sv_flags'. */ +# define SV_ONSTACK (1 << 0)/* Take the signal on the signal stack. */ +# define SV_INTERRUPT (1 << 1)/* Do not restart system calls. */ +# define SV_RESETHAND (1 << 2)/* Reset handler to SIG_DFL on receipt. */ + + +/* If VEC is non-NULL, set the handler for SIG to the `sv_handler' member + of VEC. The signals in `sv_mask' will be blocked while the handler runs. + If the SV_RESETHAND bit is set in `sv_flags', the handler for SIG will be + reset to SIG_DFL before `sv_handler' is entered. If OVEC is non-NULL, + it is filled in with the old information for SIG. */ +extern int sigvec (int __sig, __const struct sigvec *__vec, + struct sigvec *__ovec) __THROW; + + +/* Get machine-dependent `struct sigcontext' and signal subcodes. */ +# include + +/* Restore the state saved in SCP. */ +extern int sigreturn (struct sigcontext *__scp) __THROW; + +#endif /* use BSD. */ + + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED + +/* If INTERRUPT is nonzero, make signal SIG interrupt system calls + (causing them to fail with EINTR); if INTERRUPT is zero, make system + calls be restarted after signal SIG. */ +extern int siginterrupt (int __sig, int __interrupt) __THROW; + +# include +# ifdef __USE_XOPEN +/* This will define `ucontext_t' and `mcontext_t'. */ +# include +# endif + +/* Run signals handlers on the stack specified by SS (if not NULL). + If OSS is not NULL, it is filled in with the old signal stack status. + This interface is obsolete and on many platform not implemented. */ +extern int sigstack (struct sigstack *__ss, struct sigstack *__oss) + __THROW __attribute_deprecated__; + +/* Alternate signal handler stack interface. + This interface should always be preferred over `sigstack'. */ +extern int sigaltstack (__const struct sigaltstack *__restrict __ss, + struct sigaltstack *__restrict __oss) __THROW; + +#endif /* use BSD or X/Open Unix. */ + +#ifdef __USE_XOPEN_EXTENDED +/* Simplified interface for signal management. */ + +/* Add SIG to the calling process' signal mask. */ +extern int sighold (int __sig) __THROW; + +/* Remove SIG from the calling process' signal mask. */ +extern int sigrelse (int __sig) __THROW; + +/* Set the disposition of SIG to SIG_IGN. */ +extern int sigignore (int __sig) __THROW; + +/* Set the disposition of SIG. */ +extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __THROW; +#endif + +#if defined __UCLIBC_HAS_THREADS__ && (defined __USE_POSIX199506 || defined __USE_UNIX98) +/* Some of the functions for handling signals in threaded programs must + be defined here. */ +# include +# include +#endif /* use Unix98 */ + +/* The following functions are used internally in the C library and in + other code which need deep insights. */ + +/* Return number of available real-time signal with highest priority. */ +extern int __libc_current_sigrtmin (void) __THROW; +/* Return number of available real-time signal with lowest priority. */ +extern int __libc_current_sigrtmax (void) __THROW; + +#endif /* signal.h */ + +__END_DECLS + +#endif /* not signal.h */ diff --git a/conts/posix/libposix/include/posix/stdint.h b/conts/posix/libposix/include/posix/stdint.h new file mode 100644 index 0000000..2f4020e --- /dev/null +++ b/conts/posix/libposix/include/posix/stdint.h @@ -0,0 +1,332 @@ +/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99: 7.18 Integer types + */ + +#ifndef _STDINT_H +#define _STDINT_H 1 + +#include +#ifdef __UCLIBC_HAS_WCHAR__ +#include +#endif /* __UCLIBC_HAS_WCHAR__ */ +#include + +/* Exact integral types. */ + +/* Signed. */ + +/* There is some amount of overlap with as known by inet code */ +#ifndef __int8_t_defined +# define __int8_t_defined +typedef signed char int8_t; +typedef short int int16_t; +typedef int int32_t; +# if __WORDSIZE == 64 +typedef long int int64_t; +# else +__extension__ +typedef long long int int64_t; +# endif +#endif + +/* Unsigned. */ +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +#ifndef __uint32_t_defined +typedef unsigned int uint32_t; +# define __uint32_t_defined +#endif +#if __WORDSIZE == 64 +typedef unsigned long int uint64_t; +#else +__extension__ +typedef unsigned long long int uint64_t; +#endif + + +/* Small types. */ + +/* Signed. */ +typedef signed char int_least8_t; +typedef short int int_least16_t; +typedef int int_least32_t; +#if __WORDSIZE == 64 +typedef long int int_least64_t; +#else +__extension__ +typedef long long int int_least64_t; +#endif + +/* Unsigned. */ +typedef unsigned char uint_least8_t; +typedef unsigned short int uint_least16_t; +typedef unsigned int uint_least32_t; +#if __WORDSIZE == 64 +typedef unsigned long int uint_least64_t; +#else +__extension__ +typedef unsigned long long int uint_least64_t; +#endif + + +/* Fast types. */ + +/* Signed. */ +typedef signed char int_fast8_t; +#if __WORDSIZE == 64 +typedef long int int_fast16_t; +typedef long int int_fast32_t; +typedef long int int_fast64_t; +#else +typedef int int_fast16_t; +typedef int int_fast32_t; +__extension__ +typedef long long int int_fast64_t; +#endif + +/* Unsigned. */ +typedef unsigned char uint_fast8_t; +#if __WORDSIZE == 64 +typedef unsigned long int uint_fast16_t; +typedef unsigned long int uint_fast32_t; +typedef unsigned long int uint_fast64_t; +#else +typedef unsigned int uint_fast16_t; +typedef unsigned int uint_fast32_t; +__extension__ +typedef unsigned long long int uint_fast64_t; +#endif + + +/* Types for `void *' pointers. */ +#if __WORDSIZE == 64 +# ifndef __intptr_t_defined +typedef long int intptr_t; +# define __intptr_t_defined +# endif +typedef unsigned long int uintptr_t; +#else +# ifndef __intptr_t_defined +typedef int intptr_t; +# define __intptr_t_defined +# endif +typedef unsigned int uintptr_t; +#endif + + +/* Largest integral types. */ +#if __WORDSIZE == 64 +typedef long int intmax_t; +typedef unsigned long int uintmax_t; +#else +__extension__ +typedef long long int intmax_t; +__extension__ +typedef unsigned long long int uintmax_t; +#endif + + +/* The ISO C99 standard specifies that in C++ implementations these + macros should only be defined if explicitly requested. */ +#if !defined __cplusplus || defined __STDC_LIMIT_MACROS + +# if __WORDSIZE == 64 +# define __INT64_C(c) c ## L +# define __UINT64_C(c) c ## UL +# else +# define __INT64_C(c) c ## LL +# define __UINT64_C(c) c ## ULL +# endif + +/* Limits of integral types. */ + +/* Minimum of signed integral types. */ +# define INT8_MIN (-128) +# define INT16_MIN (-32767-1) +# define INT32_MIN (-2147483647-1) +# define INT64_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum of signed integral types. */ +# define INT8_MAX (127) +# define INT16_MAX (32767) +# define INT32_MAX (2147483647) +# define INT64_MAX (__INT64_C(9223372036854775807)) + +/* Maximum of unsigned integral types. */ +# define UINT8_MAX (255) +# define UINT16_MAX (65535) +# define UINT32_MAX (4294967295U) +# define UINT64_MAX (__UINT64_C(18446744073709551615)) + + +/* Minimum of signed integral types having a minimum size. */ +# define INT_LEAST8_MIN (-128) +# define INT_LEAST16_MIN (-32767-1) +# define INT_LEAST32_MIN (-2147483647-1) +# define INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum of signed integral types having a minimum size. */ +# define INT_LEAST8_MAX (127) +# define INT_LEAST16_MAX (32767) +# define INT_LEAST32_MAX (2147483647) +# define INT_LEAST64_MAX (__INT64_C(9223372036854775807)) + +/* Maximum of unsigned integral types having a minimum size. */ +# define UINT_LEAST8_MAX (255) +# define UINT_LEAST16_MAX (65535) +# define UINT_LEAST32_MAX (4294967295U) +# define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615)) + + +/* Minimum of fast signed integral types having a minimum size. */ +# define INT_FAST8_MIN (-128) +# if __WORDSIZE == 64 +# define INT_FAST16_MIN (-9223372036854775807L-1) +# define INT_FAST32_MIN (-9223372036854775807L-1) +# else +# define INT_FAST16_MIN (-2147483647-1) +# define INT_FAST32_MIN (-2147483647-1) +# endif +# define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum of fast signed integral types having a minimum size. */ +# define INT_FAST8_MAX (127) +# if __WORDSIZE == 64 +# define INT_FAST16_MAX (9223372036854775807L) +# define INT_FAST32_MAX (9223372036854775807L) +# else +# define INT_FAST16_MAX (2147483647) +# define INT_FAST32_MAX (2147483647) +# endif +# define INT_FAST64_MAX (__INT64_C(9223372036854775807)) + +/* Maximum of fast unsigned integral types having a minimum size. */ +# define UINT_FAST8_MAX (255) +# if __WORDSIZE == 64 +# define UINT_FAST16_MAX (18446744073709551615UL) +# define UINT_FAST32_MAX (18446744073709551615UL) +# else +# define UINT_FAST16_MAX (4294967295U) +# define UINT_FAST32_MAX (4294967295U) +# endif +# define UINT_FAST64_MAX (__UINT64_C(18446744073709551615)) + + +/* Values to test for integral types holding `void *' pointer. */ +# if __WORDSIZE == 64 +# define INTPTR_MIN (-9223372036854775807L-1) +# define INTPTR_MAX (9223372036854775807L) +# define UINTPTR_MAX (18446744073709551615UL) +# else +# define INTPTR_MIN (-2147483647-1) +# define INTPTR_MAX (2147483647) +# define UINTPTR_MAX (4294967295U) +# endif + +#if !defined(__H8300H__) && !defined(__H8300S__) +/* Minimum for largest signed integral type. */ +# define INTMAX_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum for largest signed integral type. */ +# define INTMAX_MAX (__INT64_C(9223372036854775807)) + +/* Maximum for largest unsigned integral type. */ +# define UINTMAX_MAX (__UINT64_C(18446744073709551615)) +#else +/* Minimum for largest signed integral type. */ +# define INTMAX_MIN (-LONG_LONG_MAX-1) +/* Maximum for largest signed integral type. */ +# define INTMAX_MAX (LONG_LONG_MAX) + +/* Maximum for largest unsigned integral type. */ +# define UINTMAX_MAX (LONG_LONG_MAX<<1+1) +#endif + +/* Limits of other integer types. */ + +/* Limits of `ptrdiff_t' type. */ +# if __WORDSIZE == 64 +# define PTRDIFF_MIN (-9223372036854775807L-1) +# define PTRDIFF_MAX (9223372036854775807L) +# else +# define PTRDIFF_MIN (-2147483647-1) +# define PTRDIFF_MAX (2147483647) +# endif + +/* Limits of `sig_atomic_t'. */ +# define SIG_ATOMIC_MIN (-2147483647-1) +# define SIG_ATOMIC_MAX (2147483647) + +/* Limit of `size_t' type. */ +# if __WORDSIZE == 64 +# define SIZE_MAX (18446744073709551615UL) +# else +# define SIZE_MAX (4294967295U) +# endif + +#ifdef __UCLIBC_HAS_WCHAR__ +/* Limits of `wchar_t'. */ +# ifndef WCHAR_MIN +/* These constants might also be defined in . */ +# define WCHAR_MIN __WCHAR_MIN +# define WCHAR_MAX __WCHAR_MAX +# endif + +/* Limits of `wint_t'. */ +# define WINT_MIN (0u) +# define WINT_MAX (4294967295u) +#endif /* __UCLIBC_HAS_WCHAR__ */ + +#endif /* C++ && limit macros */ + + +/* The ISO C99 standard specifies that in C++ implementations these + should only be defined if explicitly requested. */ +#if !defined __cplusplus || defined __STDC_CONSTANT_MACROS + +/* Signed. */ +# define INT8_C(c) c +# define INT16_C(c) c +# define INT32_C(c) c +# if __WORDSIZE == 64 +# define INT64_C(c) c ## L +# else +# define INT64_C(c) c ## LL +# endif + +/* Unsigned. */ +# define UINT8_C(c) c ## U +# define UINT16_C(c) c ## U +# define UINT32_C(c) c ## U +# if __WORDSIZE == 64 +# define UINT64_C(c) c ## UL +# else +# define UINT64_C(c) c ## ULL +# endif + +/* Maximal type. */ +# if __WORDSIZE == 64 +# define INTMAX_C(c) c ## L +# define UINTMAX_C(c) c ## UL +# else +# define INTMAX_C(c) c ## LL +# define UINTMAX_C(c) c ## ULL +# endif + +#endif /* C++ && constant macros */ + +#endif /* stdint.h */ diff --git a/conts/posix/libposix/include/posix/stdio.h b/conts/posix/libposix/include/posix/stdio.h new file mode 100644 index 0000000..fd2a738 --- /dev/null +++ b/conts/posix/libposix/include/posix/stdio.h @@ -0,0 +1,873 @@ +/* + Copyright (C) 1991,1994-2002,2003,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard: 7.19 Input/output + */ + +#ifndef _STDIO_H + +#if !defined __need_FILE && !defined __need___FILE +# define _STDIO_H 1 +# include + +__BEGIN_DECLS + +# define __need_size_t +# define __need_NULL +# include + +# include +# define __need_FILE +# define __need___FILE +#endif /* Don't need FILE. */ + + +#if !defined __FILE_defined && defined __need_FILE + +__BEGIN_NAMESPACE_STD +/* The opaque type of streams. This is the definition used elsewhere. */ +typedef struct __STDIO_FILE_STRUCT FILE; +__END_NAMESPACE_STD +#if defined __USE_LARGEFILE64 || defined __USE_SVID || defined __USE_POSIX \ + || defined __USE_BSD || defined __USE_ISOC99 || defined __USE_XOPEN \ + || defined __USE_POSIX2 +__USING_NAMESPACE_STD(FILE) +#endif + +# define __FILE_defined 1 +#endif /* FILE not defined. */ +#undef __need_FILE + + +#if !defined ____FILE_defined && defined __need___FILE + +/* The opaque type of streams. This is the definition used elsewhere. */ +typedef struct __STDIO_FILE_STRUCT __FILE; + +# define ____FILE_defined 1 +#endif /* __FILE not defined. */ +#undef __need___FILE + + +#ifdef _STDIO_H +#undef _STDIO_USES_IOSTREAM + +#include + +/* This define avoids name pollution if we're using GNU stdarg.h */ +# define __need___va_list +#include + +/* The type of the second argument to `fgetpos' and `fsetpos'. */ +__BEGIN_NAMESPACE_STD +#ifndef __USE_FILE_OFFSET64 +typedef __STDIO_fpos_t fpos_t; +#else +typedef __STDIO_fpos64_t fpos_t; +#endif +__END_NAMESPACE_STD +#ifdef __USE_LARGEFILE64 +typedef __STDIO_fpos64_t fpos64_t; +#endif + +/* The possibilities for the third argument to `setvbuf'. */ +#define _IOFBF __STDIO_IOFBF /* Fully buffered. */ +#define _IOLBF __STDIO_IOLBF /* Line buffered. */ +#define _IONBF __STDIO_IONBF /* No buffering. */ + + +/* Default buffer size. */ +#ifndef BUFSIZ +# define BUFSIZ __STDIO_BUFSIZ +#endif + + +/* End of file character. + Some things throughout the library rely on this being -1. */ +#ifndef EOF +# define EOF (-1) +#endif + + +/* The possibilities for the third argument to `fseek'. + These values should not be changed. */ +#define SEEK_SET 0 /* Seek from beginning of file. */ +#define SEEK_CUR 1 /* Seek from current position. */ +#define SEEK_END 2 /* Seek from end of file. */ + + +#if defined __USE_SVID || defined __USE_XOPEN +/* Default path prefix for `tempnam' and `tmpnam'. */ +# define P_tmpdir "/tmp" +#endif + + +/* Get the values: + L_tmpnam How long an array of chars must be to be passed to `tmpnam'. + TMP_MAX The minimum number of unique filenames generated by tmpnam + (and tempnam when it uses tmpnam's name space), + or tempnam (the two are separate). + L_ctermid How long an array to pass to `ctermid'. + L_cuserid How long an array to pass to `cuserid'. + FOPEN_MAX Minimum number of files that can be open at once. + FILENAME_MAX Maximum length of a filename. */ +#include + + +/* Standard streams. */ +extern FILE *stdin; /* Standard input stream. */ +extern FILE *stdout; /* Standard output stream. */ +extern FILE *stderr; /* Standard error output stream. */ +/* C89/C99 say they're macros. Make them happy. */ +#define stdin stdin +#define stdout stdout +#define stderr stderr + +__BEGIN_NAMESPACE_STD +/* Remove file FILENAME. */ +extern int remove (__const char *__filename) __THROW; +/* Rename file OLD to NEW. */ +extern int rename (__const char *__old, __const char *__new) __THROW; +__END_NAMESPACE_STD + + +__BEGIN_NAMESPACE_STD +/* Create a temporary file and open it read/write. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +#ifndef __USE_FILE_OFFSET64 +extern FILE *tmpfile (void); +#else +# ifdef __REDIRECT +extern FILE *__REDIRECT (tmpfile, (void), tmpfile64); +# else +# define tmpfile tmpfile64 +# endif +#endif + +#ifdef __USE_LARGEFILE64 +extern FILE *tmpfile64 (void); +#endif + +/* Generate a temporary filename. */ +extern char *tmpnam (char *__s) __THROW; +__END_NAMESPACE_STD + +#ifdef __USE_MISC +/* This is the reentrant variant of `tmpnam'. The only difference is + that it does not allow S to be NULL. */ +extern char *tmpnam_r (char *__s) __THROW; +#endif + + +#if defined __USE_SVID || defined __USE_XOPEN +/* Generate a unique temporary filename using up to five characters of PFX + if it is not NULL. The directory to put this file in is searched for + as follows: First the environment variable "TMPDIR" is checked. + If it contains the name of a writable directory, that directory is used. + If not and if DIR is not NULL, that value is checked. If that fails, + P_tmpdir is tried and finally "/tmp". The storage for the filename + is allocated by `malloc'. */ +extern char *tempnam (__const char *__dir, __const char *__pfx) + __THROW __attribute_malloc__; +#endif + + +__BEGIN_NAMESPACE_STD +/* Close STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fclose (FILE *__stream); +/* Flush STREAM, or all streams if STREAM is NULL. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fflush (FILE *__stream); +__END_NAMESPACE_STD + +#ifdef __USE_MISC +/* Faster versions when locking is not required. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int fflush_unlocked (FILE *__stream); +#endif + +#ifdef __USE_GNU +/* Close all streams. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int fcloseall (void); +#endif + + +__BEGIN_NAMESPACE_STD +#ifndef __USE_FILE_OFFSET64 +/* Open a file and create a new stream for it. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern FILE *fopen (__const char *__restrict __filename, + __const char *__restrict __modes); +/* Open a file, replacing an existing stream with it. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern FILE *freopen (__const char *__restrict __filename, + __const char *__restrict __modes, + FILE *__restrict __stream); +#else +# ifdef __REDIRECT +extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename, + __const char *__restrict __modes), fopen64); +extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename, + __const char *__restrict __modes, + FILE *__restrict __stream), freopen64); +# else +# define fopen fopen64 +# define freopen freopen64 +# endif +#endif +__END_NAMESPACE_STD +#ifdef __USE_LARGEFILE64 +extern FILE *fopen64 (__const char *__restrict __filename, + __const char *__restrict __modes); +extern FILE *freopen64 (__const char *__restrict __filename, + __const char *__restrict __modes, + FILE *__restrict __stream); +#endif + +#ifdef __USE_POSIX +/* Create a new stream that refers to an existing system file descriptor. */ +extern FILE *fdopen (int __fd, __const char *__modes) __THROW; +#endif + +#ifdef __USE_GNU +#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__ +/* Create a new stream that refers to the given magic cookie, + and uses the given functions for input and output. */ +extern FILE *fopencookie (void *__restrict __magic_cookie, + __const char *__restrict __modes, + _IO_cookie_io_functions_t __io_funcs) __THROW; + +/* Create a new stream that refers to a memory buffer. */ +extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes) __THROW; + +/* Open a stream that writes into a malloc'd buffer that is expanded as + necessary. *BUFLOC and *SIZELOC are updated with the buffer's location + and the number of characters written on fflush or fclose. */ +extern FILE *open_memstream (char **__restrict __bufloc, + size_t *__restrict __sizeloc) __THROW; +#endif +#endif + + +__BEGIN_NAMESPACE_STD +/* If BUF is NULL, make STREAM unbuffered. + Else make it use buffer BUF, of size BUFSIZ. */ +extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW; +/* Make STREAM use buffering mode MODE. + If BUF is not NULL, use N bytes of it for buffering; + else allocate an internal buffer N bytes long. */ +extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf, + int __modes, size_t __n) __THROW; +__END_NAMESPACE_STD + +#ifdef __USE_BSD +/* If BUF is NULL, make STREAM unbuffered. + Else make it use SIZE bytes of BUF for buffering. */ +extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf, + size_t __size) __THROW; + +/* Make STREAM line-buffered. */ +extern void setlinebuf (FILE *__stream) __THROW; +#endif + + +__BEGIN_NAMESPACE_STD +/* Write formatted output to STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fprintf (FILE *__restrict __stream, + __const char *__restrict __format, ...); +/* Write formatted output to stdout. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int printf (__const char *__restrict __format, ...); +/* Write formatted output to S. */ +extern int sprintf (char *__restrict __s, + __const char *__restrict __format, ...) __THROW; + +/* Write formatted output to S from argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format, + __gnuc_va_list __arg); +/* Write formatted output to stdout from argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg); +/* Write formatted output to S from argument list ARG. */ +extern int vsprintf (char *__restrict __s, __const char *__restrict __format, + __gnuc_va_list __arg) __THROW; +__END_NAMESPACE_STD + +#if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98 +__BEGIN_NAMESPACE_C99 +/* Maximum chars of output to write in MAXLEN. */ +extern int snprintf (char *__restrict __s, size_t __maxlen, + __const char *__restrict __format, ...) + __THROW __attribute__ ((__format__ (__printf__, 3, 4))); + +extern int vsnprintf (char *__restrict __s, size_t __maxlen, + __const char *__restrict __format, __gnuc_va_list __arg) + __THROW __attribute__ ((__format__ (__printf__, 3, 0))); +__END_NAMESPACE_C99 +#endif + +#ifdef __USE_GNU +/* Write formatted output to a string dynamically allocated with `malloc'. + Store the address of the string in *PTR. */ +extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f, + __gnuc_va_list __arg) + __THROW __attribute__ ((__format__ (__printf__, 2, 0))); +#if 0 /* uClibc: disabled */ +extern int __asprintf (char **__restrict __ptr, + __const char *__restrict __fmt, ...) + __THROW __attribute__ ((__format__ (__printf__, 2, 3))); +#endif +extern int asprintf (char **__restrict __ptr, + __const char *__restrict __fmt, ...) + __THROW __attribute__ ((__format__ (__printf__, 2, 3))); + +/* Write formatted output to a file descriptor. + + These functions are not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation they are cancellation points and + therefore not marked with __THROW. */ +extern int vdprintf (int __fd, __const char *__restrict __fmt, + __gnuc_va_list __arg) + __attribute__ ((__format__ (__printf__, 2, 0))); +extern int dprintf (int __fd, __const char *__restrict __fmt, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +#endif + + +__BEGIN_NAMESPACE_STD +/* Read formatted input from STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fscanf (FILE *__restrict __stream, + __const char *__restrict __format, ...); +/* Read formatted input from stdin. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int scanf (__const char *__restrict __format, ...); +/* Read formatted input from S. */ +extern int sscanf (__const char *__restrict __s, + __const char *__restrict __format, ...) __THROW; +__END_NAMESPACE_STD + +#ifdef __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +/* Read formatted input from S into argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format, + __gnuc_va_list __arg) + __attribute__ ((__format__ (__scanf__, 2, 0))); + +/* Read formatted input from stdin into argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg) + __attribute__ ((__format__ (__scanf__, 1, 0))); + +/* Read formatted input from S into argument list ARG. */ +extern int vsscanf (__const char *__restrict __s, + __const char *__restrict __format, __gnuc_va_list __arg) + __THROW __attribute__ ((__format__ (__scanf__, 2, 0))); +__END_NAMESPACE_C99 +#endif /* Use ISO C9x. */ + + +__BEGIN_NAMESPACE_STD +/* Read a character from STREAM. + + These functions are possible cancellation points and therefore not + marked with __THROW. */ +extern int fgetc (FILE *__stream); +extern int getc (FILE *__stream); + +/* Read a character from stdin. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int getchar (void); +__END_NAMESPACE_STD + +/* The C standard explicitly says this is a macro, so we always do the + optimization for it. */ +#define getc(_fp) __GETC(_fp) + +#if defined __USE_POSIX || defined __USE_MISC +/* These are defined in POSIX.1:1996. + + These functions are possible cancellation points and therefore not + marked with __THROW. */ +extern int getc_unlocked (FILE *__stream); +extern int getchar_unlocked (void); + +/* SUSv3 allows getc_unlocked to be a macro */ +#define getc_unlocked(_fp) __GETC_UNLOCKED(_fp) +#endif /* Use POSIX or MISC. */ + +#ifdef __USE_MISC +/* Faster version when locking is not necessary. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int fgetc_unlocked (FILE *__stream); +#endif /* Use MISC. */ + + +__BEGIN_NAMESPACE_STD +/* Write a character to STREAM. + + These functions are possible cancellation points and therefore not + marked with __THROW. + + These functions is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fputc (int __c, FILE *__stream); +extern int putc (int __c, FILE *__stream); + +/* Write a character to stdout. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int putchar (int __c); +__END_NAMESPACE_STD + +/* The C standard explicitly says this can be a macro, + so we always do the optimization for it. */ +#define putc(_ch, _fp) __PUTC(_ch, _fp) + +#ifdef __USE_MISC +/* Faster version when locking is not necessary. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int fputc_unlocked (int __c, FILE *__stream); +#endif /* Use MISC. */ + +#if defined __USE_POSIX || defined __USE_MISC +/* These are defined in POSIX.1:1996. + + These functions are possible cancellation points and therefore not + marked with __THROW. */ +extern int putc_unlocked (int __c, FILE *__stream); +extern int putchar_unlocked (int __c); + +/* SUSv3 allows putc_unlocked to be a macro */ +#define putc_unlocked(_ch, _fp) __PUTC_UNLOCKED(_ch, _fp) +#endif /* Use POSIX or MISC. */ + + +#if defined __USE_SVID || defined __USE_MISC \ + || (defined __USE_XOPEN && !defined __USE_XOPEN2K) +/* Get a word (int) from STREAM. */ +extern int getw (FILE *__stream); + +/* Write a word (int) to STREAM. */ +extern int putw (int __w, FILE *__stream); +#endif + + +__BEGIN_NAMESPACE_STD +/* Get a newline-terminated string of finite length from STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream); + +/* Get a newline-terminated string from stdin, removing the newline. + DO NOT USE THIS FUNCTION!! There is no limit on how much it will read. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern char *gets (char *__s); +__END_NAMESPACE_STD + +#ifdef __USE_GNU +/* This function does the same as `fgets' but does not lock the stream. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern char *fgets_unlocked (char *__restrict __s, int __n, + FILE *__restrict __stream); +#endif + + +#ifdef __USE_GNU +/* Read up to (and including) a DELIMITER from STREAM into *LINEPTR + (and null-terminate it). *LINEPTR is a pointer returned from malloc (or + NULL), pointing to *N characters of space. It is realloc'd as + necessary. Returns the number of characters read (not including the + null terminator), or -1 on error or EOF. + + These functions are not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation they are cancellation points and + therefore not marked with __THROW. */ +#if 0 /* uClibc: disabled */ +extern __ssize_t __getdelim (char **__restrict __lineptr, + size_t *__restrict __n, int __delimiter, + FILE *__restrict __stream); +#endif +extern __ssize_t getdelim (char **__restrict __lineptr, + size_t *__restrict __n, int __delimiter, + FILE *__restrict __stream); + +/* Like `getdelim', but reads up to a newline. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern __ssize_t getline (char **__restrict __lineptr, + size_t *__restrict __n, + FILE *__restrict __stream); +#endif + + +__BEGIN_NAMESPACE_STD +/* Write a string to STREAM. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +extern int fputs (__const char *__restrict __s, FILE *__restrict __stream); + +/* Write a string, followed by a newline, to stdout. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +extern int puts (__const char *__s); + + +/* Push a character back onto the input buffer of STREAM. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +extern int ungetc (int __c, FILE *__stream); + + +/* Read chunks of generic data from STREAM. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +extern size_t fread (void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream); +/* Write chunks of generic data to STREAM. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +extern size_t fwrite (__const void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __s); +__END_NAMESPACE_STD + +#ifdef __USE_GNU +/* This function does the same as `fputs' but does not lock the stream. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int fputs_unlocked (__const char *__restrict __s, + FILE *__restrict __stream); +#endif + +#ifdef __USE_MISC +/* Faster versions when locking is not necessary. + + These functions are not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation they are cancellation points and + therefore not marked with __THROW. */ +extern size_t fread_unlocked (void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream); +extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream); +#endif + + +__BEGIN_NAMESPACE_STD +/* Seek to a certain position on STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fseek (FILE *__stream, long int __off, int __whence); +/* Return the current position of STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern long int ftell (FILE *__stream); +/* Rewind to the beginning of STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void rewind (FILE *__stream); +__END_NAMESPACE_STD + +/* The Single Unix Specification, Version 2, specifies an alternative, + more adequate interface for the two functions above which deal with + file offset. `long int' is not the right type. These definitions + are originally defined in the Large File Support API. */ + +#if defined __USE_LARGEFILE || defined __USE_XOPEN2K +# ifndef __USE_FILE_OFFSET64 +/* Seek to a certain position on STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fseeko (FILE *__stream, __off_t __off, int __whence); +/* Return the current position of STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern __off_t ftello (FILE *__stream); +# else +# ifdef __REDIRECT +extern int __REDIRECT (fseeko, + (FILE *__stream, __off64_t __off, int __whence), + fseeko64); +extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64); +# else +# define fseeko fseeko64 +# define ftello ftello64 +# endif +# endif +#endif + +__BEGIN_NAMESPACE_STD +#ifndef __USE_FILE_OFFSET64 +/* Get STREAM's position. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos); +/* Set STREAM's position. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fsetpos (FILE *__stream, __const fpos_t *__pos); +#else +# ifdef __REDIRECT +extern int __REDIRECT (fgetpos, (FILE *__restrict __stream, + fpos_t *__restrict __pos), fgetpos64); +extern int __REDIRECT (fsetpos, + (FILE *__stream, __const fpos_t *__pos), fsetpos64); +# else +# define fgetpos fgetpos64 +# define fsetpos fsetpos64 +# endif +#endif +__END_NAMESPACE_STD + +#ifdef __USE_LARGEFILE64 +extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence); +extern __off64_t ftello64 (FILE *__stream); +extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos); +extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos); +#endif + +__BEGIN_NAMESPACE_STD +/* Clear the error and EOF indicators for STREAM. */ +extern void clearerr (FILE *__stream) __THROW; +/* Return the EOF indicator for STREAM. */ +extern int feof (FILE *__stream) __THROW; +/* Return the error indicator for STREAM. */ +extern int ferror (FILE *__stream) __THROW; +__END_NAMESPACE_STD + +#ifdef __USE_MISC +/* Faster versions when locking is not required. */ +extern void clearerr_unlocked (FILE *__stream) __THROW; +extern int feof_unlocked (FILE *__stream) __THROW; +extern int ferror_unlocked (FILE *__stream) __THROW; +#endif + + +__BEGIN_NAMESPACE_STD +/* Print a message describing the meaning of the value of errno. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void perror (__const char *__s); +__END_NAMESPACE_STD + +#ifdef __UCLIBC_HAS_SYS_ERRLIST__ +/* These variables normally should not be used directly. The `strerror' + function provides all the needed functionality. */ +#ifdef __USE_BSD +extern int sys_nerr; +extern __const char *__const sys_errlist[]; +#endif +#endif /* __UCLIBC_HAS_SYS_ERRLIST__ */ + + +#ifdef __USE_POSIX +/* Return the system file descriptor for STREAM. */ +extern int fileno (FILE *__stream) __THROW; +#endif /* Use POSIX. */ + +#ifdef __USE_MISC +/* Faster version when locking is not required. */ +extern int fileno_unlocked (FILE *__stream) __THROW; +#endif + + +#if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \ + defined __USE_MISC) +/* Create a new stream connected to a pipe running the given command. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern FILE *popen (__const char *__command, __const char *__modes); + +/* Close a stream opened by popen and return the status of its child. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int pclose (FILE *__stream); +#endif + + +#ifdef __USE_POSIX +/* Return the name of the controlling terminal. */ +extern char *ctermid (char *__s) __THROW; +#endif /* Use POSIX. */ + + +#ifdef __USE_XOPEN +/* Return the name of the current user. */ +extern char *cuserid (char *__s); +#endif /* Use X/Open, but not issue 6. */ + + +#if 0 /* def __USE_GNU uClibc note: not supported */ +struct obstack; /* See . */ + +/* Write formatted output to an obstack. */ +extern int obstack_printf (struct obstack *__restrict __obstack, + __const char *__restrict __format, ...) + __THROW __attribute__ ((__format__ (__printf__, 2, 3))); +extern int obstack_vprintf (struct obstack *__restrict __obstack, + __const char *__restrict __format, + __gnuc_va_list __args) + __THROW __attribute__ ((__format__ (__printf__, 2, 0))); +#endif /* Use GNU. */ + + +#if defined __USE_POSIX || defined __USE_MISC +/* These are defined in POSIX.1:1996. */ + +/* Acquire ownership of STREAM. */ +extern void flockfile (FILE *__stream) __THROW; + +/* Try to acquire ownership of STREAM but do not block if it is not + possible. */ +extern int ftrylockfile (FILE *__stream) __THROW; + +/* Relinquish the ownership granted for STREAM. */ +extern void funlockfile (FILE *__stream) __THROW; +#endif /* POSIX || misc */ + +#if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU +/* The X/Open standard requires some functions and variables to be + declared here which do not belong into this header. But we have to + follow. In GNU mode we don't do this nonsense. */ +# define __need_getopt +# include +#endif /* X/Open, but not issue 6 and not for GNU. */ + +/* If we are compiling with optimizing read this file. It contains + several optimizing inline functions and macros. */ +#define fgetc(_fp) __FGETC(_fp) +#define fputc(_ch, _fp) __FPUTC(_ch, _fp) + +#ifdef __USE_MISC +#define fgetc_unlocked(_fp) __FGETC_UNLOCKED(_fp) +#define fputc_unlocked(_ch, _fp) __FPUTC_UNLOCKED(_ch, _fp) +#endif + +#ifndef __STDIO_GETC_MACRO +#define __stdin stdin +#endif +#define getchar() __GETC(__stdin) + +#ifndef __STDIO_PUTC_MACRO +#define __stdout stdout +#endif +#define putchar(_ch) __PUTC((_ch), __stdout) + +#if defined __USE_POSIX || defined __USE_MISC +#define getchar_unlocked() __GETC_UNLOCKED(__stdin) +#define putchar_unlocked(_ch) __PUTC_UNLOCKED((_ch), __stdout) +#endif + +/* Clear the error and EOF indicators for STREAM. */ +#define clearerr(_fp) __CLEARERR(_fp) +#define feof(_fp) __FEOF(_fp) +#define ferror(_fp) __FERROR(_fp) + +#ifdef __USE_MISC +#define clearerr_unlocked(_fp) __CLEARERR_UNLOCKED(_fp) +#define feof_unlocked(_fp) __FEOF_UNLOCKED(_fp) +#define ferror_unlocked(_fp) __FERROR_UNLOCKED(_fp) +#endif + +__END_DECLS + +#endif /* included. */ + +#endif /* !_STDIO_H */ diff --git a/conts/posix/libposix/include/posix/stdio_ext.h b/conts/posix/libposix/include/posix/stdio_ext.h new file mode 100644 index 0000000..23d12e0 --- /dev/null +++ b/conts/posix/libposix/include/posix/stdio_ext.h @@ -0,0 +1,87 @@ +/* Functions to access FILE structure internals. + Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This header contains the same definitions as the header of the same name + on Sun's Solaris OS. */ + +#ifndef _STDIO_EXT_H +#define _STDIO_EXT_H 1 + +#include + +enum +{ + /* Query current state of the locking status. */ + FSETLOCKING_QUERY = 0, +#define FSETLOCKING_QUERY FSETLOCKING_QUERY + /* The library protects all uses of the stream functions, except for + uses of the *_unlocked functions, by calls equivalent to flockfile(). */ + FSETLOCKING_INTERNAL, +#define FSETLOCKING_INTERNAL FSETLOCKING_INTERNAL + /* The user will take care of locking. */ + FSETLOCKING_BYCALLER +#define FSETLOCKING_BYCALLER FSETLOCKING_BYCALLER +}; + + +__BEGIN_DECLS + +/* Return the size of the buffer of FP in bytes currently in use by + the given stream. */ +extern size_t __fbufsize (FILE *__fp) __THROW; + + +/* Return non-zero value iff the stream FP is opened readonly, or if the + last operation on the stream was a read operation. */ +extern int __freading (FILE *__fp) __THROW; + +/* Return non-zero value iff the stream FP is opened write-only or + append-only, or if the last operation on the stream was a write + operation. */ +extern int __fwriting (FILE *__fp) __THROW; + + +/* Return non-zero value iff stream FP is not opened write-only or + append-only. */ +extern int __freadable (FILE *__fp) __THROW; + +/* Return non-zero value iff stream FP is not opened read-only. */ +extern int __fwritable (FILE *__fp) __THROW; + + +/* Return non-zero value iff the stream FP is line-buffered. */ +extern int __flbf (FILE *__fp) __THROW; + + +/* Discard all pending buffered I/O on the stream FP. */ +extern void __fpurge (FILE *__fp) __THROW; + +/* Return amount of output in bytes pending on a stream FP. */ +extern size_t __fpending (FILE *__fp) __THROW; + +/* Flush all line-buffered files. */ +extern void _flushlbf (void); + + +/* Set locking status of stream FP to TYPE. */ +extern int __fsetlocking (FILE *__fp, int __type) __THROW; + +__END_DECLS + +#endif /* stdio_ext.h */ diff --git a/conts/posix/libposix/include/posix/stdlib.h b/conts/posix/libposix/include/posix/stdlib.h new file mode 100644 index 0000000..276f1ba --- /dev/null +++ b/conts/posix/libposix/include/posix/stdlib.h @@ -0,0 +1,865 @@ +/* Copyright (C) 1991-2003, 2004, 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard: 7.20 General utilities + */ + +#ifndef _STDLIB_H + +#include + +/* Get size_t, wchar_t and NULL from . */ +#define __need_size_t +#ifndef __need_malloc_and_calloc +# ifdef __UCLIBC_HAS_WCHAR__ +# define __need_wchar_t +# endif +# define __need_NULL +#endif +#include + +__BEGIN_DECLS + +#ifndef __need_malloc_and_calloc +#define _STDLIB_H 1 + +#if defined __USE_XOPEN && !defined _SYS_WAIT_H +/* XPG requires a few symbols from being defined. */ +# include +# include + +# ifdef __USE_BSD + +/* Lots of hair to allow traditional BSD use of `union wait' + as well as POSIX.1 use of `int' for the status word. */ + +# if defined __GNUC__ && !defined __cplusplus +# define __WAIT_INT(status) \ + (__extension__ ({ union { __typeof(status) __in; int __i; } __u; \ + __u.__in = (status); __u.__i; })) +# else +# define __WAIT_INT(status) (*(int *) &(status)) +# endif + +/* This is the type of the argument to `wait'. The funky union + causes redeclarations with ether `int *' or `union wait *' to be + allowed without complaint. __WAIT_STATUS_DEFN is the type used in + the actual function definitions. */ + +# if !defined __GNUC__ || __GNUC__ < 2 || defined __cplusplus +# define __WAIT_STATUS void * +# define __WAIT_STATUS_DEFN void * +# else +/* This works in GCC 2.6.1 and later. */ +typedef union + { + union wait *__uptr; + int *__iptr; + } __WAIT_STATUS __attribute__ ((__transparent_union__)); +# define __WAIT_STATUS_DEFN int * +# endif + +# else /* Don't use BSD. */ + +# define __WAIT_INT(status) (status) +# define __WAIT_STATUS int * +# define __WAIT_STATUS_DEFN int * + +# endif /* Use BSD. */ + +/* Define the macros also would define this way. */ +# define WEXITSTATUS(status) __WEXITSTATUS(__WAIT_INT(status)) +# define WTERMSIG(status) __WTERMSIG(__WAIT_INT(status)) +# define WSTOPSIG(status) __WSTOPSIG(__WAIT_INT(status)) +# define WIFEXITED(status) __WIFEXITED(__WAIT_INT(status)) +# define WIFSIGNALED(status) __WIFSIGNALED(__WAIT_INT(status)) +# define WIFSTOPPED(status) __WIFSTOPPED(__WAIT_INT(status)) +# if 0 /* def __WIFCONTINUED */ +# define WIFCONTINUED(status) __WIFCONTINUED(__WAIT_INT(status)) +# endif +#endif /* X/Open and not included. */ + +__BEGIN_NAMESPACE_STD +/* Returned by `div'. */ +typedef struct + { + int quot; /* Quotient. */ + int rem; /* Remainder. */ + } div_t; + +/* Returned by `ldiv'. */ +#ifndef __ldiv_t_defined +typedef struct + { + long int quot; /* Quotient. */ + long int rem; /* Remainder. */ + } ldiv_t; +# define __ldiv_t_defined 1 +#endif +__END_NAMESPACE_STD + +#if defined __USE_ISOC99 && !defined __lldiv_t_defined +__BEGIN_NAMESPACE_C99 +/* Returned by `lldiv'. */ +__extension__ typedef struct + { + long long int quot; /* Quotient. */ + long long int rem; /* Remainder. */ + } lldiv_t; +# define __lldiv_t_defined 1 +__END_NAMESPACE_C99 +#endif + + +/* The largest number rand will return (same as INT_MAX). */ +#define RAND_MAX 2147483647 + + +/* We define these the same for all machines. + Changes from this to the outside world should be done in `_exit'. */ +#define EXIT_FAILURE 1 /* Failing exit status. */ +#define EXIT_SUCCESS 0 /* Successful exit status. */ + + +/* Maximum length of a multibyte character in the current locale. */ +#if 0 +#define MB_CUR_MAX (__ctype_get_mb_cur_max ()) +extern size_t __ctype_get_mb_cur_max (void) __THROW __wur; +#endif +#ifdef __UCLIBC_HAS_WCHAR__ +#define MB_CUR_MAX (_stdlib_mb_cur_max ()) +extern size_t _stdlib_mb_cur_max (void) __THROW __wur; +#endif + + +__BEGIN_NAMESPACE_STD +#ifdef __UCLIBC_HAS_FLOATS__ +/* Convert a string to a floating-point number. */ +extern double atof (__const char *__nptr) + __THROW __attribute_pure__ __nonnull ((1)) __wur; +#endif /* __UCLIBC_HAS_FLOATS__ */ +/* Convert a string to an integer. */ +extern int atoi (__const char *__nptr) + __THROW __attribute_pure__ __nonnull ((1)) __wur; +/* Convert a string to a long integer. */ +extern long int atol (__const char *__nptr) + __THROW __attribute_pure__ __nonnull ((1)) __wur; +__END_NAMESPACE_STD + +#if defined __USE_ISOC99 || defined __USE_MISC +__BEGIN_NAMESPACE_C99 +/* Convert a string to a long long integer. */ +__extension__ extern long long int atoll (__const char *__nptr) + __THROW __attribute_pure__ __nonnull ((1)) __wur; +__END_NAMESPACE_C99 +#endif + +#ifdef __UCLIBC_HAS_FLOATS__ +__BEGIN_NAMESPACE_STD +/* Convert a string to a floating-point number. */ +extern double strtod (__const char *__restrict __nptr, + char **__restrict __endptr) + __THROW __nonnull ((1)) __wur; +__END_NAMESPACE_STD + +#ifdef __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +/* Likewise for `float' and `long double' sizes of floating-point numbers. */ +extern float strtof (__const char *__restrict __nptr, + char **__restrict __endptr) __THROW __nonnull ((1)) __wur; + +extern long double strtold (__const char *__restrict __nptr, + char **__restrict __endptr) + __THROW __nonnull ((1)) __wur; +__END_NAMESPACE_C99 +#endif +#endif /* __UCLIBC_HAS_FLOATS__ */ + +__BEGIN_NAMESPACE_STD +/* Convert a string to a long integer. */ +extern long int strtol (__const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __THROW __nonnull ((1)) __wur; +/* Convert a string to an unsigned long integer. */ +extern unsigned long int strtoul (__const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __THROW __nonnull ((1)) __wur; +__END_NAMESPACE_STD + +#ifdef __USE_BSD +/* Convert a string to a quadword integer. */ +__extension__ +extern long long int strtoq (__const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __THROW __nonnull ((1)) __wur; +/* Convert a string to an unsigned quadword integer. */ +__extension__ +extern unsigned long long int strtouq (__const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __THROW __nonnull ((1)) __wur; +#endif /* GCC and use BSD. */ + +#if defined __USE_ISOC99 || defined __USE_MISC +__BEGIN_NAMESPACE_C99 +/* Convert a string to a quadword integer. */ +__extension__ +extern long long int strtoll (__const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __THROW __nonnull ((1)) __wur; +/* Convert a string to an unsigned quadword integer. */ +__extension__ +extern unsigned long long int strtoull (__const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __THROW __nonnull ((1)) __wur; +__END_NAMESPACE_C99 +#endif /* ISO C99 or GCC and use MISC. */ + + +#ifdef __UCLIBC_HAS_XLOCALE__ +#ifdef __USE_GNU +/* The concept of one static locale per category is not very well + thought out. Many applications will need to process its data using + information from several different locales. Another application is + the implementation of the internationalization handling in the + upcoming ISO C++ standard library. To support this another set of + the functions using locale data exist which have an additional + argument. + + Attention: all these functions are *not* standardized in any form. + This is a proof-of-concept implementation. */ + +/* Structure for reentrant locale using functions. This is an + (almost) opaque type for the user level programs. */ +# include + +/* Special versions of the functions above which take the locale to + use as an additional parameter. */ +extern long int strtol_l (__const char *__restrict __nptr, + char **__restrict __endptr, int __base, + __locale_t __loc) __THROW __nonnull ((1, 4)) __wur; + +extern unsigned long int strtoul_l (__const char *__restrict __nptr, + char **__restrict __endptr, + int __base, __locale_t __loc) + __THROW __nonnull ((1, 4)) __wur; + +__extension__ +extern long long int strtoll_l (__const char *__restrict __nptr, + char **__restrict __endptr, int __base, + __locale_t __loc) + __THROW __nonnull ((1, 4)) __wur; + +__extension__ +extern unsigned long long int strtoull_l (__const char *__restrict __nptr, + char **__restrict __endptr, + int __base, __locale_t __loc) + __THROW __nonnull ((1, 4)) __wur; + +#ifdef __UCLIBC_HAS_FLOATS__ +extern double strtod_l (__const char *__restrict __nptr, + char **__restrict __endptr, __locale_t __loc) + __THROW __nonnull ((1, 3)) __wur; + +extern float strtof_l (__const char *__restrict __nptr, + char **__restrict __endptr, __locale_t __loc) + __THROW __nonnull ((1, 3)) __wur; + +extern long double strtold_l (__const char *__restrict __nptr, + char **__restrict __endptr, + __locale_t __loc) + __THROW __nonnull ((1, 3)) __wur; +#endif /* __UCLIBC_HAS_FLOATS__ */ + +#endif /* GNU */ +#endif /* __UCLIBC_HAS_XLOCALE__ */ + + +#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED +/* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant + digit first. Returns a pointer to static storage overwritten by the + next call. */ +extern char *l64a (long int __n) __THROW __wur; + +/* Read a number from a string S in base 64 as above. */ +extern long int a64l (__const char *__s) + __THROW __attribute_pure__ __nonnull ((1)) __wur; + +#endif /* Use SVID || extended X/Open. */ + +#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED || defined __USE_BSD +# include /* we need int32_t... */ + +/* These are the functions that actually do things. The `random', `srandom', + `initstate' and `setstate' functions are those from BSD Unices. + The `rand' and `srand' functions are required by the ANSI standard. + We provide both interfaces to the same random number generator. */ +/* Return a random long integer between 0 and RAND_MAX inclusive. */ +extern long int random (void) __THROW; + +/* Seed the random number generator with the given number. */ +extern void srandom (unsigned int __seed) __THROW; + +/* Initialize the random number generator to use state buffer STATEBUF, + of length STATELEN, and seed it with SEED. Optimal lengths are 8, 16, + 32, 64, 128 and 256, the bigger the better; values less than 8 will + cause an error and values greater than 256 will be rounded down. */ +extern char *initstate (unsigned int __seed, char *__statebuf, + size_t __statelen) __THROW __nonnull ((2)); + +/* Switch the random number generator to state buffer STATEBUF, + which should have been previously initialized by `initstate'. */ +extern char *setstate (char *__statebuf) __THROW __nonnull ((1)); + + +# ifdef __USE_MISC +/* Reentrant versions of the `random' family of functions. + These functions all use the following data structure to contain + state, rather than global state variables. */ + +struct random_data + { + int32_t *fptr; /* Front pointer. */ + int32_t *rptr; /* Rear pointer. */ + int32_t *state; /* Array of state values. */ + int rand_type; /* Type of random number generator. */ + int rand_deg; /* Degree of random number generator. */ + int rand_sep; /* Distance between front and rear. */ + int32_t *end_ptr; /* Pointer behind state table. */ + }; + +extern int random_r (struct random_data *__restrict __buf, + int32_t *__restrict __result) __THROW __nonnull ((1, 2)); + +extern int srandom_r (unsigned int __seed, struct random_data *__buf) + __THROW __nonnull ((2)); + +extern int initstate_r (unsigned int __seed, char *__restrict __statebuf, + size_t __statelen, + struct random_data *__restrict __buf) + __THROW __nonnull ((2, 4)); + +extern int setstate_r (char *__restrict __statebuf, + struct random_data *__restrict __buf) + __THROW __nonnull ((1, 2)); +# endif /* Use misc. */ +#endif /* Use SVID || extended X/Open || BSD. */ + + +__BEGIN_NAMESPACE_STD +/* Return a random integer between 0 and RAND_MAX inclusive. */ +extern int rand (void) __THROW; +/* Seed the random number generator with the given number. */ +extern void srand (unsigned int __seed) __THROW; +__END_NAMESPACE_STD + +#ifdef __USE_POSIX +/* Reentrant interface according to POSIX.1. */ +extern int rand_r (unsigned int *__seed) __THROW; +#endif + + +#if defined __USE_SVID || defined __USE_XOPEN +/* System V style 48-bit random number generator functions. */ + +#ifdef __UCLIBC_HAS_FLOATS__ +/* Return non-negative, double-precision floating-point value in [0.0,1.0). */ +extern double drand48 (void) __THROW; +extern double erand48 (unsigned short int __xsubi[3]) __THROW __nonnull ((1)); +#endif /* __UCLIBC_HAS_FLOATS__ */ + +/* Return non-negative, long integer in [0,2^31). */ +extern long int lrand48 (void) __THROW; +extern long int nrand48 (unsigned short int __xsubi[3]) + __THROW __nonnull ((1)); + +/* Return signed, long integers in [-2^31,2^31). */ +extern long int mrand48 (void) __THROW; +extern long int jrand48 (unsigned short int __xsubi[3]) + __THROW __nonnull ((1)); + +/* Seed random number generator. */ +extern void srand48 (long int __seedval) __THROW; +extern unsigned short int *seed48 (unsigned short int __seed16v[3]) + __THROW __nonnull ((1)); +extern void lcong48 (unsigned short int __param[7]) __THROW __nonnull ((1)); + +# ifdef __USE_MISC +/* Data structure for communication with thread safe versions. This + type is to be regarded as opaque. It's only exported because users + have to allocate objects of this type. */ +struct drand48_data + { + unsigned short int __x[3]; /* Current state. */ + unsigned short int __old_x[3]; /* Old state. */ + unsigned short int __c; /* Additive const. in congruential formula. */ + unsigned short int __init; /* Flag for initializing. */ + unsigned long long int __a; /* Factor in congruential formula. */ + }; + +#ifdef __UCLIBC_HAS_FLOATS__ +/* Return non-negative, double-precision floating-point value in [0.0,1.0). */ +extern int drand48_r (struct drand48_data *__restrict __buffer, + double *__restrict __result) __THROW __nonnull ((1, 2)); +extern int erand48_r (unsigned short int __xsubi[3], + struct drand48_data *__restrict __buffer, + double *__restrict __result) __THROW __nonnull ((1, 2)); +#endif /* __UCLIBC_HAS_FLOATS__ */ + +/* Return non-negative, long integer in [0,2^31). */ +extern int lrand48_r (struct drand48_data *__restrict __buffer, + long int *__restrict __result) + __THROW __nonnull ((1, 2)); +extern int nrand48_r (unsigned short int __xsubi[3], + struct drand48_data *__restrict __buffer, + long int *__restrict __result) + __THROW __nonnull ((1, 2)); + +/* Return signed, long integers in [-2^31,2^31). */ +extern int mrand48_r (struct drand48_data *__restrict __buffer, + long int *__restrict __result) + __THROW __nonnull ((1, 2)); +extern int jrand48_r (unsigned short int __xsubi[3], + struct drand48_data *__restrict __buffer, + long int *__restrict __result) + __THROW __nonnull ((1, 2)); + +/* Seed random number generator. */ +extern int srand48_r (long int __seedval, struct drand48_data *__buffer) + __THROW __nonnull ((2)); + +extern int seed48_r (unsigned short int __seed16v[3], + struct drand48_data *__buffer) __THROW __nonnull ((1, 2)); + +extern int lcong48_r (unsigned short int __param[7], + struct drand48_data *__buffer) + __THROW __nonnull ((1, 2)); +# endif /* Use misc. */ +#endif /* Use SVID or X/Open. */ + +#endif /* don't just need malloc and calloc */ + +#ifndef __malloc_and_calloc_defined +# define __malloc_and_calloc_defined +__BEGIN_NAMESPACE_STD +/* Allocate SIZE bytes of memory. */ +extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur; +/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ +extern void *calloc (size_t __nmemb, size_t __size) + __THROW __attribute_malloc__ __wur; +__END_NAMESPACE_STD +#endif + +#ifndef __need_malloc_and_calloc +__BEGIN_NAMESPACE_STD +/* Re-allocate the previously allocated block + in PTR, making the new block SIZE bytes long. */ +extern void *realloc (void *__ptr, size_t __size) + __THROW __attribute_malloc__ __attribute_warn_unused_result__; +/* Free a block allocated by `malloc', `realloc' or `calloc'. */ +extern void free (void *__ptr) __THROW; +__END_NAMESPACE_STD + +#ifdef __USE_MISC +/* Free a block. An alias for `free'. (Sun Unices). */ +extern void cfree (void *__ptr) __THROW; +#endif /* Use misc. */ + +#if defined __USE_GNU || defined __USE_BSD || defined __USE_MISC +# include +#endif /* Use GNU, BSD, or misc. */ + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED +/* Allocate SIZE bytes on a page boundary. The storage cannot be freed. */ +extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur; +#endif + +#ifdef __USE_XOPEN2K +/* Allocate memory of SIZE bytes with an alignment of ALIGNMENT. */ +extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size) + __THROW __nonnull ((1)) __wur; +#endif + +__BEGIN_NAMESPACE_STD +/* Abort execution and generate a core-dump. */ +extern void abort (void) __THROW __attribute__ ((__noreturn__)); + + +/* Register a function to be called when `exit' is called. */ +extern int atexit (void (*__func) (void)) __THROW __nonnull ((1)); +__END_NAMESPACE_STD + +#ifdef __USE_MISC +/* Register a function to be called with the status + given to `exit' and the given argument. */ +extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg) + __THROW __nonnull ((1)); +#endif + +__BEGIN_NAMESPACE_STD +/* Call all functions registered with `atexit' and `on_exit', + in the reverse of the order in which they were registered + perform stdio cleanup, and terminate program execution with STATUS. */ +extern void exit (int __status) __THROW __attribute__ ((__noreturn__)); +__END_NAMESPACE_STD + +#ifdef __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +/* Terminate the program with STATUS without calling any of the + functions registered with `atexit' or `on_exit'. */ +extern void _Exit (int __status) __THROW __attribute__ ((__noreturn__)); +__END_NAMESPACE_C99 +#endif + + +__BEGIN_NAMESPACE_STD +/* Return the value of envariable NAME, or NULL if it doesn't exist. */ +extern char *getenv (__const char *__name) __THROW __nonnull ((1)) __wur; +__END_NAMESPACE_STD + +/* This function is similar to the above but returns NULL if the + programs is running with SUID or SGID enabled. */ +extern char *__secure_getenv (__const char *__name) + __THROW __nonnull ((1)) __wur; + +#if defined __USE_SVID || defined __USE_XOPEN +/* The SVID says this is in , but this seems a better place. */ +/* Put STRING, which is of the form "NAME=VALUE", in the environment. + If there is no `=', remove NAME from the environment. */ +extern int putenv (char *__string) __THROW __nonnull ((1)); +#endif + +#if defined __USE_BSD || defined __USE_XOPEN2K +/* Set NAME to VALUE in the environment. + If REPLACE is nonzero, overwrite an existing value. */ +extern int setenv (__const char *__name, __const char *__value, int __replace) + __THROW __nonnull ((2)); + +/* Remove the variable NAME from the environment. */ +extern int unsetenv (__const char *__name) __THROW; +#endif + +/* The following is used by uClibc in atexit.c and sysconf.c */ +/* We have no limit when __UCLIBC_DYNAMIC_ATEXIT__ is enabled. */ +#ifdef __UCLIBC_DYNAMIC_ATEXIT__ +# define __UCLIBC_MAX_ATEXIT INT_MAX +#else +# define __UCLIBC_MAX_ATEXIT 20 +#endif + + +#ifdef __USE_MISC +/* The `clearenv' was planned to be added to POSIX.1 but probably + never made it. Nevertheless the POSIX.9 standard (POSIX bindings + for Fortran 77) requires this function. */ +extern int clearenv (void) __THROW; +#endif + + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +/* Generate a unique temporary file name from TEMPLATE. + The last six characters of TEMPLATE must be "XXXXXX"; + they are replaced with a string that makes the file name unique. + Returns TEMPLATE, or a null pointer if it cannot get a unique file name. */ +extern char *mktemp (char *__template) __THROW __nonnull ((1)) __wur; + +/* Generate a unique temporary file name from TEMPLATE. + The last six characters of TEMPLATE must be "XXXXXX"; + they are replaced with a string that makes the filename unique. + Returns a file descriptor open on the file for reading and writing, + or -1 if it cannot create a uniquely-named file. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +# ifndef __USE_FILE_OFFSET64 +extern int mkstemp (char *__template) __nonnull ((1)) __wur; +# else +# ifdef __REDIRECT +extern int __REDIRECT (mkstemp, (char *__template), mkstemp64) + __nonnull ((1)) __wur; +# else +# define mkstemp mkstemp64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int mkstemp64 (char *__template) __nonnull ((1)) __wur; +# endif +#endif + +#ifdef __USE_BSD +/* Create a unique temporary directory from TEMPLATE. + The last six characters of TEMPLATE must be "XXXXXX"; + they are replaced with a string that makes the directory name unique. + Returns TEMPLATE, or a null pointer if it cannot get a unique name. + The directory is created mode 700. */ +extern char *mkdtemp (char *__template) __THROW __nonnull ((1)) __wur; +#endif + + +__BEGIN_NAMESPACE_STD +/* Execute the given line as a shell command. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int system (__const char *__command) __wur; +__END_NAMESPACE_STD + + +#if 0 /* def __USE_GNU */ +/* Return a malloc'd string containing the canonical absolute name of the + named file. The last file name component need not exist, and may be a + symlink to a nonexistent file. */ +extern char *canonicalize_file_name (__const char *__name) + __THROW __nonnull ((1)) __wur; +#endif + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED +/* Return the canonical absolute name of file NAME. The last file name + component need not exist, and may be a symlink to a nonexistent file. + If RESOLVED is null, the result is malloc'd; otherwise, if the canonical + name is PATH_MAX chars or more, returns null with `errno' set to + ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, returns the + name in RESOLVED. */ +/* we choose to handle __resolved==NULL as crash :) */ +extern char *realpath (__const char *__restrict __name, + char *__restrict __resolved) __THROW __wur __nonnull((2)); +#endif + + +/* Shorthand for type of comparison functions. */ +#ifndef __COMPAR_FN_T +# define __COMPAR_FN_T +typedef int (*__compar_fn_t) (__const void *, __const void *); + +# ifdef __USE_GNU +typedef __compar_fn_t comparison_fn_t; +# endif +#endif + +__BEGIN_NAMESPACE_STD +/* Do a binary search for KEY in BASE, which consists of NMEMB elements + of SIZE bytes each, using COMPAR to perform the comparisons. */ +extern void *bsearch (__const void *__key, __const void *__base, + size_t __nmemb, size_t __size, __compar_fn_t __compar) + __nonnull ((1, 2, 5)) __wur; + +/* Sort NMEMB elements of BASE, of SIZE bytes each, + using COMPAR to perform the comparisons. */ +extern void qsort (void *__base, size_t __nmemb, size_t __size, + __compar_fn_t __compar) __nonnull ((1, 4)); + + +/* Return the absolute value of X. */ +extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; +extern long int labs (long int __x) __THROW __attribute__ ((__const__)) __wur; +__END_NAMESPACE_STD + +#ifdef __USE_ISOC99 +__extension__ extern long long int llabs (long long int __x) + __THROW __attribute__ ((__const__)) __wur; +#endif + + +__BEGIN_NAMESPACE_STD +/* Return the `div_t', `ldiv_t' or `lldiv_t' representation + of the value of NUMER over DENOM. */ +/* GCC may have built-ins for these someday. */ +extern div_t div (int __numer, int __denom) + __THROW __attribute__ ((__const__)) __wur; +extern ldiv_t ldiv (long int __numer, long int __denom) + __THROW __attribute__ ((__const__)) __wur; +__END_NAMESPACE_STD + +#ifdef __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +__extension__ extern lldiv_t lldiv (long long int __numer, + long long int __denom) + __THROW __attribute__ ((__const__)) __wur; +__END_NAMESPACE_C99 +#endif + + +#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED || defined __USE_BSD +/* Convert floating point numbers to strings. The returned values are + valid only until another call to the same function. */ + +# ifdef __UCLIBC_SUSV3_LEGACY__ + +#if 0 +/* Convert VALUE to a string with NDIGIT digits and return a pointer to + this. Set *DECPT with the position of the decimal character and *SIGN + with the sign of the number. */ +extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt, + int *__restrict __sign) __THROW __nonnull ((3, 4)) __wur; + +/* Convert VALUE to a string rounded to NDIGIT decimal digits. Set *DECPT + with the position of the decimal character and *SIGN with the sign of + the number. */ +extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt, + int *__restrict __sign) __THROW __nonnull ((3, 4)) __wur; +#endif + +/* If possible convert VALUE to a string with NDIGIT significant digits. + Otherwise use exponential representation. The resulting string will + be written to BUF. */ +extern char *gcvt (double __value, int __ndigit, char *__buf) + __THROW __nonnull ((3)) __wur; +# endif /* __UCLIBC_SUSV3_LEGACY__ */ + +# if 0 /*def __USE_MISC*/ +/* Long double versions of above functions. */ +extern char *qecvt (long double __value, int __ndigit, + int *__restrict __decpt, int *__restrict __sign) + __THROW __nonnull ((3, 4)) __wur; +extern char *qfcvt (long double __value, int __ndigit, + int *__restrict __decpt, int *__restrict __sign) + __THROW __nonnull ((3, 4)) __wur; +extern char *qgcvt (long double __value, int __ndigit, char *__buf) + __THROW __nonnull ((3)) __wur; + + +/* Reentrant version of the functions above which provide their own + buffers. */ +extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt, + int *__restrict __sign, char *__restrict __buf, + size_t __len) __THROW __nonnull ((3, 4, 5)); +extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt, + int *__restrict __sign, char *__restrict __buf, + size_t __len) __THROW __nonnull ((3, 4, 5)); + +extern int qecvt_r (long double __value, int __ndigit, + int *__restrict __decpt, int *__restrict __sign, + char *__restrict __buf, size_t __len) + __THROW __nonnull ((3, 4, 5)); +extern int qfcvt_r (long double __value, int __ndigit, + int *__restrict __decpt, int *__restrict __sign, + char *__restrict __buf, size_t __len) + __THROW __nonnull ((3, 4, 5)); +# endif /* misc */ +#endif /* use MISC || use X/Open Unix */ + +#ifdef __UCLIBC_HAS_WCHAR__ +__BEGIN_NAMESPACE_STD +/* Return the length of the multibyte character + in S, which is no longer than N. */ +extern int mblen (__const char *__s, size_t __n) __THROW __wur; +/* Return the length of the given multibyte character, + putting its `wchar_t' representation in *PWC. */ +extern int mbtowc (wchar_t *__restrict __pwc, + __const char *__restrict __s, size_t __n) __THROW __wur; +/* Put the multibyte character represented + by WCHAR in S, returning its length. */ +extern int wctomb (char *__s, wchar_t __wchar) __THROW __wur; + + +/* Convert a multibyte string to a wide char string. */ +extern size_t mbstowcs (wchar_t *__restrict __pwcs, + __const char *__restrict __s, size_t __n) __THROW; +/* Convert a wide char string to multibyte string. */ +extern size_t wcstombs (char *__restrict __s, + __const wchar_t *__restrict __pwcs, size_t __n) + __THROW; +__END_NAMESPACE_STD +#endif /* __UCLIBC_HAS_WCHAR__ */ + + +#ifdef __USE_SVID +/* Determine whether the string value of RESPONSE matches the affirmation + or negative response expression as specified by the LC_MESSAGES category + in the program's current locale. Returns 1 if affirmative, 0 if + negative, and -1 if not matching. */ +extern int rpmatch (__const char *__response) __THROW __nonnull ((1)) __wur; +#endif + + +#ifdef __USE_XOPEN_EXTENDED +/* Parse comma separated suboption from *OPTIONP and match against + strings in TOKENS. If found return index and set *VALUEP to + optional value introduced by an equal sign. If the suboption is + not part of TOKENS return in *VALUEP beginning of unknown + suboption. On exit *OPTIONP is set to the beginning of the next + token or at the terminating NUL character. */ +extern int getsubopt (char **__restrict __optionp, + char *__const *__restrict __tokens, + char **__restrict __valuep) + __THROW __nonnull ((1, 2, 3)) __wur; +#endif + + +#ifdef __USE_XOPEN +/* Setup DES tables according KEY. */ +extern void setkey (__const char *__key) __THROW __nonnull ((1)); +#endif + + +/* X/Open pseudo terminal handling. */ + +#ifdef __USE_XOPEN2K +/* Return a master pseudo-terminal handle. */ +extern int posix_openpt (int __oflag) __wur; +#endif + +#ifdef __USE_XOPEN +/* The next four functions all take a master pseudo-tty fd and + perform an operation on the associated slave: */ + +/* Chown the slave to the calling user. */ +extern int grantpt (int __fd) __THROW; + +/* Release an internal lock so the slave can be opened. + Call after grantpt(). */ +extern int unlockpt (int __fd) __THROW; + +/* Return the pathname of the pseudo terminal slave assoicated with + the master FD is open on, or NULL on errors. + The returned storage is good until the next call to this function. */ +extern char *ptsname (int __fd) __THROW __wur; +#endif + +#ifdef __USE_GNU +/* Store at most BUFLEN characters of the pathname of the slave pseudo + terminal associated with the master FD is open on in BUF. + Return 0 on success, otherwise an error number. */ +extern int ptsname_r (int __fd, char *__buf, size_t __buflen) + __THROW __nonnull ((2)); + +/* Open a master pseudo terminal and return its file descriptor. */ +extern int getpt (void); +#endif + +#if 0 /* def __USE_BSD */ +/* Put the 1 minute, 5 minute and 15 minute load averages into the first + NELEM elements of LOADAVG. Return the number written (never more than + three, but may be less than NELEM), or -1 if an error occurred. */ +extern int getloadavg (double __loadavg[], int __nelem) + __THROW __nonnull ((1)); +#endif + +#ifdef __UCLIBC_HAS_ARC4RANDOM__ +#include +extern uint32_t arc4random(void); +extern void arc4random_stir(void); +extern void arc4random_addrandom(unsigned char *, int); +#endif + +#endif /* don't just need malloc and calloc */ +#undef __need_malloc_and_calloc + +__END_DECLS + +#endif /* stdlib.h */ diff --git a/conts/posix/libposix/include/posix/string.h b/conts/posix/libposix/include/posix/string.h new file mode 100644 index 0000000..87d9534 --- /dev/null +++ b/conts/posix/libposix/include/posix/string.h @@ -0,0 +1,437 @@ +/* Copyright (C) 1991-1993, 1995-2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard: 7.21 String handling + */ + +#ifndef _STRING_H +#define _STRING_H 1 + +#include + +__BEGIN_DECLS + +/* Get size_t and NULL from . */ +#define __need_size_t +#define __need_NULL +#include + + +__BEGIN_NAMESPACE_STD +/* Copy N bytes of SRC to DEST. */ +extern void *memcpy (void *__restrict __dest, + __const void *__restrict __src, size_t __n) + __THROW __nonnull ((1, 2)); +/* Copy N bytes of SRC to DEST, guaranteeing + correct behavior for overlapping strings. */ +extern void *memmove (void *__dest, __const void *__src, size_t __n) + __THROW __nonnull ((1, 2)); +__END_NAMESPACE_STD + +/* Copy no more than N bytes of SRC to DEST, stopping when C is found. + Return the position in DEST one byte past where C was copied, + or NULL if C was not found in the first N bytes of SRC. */ +#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN +extern void *memccpy (void *__restrict __dest, __const void *__restrict __src, + int __c, size_t __n) + __THROW __nonnull ((1, 2)); +#endif /* SVID. */ + + +__BEGIN_NAMESPACE_STD +/* Set N bytes of S to C. */ +extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); + +/* Compare N bytes of S1 and S2. */ +extern int memcmp (__const void *__s1, __const void *__s2, size_t __n) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +/* Search N bytes of S for C. */ +extern void *memchr (__const void *__s, int __c, size_t __n) + __THROW __attribute_pure__ __nonnull ((1)); +__END_NAMESPACE_STD + +#ifdef __USE_GNU +/* Search in S for C. This is similar to `memchr' but there is no + length limit. */ +extern void *rawmemchr (__const void *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); + +/* Search N bytes of S for the final occurrence of C. */ +extern void *memrchr (__const void *__s, int __c, size_t __n) + __THROW __attribute_pure__ __nonnull ((1)); +#endif + + +__BEGIN_NAMESPACE_STD +/* Copy SRC to DEST. */ +extern char *strcpy (char *__restrict __dest, __const char *__restrict __src) + __THROW __nonnull ((1, 2)); +/* Copy no more than N characters of SRC to DEST. */ +extern char *strncpy (char *__restrict __dest, + __const char *__restrict __src, size_t __n) + __THROW __nonnull ((1, 2)); + +/* Append SRC onto DEST. */ +extern char *strcat (char *__restrict __dest, __const char *__restrict __src) + __THROW __nonnull ((1, 2)); +/* Append no more than N characters from SRC onto DEST. */ +extern char *strncat (char *__restrict __dest, __const char *__restrict __src, + size_t __n) __THROW __nonnull ((1, 2)); + +/* Compare S1 and S2. */ +extern int strcmp (__const char *__s1, __const char *__s2) + __THROW __attribute_pure__ __nonnull ((1, 2)); +/* Compare N characters of S1 and S2. */ +extern int strncmp (__const char *__s1, __const char *__s2, size_t __n) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +/* Compare the collated forms of S1 and S2. */ +extern int strcoll (__const char *__s1, __const char *__s2) + __THROW __attribute_pure__ __nonnull ((1, 2)); +/* Put a transformation of SRC into no more than N bytes of DEST. */ +extern size_t strxfrm (char *__restrict __dest, + __const char *__restrict __src, size_t __n) + __THROW __nonnull ((2)); +__END_NAMESPACE_STD + +#if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__ +/* The following functions are equivalent to the both above but they + take the locale they use for the collation as an extra argument. + This is not standardsized but something like will come. */ +# include + +/* Compare the collated forms of S1 and S2 using rules from L. */ +extern int strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l) + __THROW __attribute_pure__ __nonnull ((1, 2, 3)); +/* Put a transformation of SRC into no more than N bytes of DEST. */ +extern size_t strxfrm_l (char *__dest, __const char *__src, size_t __n, + __locale_t __l) __THROW __nonnull ((2, 4)); +#endif + +#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED +/* Duplicate S, returning an identical malloc'd string. */ +extern char *strdup (__const char *__s) + __THROW __attribute_malloc__ __nonnull ((1)); +#endif + +/* Return a malloc'd copy of at most N bytes of STRING. The + resultant string is terminated even if no null terminator + appears before STRING[N]. */ +#if defined __USE_GNU +extern char *strndup (__const char *__string, size_t __n) + __THROW __attribute_malloc__ __nonnull ((1)); +#endif + +#if defined __USE_GNU && defined __GNUC__ +/* Duplicate S, returning an identical alloca'd string. */ +# define strdupa(s) \ + (__extension__ \ + ({ \ + __const char *__old = (s); \ + size_t __len = strlen (__old) + 1; \ + char *__new = (char *) __builtin_alloca (__len); \ + (char *) memcpy (__new, __old, __len); \ + })) + +/* Return an alloca'd copy of at most N bytes of string. */ +# define strndupa(s, n) \ + (__extension__ \ + ({ \ + __const char *__old = (s); \ + size_t __len = strnlen (__old, (n)); \ + char *__new = (char *) __builtin_alloca (__len + 1); \ + __new[__len] = '\0'; \ + (char *) memcpy (__new, __old, __len); \ + })) +#endif + +__BEGIN_NAMESPACE_STD +/* Find the first occurrence of C in S. */ +extern char *strchr (__const char *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); +/* Find the last occurrence of C in S. */ +extern char *strrchr (__const char *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); +__END_NAMESPACE_STD + +#ifdef __USE_GNU +/* This function is similar to `strchr'. But it returns a pointer to + the closing NUL byte in case C is not found in S. */ +extern char *strchrnul (__const char *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); +#endif + +__BEGIN_NAMESPACE_STD +/* Return the length of the initial segment of S which + consists entirely of characters not in REJECT. */ +extern size_t strcspn (__const char *__s, __const char *__reject) + __THROW __attribute_pure__ __nonnull ((1, 2)); +/* Return the length of the initial segment of S which + consists entirely of characters in ACCEPT. */ +extern size_t strspn (__const char *__s, __const char *__accept) + __THROW __attribute_pure__ __nonnull ((1, 2)); +/* Find the first occurrence in S of any character in ACCEPT. */ +extern char *strpbrk (__const char *__s, __const char *__accept) + __THROW __attribute_pure__ __nonnull ((1, 2)); +/* Find the first occurrence of NEEDLE in HAYSTACK. */ +extern char *strstr (__const char *__haystack, __const char *__needle) + __THROW __attribute_pure__ __nonnull ((1, 2)); + + +/* Divide S into tokens separated by characters in DELIM. */ +extern char *strtok (char *__restrict __s, __const char *__restrict __delim) + __THROW __nonnull ((2)); +__END_NAMESPACE_STD + +/* Divide S into tokens separated by characters in DELIM. Information + passed between calls are stored in SAVE_PTR. */ +#if 0 /* uClibc: disabled */ +extern char *__strtok_r (char *__restrict __s, + __const char *__restrict __delim, + char **__restrict __save_ptr) + __THROW __nonnull ((2, 3)); +#endif +#if defined __USE_POSIX || defined __USE_MISC +extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim, + char **__restrict __save_ptr) + __THROW __nonnull ((2, 3)); +#endif + +#ifdef __USE_GNU +/* Similar to `strstr' but this function ignores the case of both strings. */ +extern char *strcasestr (__const char *__haystack, __const char *__needle) + __THROW __attribute_pure__ __nonnull ((1, 2)); +#endif + +#ifdef __USE_GNU +/* Find the first occurrence of NEEDLE in HAYSTACK. + NEEDLE is NEEDLELEN bytes long; + HAYSTACK is HAYSTACKLEN bytes long. */ +extern void *memmem (__const void *__haystack, size_t __haystacklen, + __const void *__needle, size_t __needlelen) + __THROW __attribute_pure__ __nonnull ((1, 3)); + +/* Copy N bytes of SRC to DEST, return pointer to bytes after the + last written byte. */ +#if 0 /* uClibc: disabled */ +extern void *__mempcpy (void *__restrict __dest, + __const void *__restrict __src, size_t __n) + __THROW __nonnull ((1, 2)); +#endif +extern void *mempcpy (void *__restrict __dest, + __const void *__restrict __src, size_t __n) + __THROW __nonnull ((1, 2)); +#endif + + +__BEGIN_NAMESPACE_STD +/* Return the length of S. */ +extern size_t strlen (__const char *__s) + __THROW __attribute_pure__ __nonnull ((1)); +__END_NAMESPACE_STD + +#ifdef __USE_GNU +/* Find the length of STRING, but scan at most MAXLEN characters. + If no '\0' terminator is found in that many characters, return MAXLEN. */ +extern size_t strnlen (__const char *__string, size_t __maxlen) + __THROW __attribute_pure__ __nonnull ((1)); +#endif + + +__BEGIN_NAMESPACE_STD +/* Return a string describing the meaning of the `errno' code in ERRNUM. */ +extern char *strerror (int __errnum) __THROW; +__END_NAMESPACE_STD +#if defined __USE_XOPEN2K || defined __USE_MISC +/* Reentrant version of `strerror'. + There are 2 flavors of `strerror_r', GNU which returns the string + and may or may not use the supplied temporary buffer and POSIX one + which fills the string into the buffer. + To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L + without -D_GNU_SOURCE is needed, otherwise the GNU version is + preferred. */ +# if defined __USE_XOPEN2K && !defined __USE_GNU +/* Fill BUF with a string describing the meaning of the `errno' code in + ERRNUM. */ +extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen) + __THROW __nonnull ((2)); +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (strerror_r, + (int __errnum, char *__buf, size_t __buflen), + __xpg_strerror_r) __nonnull ((2)); +# else +# define strerror_r __xpg_strerror_r +# endif +# else +/* If a temporary buffer is required, at most BUFLEN bytes of BUF will be + used. */ +extern char *__glibc_strerror_r (int __errnum, char *__buf, size_t __buflen) + __THROW __nonnull ((2)); +# ifdef __REDIRECT_NTH +extern char * __REDIRECT_NTH (strerror_r, + (int __errnum, char *__buf, size_t __buflen), + __glibc_strerror_r) __nonnull ((2)); +# else +# define strerror_r __glibc_strerror_r +# endif +# endif +#endif + +/* We define this function always since `bzero' is sometimes needed when + the namespace rules does not allow this. */ +#if 0 /* uClibc: disabled */ +extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1)); +#endif + +#ifdef __USE_BSD +# ifdef __UCLIBC_SUSV3_LEGACY__ +/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */ +extern void bcopy (__const void *__src, void *__dest, size_t __n) + __THROW __nonnull ((1, 2)); + +/* Set N bytes of S to 0. */ +extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1)); + +/* Compare N bytes of S1 and S2 (same as memcmp). */ +extern int bcmp (__const void *__s1, __const void *__s2, size_t __n) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +/* Find the first occurrence of C in S (same as strchr). */ +extern char *index (__const char *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); + +/* Find the last occurrence of C in S (same as strrchr). */ +extern char *rindex (__const char *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); +# else +# ifdef __UCLIBC_SUSV3_LEGACY_MACROS__ +/* bcopy/bzero/bcmp/index/rindex are marked LEGACY in SuSv3. + * They are replaced as proposed by SuSv3. Don't sync this part + * with glibc and keep it in sync with strings.h. */ + +# define bcopy(src,dest,n) (memmove((dest), (src), (n)), (void) 0) +# define bzero(s,n) (memset((s), '\0', (n)), (void) 0) +# define bcmp(s1,s2,n) memcmp((s1), (s2), (size_t)(n)) +# define index(s,c) strchr((s), (c)) +# define rindex(s,c) strrchr((s), (c)) +# endif +# endif + +/* Return the position of the first bit set in I, or 0 if none are set. + The least-significant bit is position 1, the most-significant 32. */ +extern int ffs (int __i) __THROW __attribute__ ((__const__)); + +/* The following two functions are non-standard but necessary for non-32 bit + platforms. */ +#if 0 /*def __USE_GNU*/ +extern int ffsl (long int __l) __THROW __attribute__ ((__const__)); +# ifdef __GNUC__ +__extension__ extern int ffsll (long long int __ll) + __THROW __attribute__ ((__const__)); +# endif +# endif + +/* Compare S1 and S2, ignoring case. */ +extern int strcasecmp (__const char *__s1, __const char *__s2) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +/* Compare no more than N chars of S1 and S2, ignoring case. */ +extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n) + __THROW __attribute_pure__ __nonnull ((1, 2)); +#endif /* Use BSD. */ + +#if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__ +/* Again versions of a few functions which use the given locale instead + of the global one. */ +extern int strcasecmp_l (__const char *__s1, __const char *__s2, + __locale_t __loc) + __THROW __attribute_pure__ __nonnull ((1, 2, 3)); + +extern int strncasecmp_l (__const char *__s1, __const char *__s2, + size_t __n, __locale_t __loc) + __THROW __attribute_pure__ __nonnull ((1, 2, 4)); +#endif + +#ifdef __USE_BSD +/* Return the next DELIM-delimited token from *STRINGP, + terminating it with a '\0', and update *STRINGP to point past it. */ +extern char *strsep (char **__restrict __stringp, + __const char *__restrict __delim) + __THROW __nonnull ((1, 2)); +#endif + +#ifdef __USE_GNU +/* Compare S1 and S2 as strings holding name & indices/version numbers. */ +#if 0 +extern int strverscmp (__const char *__s1, __const char *__s2) + __THROW __attribute_pure__ __nonnull ((1, 2)); +#endif + +/* Return a string describing the meaning of the signal number in SIG. */ +extern char *strsignal (int __sig) __THROW; + +/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ +#if 0 /* uClibc: disabled */ +extern char *__stpcpy (char *__restrict __dest, __const char *__restrict __src) + __THROW __nonnull ((1, 2)); +#endif +extern char *stpcpy (char *__restrict __dest, __const char *__restrict __src) + __THROW __nonnull ((1, 2)); + +/* Copy no more than N characters of SRC to DEST, returning the address of + the last character written into DEST. */ +#if 0 /* uClibc: disabled */ +extern char *__stpncpy (char *__restrict __dest, + __const char *__restrict __src, size_t __n) + __THROW __nonnull ((1, 2)); +#endif +extern char *stpncpy (char *__restrict __dest, + __const char *__restrict __src, size_t __n) + __THROW __nonnull ((1, 2)); + +#if 0 /* uClibc does not support strfry or memfrob. */ +/* Sautee STRING briskly. */ +extern char *strfry (char *__string) __THROW __nonnull ((1)); + +/* Frobnicate N bytes of S. */ +extern void *memfrob (void *__s, size_t __n) __THROW __nonnull ((1)); +#endif + +# ifndef basename +/* Return the file name within directory of FILENAME. We don't + declare the function if the `basename' macro is available (defined + in ) which makes the XPG version of this function + available. */ +extern char *basename (__const char *__filename) __THROW __nonnull ((1)); +# endif +#endif + + +#ifdef __USE_BSD +/* Two OpenBSD extension functions. */ +extern size_t strlcat(char *__restrict dst, const char *__restrict src, + size_t n) __THROW __nonnull ((1, 2)); +extern size_t strlcpy(char *__restrict dst, const char *__restrict src, + size_t n) __THROW __nonnull ((1, 2)); +#endif + +__END_DECLS + +#endif /* string.h */ diff --git a/conts/posix/libposix/include/posix/strings.h b/conts/posix/libposix/include/posix/strings.h new file mode 100644 index 0000000..107c53a --- /dev/null +++ b/conts/posix/libposix/include/posix/strings.h @@ -0,0 +1,95 @@ +/* Copyright (C) 1991,92,96,97,99,2000,2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _STRINGS_H +#define _STRINGS_H 1 + +/* We don't need and should not read this file if was already + read. The one exception being that if __USE_BSD isn't defined, then + these aren't defined in string.h, so we need to define them here. */ + +/* keep this file in sync w/ string.h, the glibc version is out of date */ + +#if !defined _STRING_H || !defined __USE_BSD + +# include +# define __need_size_t +# include + +__BEGIN_DECLS + +# ifdef __UCLIBC_SUSV3_LEGACY__ +/* Copy N bytes of SRC to DEST (like memmove, but args reversed). */ +extern void bcopy (__const void *__src, void *__dest, size_t __n) + __THROW __nonnull ((1, 2)); + +/* Set N bytes of S to 0. */ +extern void bzero (void *__s, size_t __n) __THROW __nonnull ((1)); + +/* Compare N bytes of S1 and S2 (same as memcmp). */ +extern int bcmp (__const void *__s1, __const void *__s2, size_t __n) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +/* Find the first occurrence of C in S (same as strchr). */ +extern char *index (__const char *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); + +/* Find the last occurrence of C in S (same as strrchr). */ +extern char *rindex (__const char *__s, int __c) + __THROW __attribute_pure__ __nonnull ((1)); +# else +# ifdef __UCLIBC_SUSV3_LEGACY_MACROS__ +/* bcopy/bzero/bcmp/index/rindex are marked LEGACY in SuSv3. + * They are replaced as proposed by SuSv3. Don't sync this part + * with glibc and keep it in sync with string.h. */ + +# define bcopy(src,dest,n) (memmove((dest), (src), (n)), (void) 0) +# define bzero(s,n) (memset((s), '\0', (n)), (void) 0) +# define bcmp(s1,s2,n) memcmp((s1), (s2), (size_t)(n)) +# define index(s,c) strchr((s), (c)) +# define rindex(s,c) strrchr((s), (c)) +# endif +# endif + +/* Return the position of the first bit set in I, or 0 if none are set. + The least-significant bit is position 1, the most-significant 32. */ +extern int ffs (int __i) __THROW __attribute__ ((__const__)); + +/* The following two functions are non-standard but necessary for non-32 bit + platforms. */ +#if 0 /*def __USE_GNU*/ +extern int ffsl (long int __l) __THROW __attribute__ ((__const__)); +# ifdef __GNUC__ +__extension__ extern int ffsll (long long int __ll) + __THROW __attribute__ ((__const__)); +# endif +# endif + +/* Compare S1 and S2, ignoring case. */ +extern int strcasecmp (__const char *__s1, __const char *__s2) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +/* Compare no more than N chars of S1 and S2, ignoring case. */ +extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n) + __THROW __attribute_pure__ __nonnull ((1, 2)); + +__END_DECLS + +#endif /* string.h */ + +#endif /* strings.h */ diff --git a/conts/posix/libposix/include/posix/sys/bitypes.h b/conts/posix/libposix/include/posix/sys/bitypes.h new file mode 100644 index 0000000..3a9860f --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/bitypes.h @@ -0,0 +1,3 @@ +/* The GNU defines all the necessary types. */ + +#include diff --git a/conts/posix/libposix/include/posix/sys/cdefs.h b/conts/posix/libposix/include/posix/sys/cdefs.h new file mode 100644 index 0000000..8daac15 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/cdefs.h @@ -0,0 +1,320 @@ +/* Copyright (C) 1992-2001, 2002, 2004, 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_CDEFS_H +#define _SYS_CDEFS_H 1 + +/* We are almost always included from features.h. */ +#ifndef _FEATURES_H +# include +#endif + +/* The GNU libc does not support any K&R compilers or the traditional mode + of ISO C compilers anymore. Check for some of the combinations not + anymore supported. */ +#if defined __GNUC__ && !defined __STDC__ +# error "You need a ISO C conforming compiler to use the glibc headers" +#endif + +/* Some user header file might have defined this before. */ +#undef __P +#undef __PMT + +#ifdef __GNUC__ + +/* GCC can always grok prototypes. For C++ programs we add throw() + to help it optimize the function calls. But this works only with + gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions + as non-throwing using a function attribute since programs can use + the -fexceptions options for C code as well. */ +# if !defined __cplusplus && __GNUC_PREREQ (3, 3) +# define __THROW __attribute__ ((__nothrow__)) +# define __NTH(fct) __attribute__ ((__nothrow__)) fct +# else +# if defined __cplusplus && __GNUC_PREREQ (2,8) +# define __THROW throw () +# define __NTH(fct) fct throw () +# else +# define __THROW +# define __NTH(fct) fct +# endif +# endif + +#else /* Not GCC. */ + +# define __inline /* No inline functions. */ + +# define __THROW +# define __NTH(fct) fct + +# define __const const +# define __signed signed +# define __volatile volatile + +#endif /* GCC. */ + +/* These two macros are not used in glibc anymore. They are kept here + only because some other projects expect the macros to be defined. */ +#define __P(args) args +#define __PMT(args) args + +/* For these things, GCC behaves the ANSI way normally, + and the non-ANSI way under -traditional. */ + +#define __CONCAT(x,y) x ## y +#define __STRING(x) #x + +/* This is not a typedef so `const __ptr_t' does the right thing. */ +#define __ptr_t void * +#define __long_double_t long double + + +/* C++ needs to know that types and declarations are C, not C++. */ +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS +# define __END_DECLS +#endif + + +/* The standard library needs the functions from the ISO C90 standard + in the std namespace. At the same time we want to be safe for + future changes and we include the ISO C99 code in the non-standard + namespace __c99. The C++ wrapper header take case of adding the + definitions to the global namespace. */ +#if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES +# define __BEGIN_NAMESPACE_STD namespace std { +# define __END_NAMESPACE_STD } +# define __USING_NAMESPACE_STD(name) using std::name; +# define __BEGIN_NAMESPACE_C99 namespace __c99 { +# define __END_NAMESPACE_C99 } +# define __USING_NAMESPACE_C99(name) using __c99::name; +#else +/* For compatibility we do not add the declarations into any + namespace. They will end up in the global namespace which is what + old code expects. */ +# define __BEGIN_NAMESPACE_STD +# define __END_NAMESPACE_STD +# define __USING_NAMESPACE_STD(name) +# define __BEGIN_NAMESPACE_C99 +# define __END_NAMESPACE_C99 +# define __USING_NAMESPACE_C99(name) +#endif + + +/* Support for bounded pointers. */ +#ifndef __BOUNDED_POINTERS__ +# define __bounded /* nothing */ +# define __unbounded /* nothing */ +# define __ptrvalue /* nothing */ +#endif + + +/* Fortify support. */ +#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) +#define __bos0(ptr) __builtin_object_size (ptr, 0) +#define __warndecl(name, msg) extern void name (void) + + +/* Support for flexible arrays. */ +#if __GNUC_PREREQ (2,97) +/* GCC 2.97 supports C99 flexible array members. */ +# define __flexarr [] +#else +# ifdef __GNUC__ +# define __flexarr [0] +# else +# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +# define __flexarr [] +# else +/* Some other non-C99 compiler. Approximate with [1]. */ +# define __flexarr [1] +# endif +# endif +#endif + + +/* __asm__ ("xyz") is used throughout the headers to rename functions + at the assembly language level. This is wrapped by the __REDIRECT + macro, in order to support compilers that can do this some other + way. When compilers don't support asm-names at all, we have to do + preprocessor tricks instead (which don't have exactly the right + semantics, but it's the best we can do). + + Example: + int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */ + +#if defined __GNUC__ && __GNUC__ >= 2 + +# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias)) +# ifdef __cplusplus +# define __REDIRECT_NTH(name, proto, alias) \ + name proto __THROW __asm__ (__ASMNAME (#alias)) +# else +# define __REDIRECT_NTH(name, proto, alias) \ + name proto __asm__ (__ASMNAME (#alias)) __THROW +# endif +# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname) +# define __ASMNAME2(prefix, cname) __STRING (prefix) cname + +/* +#elif __SOME_OTHER_COMPILER__ + +# define __REDIRECT(name, proto, alias) name proto; \ + _Pragma("let " #name " = " #alias) +*/ +#endif + +/* GCC has various useful declarations that can be made with the + `__attribute__' syntax. All of the ways we use this do fine if + they are omitted for compilers that don't understand it. */ +#if !defined __GNUC__ || __GNUC__ < 2 +# define __attribute__(xyz) /* Ignore */ +#endif + +/* We make this a no-op unless it can be used as both a variable and + a type attribute. gcc 2.8 is known to support both. */ +#if __GNUC_PREREQ (2,8) +# define __attribute_aligned__(size) __attribute__ ((__aligned__ (size))) +#else +# define __attribute_aligned__(size) /* Ignore */ +#endif + +/* At some point during the gcc 2.96 development the `malloc' attribute + for functions was introduced. We don't want to use it unconditionally + (although this would be possible) since it generates warnings. */ +#if __GNUC_PREREQ (2,96) +# define __attribute_malloc__ __attribute__ ((__malloc__)) +#else +# define __attribute_malloc__ /* Ignore */ +#endif + +/* At some point during the gcc 2.96 development the `pure' attribute + for functions was introduced. We don't want to use it unconditionally + (although this would be possible) since it generates warnings. */ +#if __GNUC_PREREQ (2,96) +# define __attribute_pure__ __attribute__ ((__pure__)) +#else +# define __attribute_pure__ /* Ignore */ +#endif + +/* At some point during the gcc 3.1 development the `used' attribute + for functions was introduced. We don't want to use it unconditionally + (although this would be possible) since it generates warnings. */ +#if __GNUC_PREREQ (3,1) +# define __attribute_used__ __attribute__ ((__used__)) +# define __attribute_noinline__ __attribute__ ((__noinline__)) +#else +# define __attribute_used__ __attribute__ ((__unused__)) +# define __attribute_noinline__ /* Ignore */ +#endif + +/* gcc allows marking deprecated functions. */ +#if __GNUC_PREREQ (3,2) && !defined(__UCLIBC_HIDE_DEPRECATED__) +# define __attribute_deprecated__ __attribute__ ((__deprecated__)) +#else +# define __attribute_deprecated__ /* Ignore */ +#endif + +/* At some point during the gcc 2.8 development the `format_arg' attribute + for functions was introduced. We don't want to use it unconditionally + (although this would be possible) since it generates warnings. + If several `format_arg' attributes are given for the same function, in + gcc-3.0 and older, all but the last one are ignored. In newer gccs, + all designated arguments are considered. */ +#if __GNUC_PREREQ (2,8) +# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x))) +#else +# define __attribute_format_arg__(x) /* Ignore */ +#endif + +/* At some point during the gcc 2.97 development the `strfmon' format + attribute for functions was introduced. We don't want to use it + unconditionally (although this would be possible) since it + generates warnings. */ +#if __GNUC_PREREQ (2,97) +# define __attribute_format_strfmon__(a,b) \ + __attribute__ ((__format__ (__strfmon__, a, b))) +#else +# define __attribute_format_strfmon__(a,b) /* Ignore */ +#endif + +/* The nonull function attribute allows to mark pointer parameters which + must not be NULL. */ +#if __GNUC_PREREQ (3,3) +# define __nonnull(params) __attribute__ ((__nonnull__ params)) +#else +# define __nonnull(params) +#endif + +/* If fortification mode, we warn about unused results of certain + function calls which can lead to problems. */ +#if __GNUC_PREREQ (3,4) +# define __attribute_warn_unused_result__ \ + __attribute__ ((__warn_unused_result__)) +# if __USE_FORTIFY_LEVEL > 0 +# define __wur __attribute_warn_unused_result__ +# endif +#else +# define __attribute_warn_unused_result__ /* empty */ +#endif +#ifndef __wur +# define __wur /* Ignore */ +#endif + +/* Forces a function to be always inlined. */ +#if __GNUC_PREREQ (3,2) +# define __always_inline __inline __attribute__ ((__always_inline__)) +#else +# define __always_inline __inline +#endif + +/* It is possible to compile containing GCC extensions even if GCC is + run in pedantic mode if the uses are carefully marked using the + `__extension__' keyword. But this is not generally available before + version 2.8. */ +#if !__GNUC_PREREQ (2,8) +# define __extension__ /* Ignore */ +#endif + +/* __restrict is known in EGCS 1.2 and above. */ +#if !__GNUC_PREREQ (2,92) +# define __restrict /* Ignore */ +#endif + +/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is + array_name[restrict] + GCC 3.1 supports this. */ +#if __GNUC_PREREQ (3,1) && !defined __GNUG__ +# define __restrict_arr __restrict +#else +# ifdef __GNUC__ +# define __restrict_arr /* Not supported in old GCC. */ +# else +# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L +# define __restrict_arr restrict +# else +/* Some other non-C99 compiler. */ +# define __restrict_arr /* Not supported. */ +# endif +# endif +#endif + +#endif /* sys/cdefs.h */ diff --git a/conts/posix/libposix/include/posix/sys/dir.h b/conts/posix/libposix/include/posix/sys/dir.h new file mode 100644 index 0000000..2611d6c --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/dir.h @@ -0,0 +1,28 @@ +/* Copyright (C) 1991, 1996 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_DIR_H +#define _SYS_DIR_H 1 + +#include + +#include + +#define direct dirent + +#endif /* sys/dir.h */ diff --git a/conts/posix/libposix/include/posix/sys/errno.h b/conts/posix/libposix/include/posix/sys/errno.h new file mode 100644 index 0000000..339f4fc --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/errno.h @@ -0,0 +1 @@ +#include diff --git a/conts/posix/libposix/include/posix/sys/fcntl.h b/conts/posix/libposix/include/posix/sys/fcntl.h new file mode 100644 index 0000000..cd30455 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/fcntl.h @@ -0,0 +1 @@ +#include diff --git a/conts/posix/libposix/include/posix/sys/file.h b/conts/posix/libposix/include/posix/sys/file.h new file mode 100644 index 0000000..93b3635 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/file.h @@ -0,0 +1,56 @@ +/* Copyright (C) 1991, 92, 96, 97, 98, 99 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_FILE_H +#define _SYS_FILE_H 1 + +#include + +#ifndef _FCNTL_H +# include +#endif + +__BEGIN_DECLS + + +/* Alternate names for values for the WHENCE argument to `lseek'. + These are the same as SEEK_SET, SEEK_CUR, and SEEK_END, respectively. */ +#ifndef L_SET +# define L_SET 0 /* Seek from beginning of file. */ +# define L_INCR 1 /* Seek from current position. */ +# define L_XTND 2 /* Seek from end of file. */ +#endif + + +/* Operations for the `flock' call. */ +#define LOCK_SH 1 /* Shared lock. */ +#define LOCK_EX 2 /* Exclusive lock. */ +#define LOCK_UN 8 /* Unlock. */ + +/* Can be OR'd in to one of the above. */ +#define LOCK_NB 4 /* Don't block when locking. */ + + +/* Apply or remove an advisory lock, according to OPERATION, + on the file FD refers to. */ +extern int flock (int __fd, int __operation) __THROW; + + +__END_DECLS + +#endif /* sys/file.h */ diff --git a/conts/posix/libposix/include/posix/sys/fsuid.h b/conts/posix/libposix/include/posix/sys/fsuid.h new file mode 100644 index 0000000..4ecb199 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/fsuid.h @@ -0,0 +1,36 @@ +/* Copyright (C) 1997, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_FSUID_H +#define _SYS_FSUID_H 1 + +#include +#include + +__BEGIN_DECLS + +/* Change uid used for file access control to UID, without affecting + other privileges (such as who can send signals at the process). */ +extern int setfsuid (__uid_t __uid) __THROW; + +/* Ditto for group id. */ +extern int setfsgid (__gid_t __gid) __THROW; + +__END_DECLS + +#endif /* fsuid.h */ diff --git a/conts/posix/libposix/include/posix/sys/ioctl.h b/conts/posix/libposix/include/posix/sys/ioctl.h new file mode 100644 index 0000000..6d8a0f4 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/ioctl.h @@ -0,0 +1,46 @@ +/* Copyright (C) 1991, 92, 93, 94, 96, 98, 99 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_IOCTL_H +#define _SYS_IOCTL_H 1 + +#include + +__BEGIN_DECLS + +/* Get the list of `ioctl' requests and related constants. */ +#include + +/* Define some types used by `ioctl' requests. */ +#include + +/* On a Unix system, the system probably defines some of + the symbols we define in (usually with the same + values). The code to generate has omitted these + symbols to avoid the conflict, but a Unix program expects + to define them, so we must include here. */ +#include + +/* Perform the I/O control operation specified by REQUEST on FD. + One argument may follow; its presence and type depend on REQUEST. + Return value depends on REQUEST. Usually -1 indicates error. */ +extern int ioctl (int __fd, unsigned long int __request, ...) __THROW; + +__END_DECLS + +#endif /* sys/ioctl.h */ diff --git a/conts/posix/libposix/include/posix/sys/ipc.h b/conts/posix/libposix/include/posix/sys/ipc.h new file mode 100644 index 0000000..42806db --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/ipc.h @@ -0,0 +1,58 @@ +/* Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_IPC_H +#define _SYS_IPC_H 1 + +#include + +#if !defined __USE_SVID && !defined __USE_XOPEN && __GNUC__ >= 2 +# warning "Files using this header must be compiled with _SVID_SOURCE or _XOPEN_SOURCE" +#endif + +/* Get system dependent definition of `struct ipc_perm' and more. */ +#include + +#ifndef __uid_t_defined +typedef __uid_t uid_t; +# define __uid_t_defined +#endif + +#ifndef __gid_t_defined +typedef __gid_t gid_t; +# define __gid_t_defined +#endif + +#ifndef __mode_t_defined +typedef __mode_t mode_t; +# define __mode_t_defined +#endif + +#ifndef __key_t_defined +typedef __key_t key_t; +# define __key_t_defined +#endif + +__BEGIN_DECLS + +/* Generates key for System V style IPC. */ +extern key_t ftok (__const char *__pathname, int __proj_id) __THROW; + +__END_DECLS + +#endif /* sys/ipc.h */ diff --git a/conts/posix/libposix/include/posix/sys/kd.h b/conts/posix/libposix/include/posix/sys/kd.h new file mode 100644 index 0000000..d459c07 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/kd.h @@ -0,0 +1,35 @@ +/* Copyright (C) 1996, 1997, 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_KD_H +#define _SYS_KD_H 1 + +/* Make sure the header is not loaded. */ +#ifndef _LINUX_TYPES_H +# define _LINUX_TYPES_H 1 +# define __undef_LINUX_TYPES_H +#endif + +#include + +#ifdef __undef_LINUX_TYPES_H +# undef _LINUX_TYPES_H +# undef __undef_LINUX_TYPES_H +#endif + +#endif /* sys/kd.h */ diff --git a/conts/posix/libposix/include/posix/sys/kdaemon.h b/conts/posix/libposix/include/posix/sys/kdaemon.h new file mode 100644 index 0000000..61491f9 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/kdaemon.h @@ -0,0 +1,33 @@ +/* Copyright (C) 1996, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Interfaces to control the various kernel daemons. */ + +#ifndef _SYS_KDAEMON_H + +#define _SYS_KDAEMON_H 1 +#include + +__BEGIN_DECLS + +/* Start, flush, or tune the kernel's buffer flushing daemon. */ +extern int bdflush (int __func, long int __data) __THROW; + +__END_DECLS + +#endif /* _SYS_KDAEMON_H */ diff --git a/conts/posix/libposix/include/posix/sys/klog.h b/conts/posix/libposix/include/posix/sys/klog.h new file mode 100644 index 0000000..35f5fe4 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/klog.h @@ -0,0 +1,34 @@ +/* Copyright (C) 1996, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_KLOG_H + +#define _SYS_KLOG_H 1 +#include + +__BEGIN_DECLS + +/* Control the kernel's logging facility. This corresponds exactly to + the kernel's syslog system call, but that name is easily confused + with the user-level syslog facility, which is something completely + different. */ +extern int klogctl (int __type, char *__bufp, int __len) __THROW; + +__END_DECLS + +#endif /* _SYS_KLOG_H */ diff --git a/conts/posix/libposix/include/posix/sys/mman.h b/conts/posix/libposix/include/posix/sys/mman.h new file mode 100644 index 0000000..76c2009 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/mman.h @@ -0,0 +1,174 @@ +/* Definitions for BSD-style memory management. + Copyright (C) 1994-2000, 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_MMAN_H +#define _SYS_MMAN_H 1 + +#include +#include +#define __need_size_t +#include + +#ifndef __off_t_defined +# ifndef __USE_FILE_OFFSET64 +typedef __off_t off_t; +# else +typedef __off64_t off_t; +# endif +# define __off_t_defined +#endif + +#ifndef __mode_t_defined +typedef __mode_t mode_t; +# define __mode_t_defined +#endif + +#include + +/* Return value of `mmap' in case of an error. */ +#define MAP_FAILED ((void *) -1) + +__BEGIN_DECLS +/* Map addresses starting near ADDR and extending for LEN bytes. from + OFFSET into the file FD describes according to PROT and FLAGS. If ADDR + is nonzero, it is the desired mapping address. If the MAP_FIXED bit is + set in FLAGS, the mapping will be at ADDR exactly (which must be + page-aligned); otherwise the system chooses a convenient nearby address. + The return value is the actual mapping address chosen or MAP_FAILED + for errors (in which case `errno' is set). A successful `mmap' call + deallocates any previous mapping for the affected region. */ + +#ifndef __USE_FILE_OFFSET64 +extern void *mmap (void *__addr, size_t __len, int __prot, + int __flags, int __fd, __off_t __offset) __THROW; +#else +# ifdef __REDIRECT +extern void * __REDIRECT (mmap, + (void *__addr, size_t __len, int __prot, + int __flags, int __fd, __off64_t __offset), + mmap64); +# else +# define mmap mmap64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern void *mmap64 (void *__addr, size_t __len, int __prot, + int __flags, int __fd, __off64_t __offset) __THROW; +#endif + +/* Deallocate any mapping for the region starting at ADDR and extending LEN + bytes. Returns 0 if successful, -1 for errors (and sets errno). */ +extern int munmap (void *__addr, size_t __len) __THROW; + +/* Change the memory protection of the region starting at ADDR and + extending LEN bytes to PROT. Returns 0 if successful, -1 for errors + (and sets errno). */ +extern int mprotect (void *__addr, size_t __len, int __prot) __THROW; + +#ifdef __ARCH_USE_MMU__ + +/* Synchronize the region starting at ADDR and extending LEN bytes with the + file it maps. Filesystem operations on a file being mapped are + unpredictable before this is done. Flags are from the MS_* set. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int msync (void *__addr, size_t __len, int __flags); + +#else + +/* On no-mmu systems you can't have real private mappings. */ +static inline int msync (void *__addr, size_t __len, int __flags) { return 0; } + +#endif + +#ifdef __USE_BSD +/* Advise the system about particular usage patterns the program follows + for the region starting at ADDR and extending LEN bytes. */ +extern int madvise (void *__addr, size_t __len, int __advice) __THROW; +#endif +#ifdef __USE_XOPEN2K +/* This is the POSIX name for this function. */ +extern int posix_madvise (void *__addr, size_t __len, int __advice) __THROW; +#endif + +#ifdef __ARCH_USE_MMU__ + +/* Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to + be memory resident. */ +extern int mlock (__const void *__addr, size_t __len) __THROW; + +/* Unlock whole pages previously mapped by the range [ADDR,ADDR+LEN). */ +extern int munlock (__const void *__addr, size_t __len) __THROW; + +/* Cause all currently mapped pages of the process to be memory resident + until unlocked by a call to the `munlockall', until the process exits, + or until the process calls `execve'. */ +extern int mlockall (int __flags) __THROW; + +/* All currently mapped pages of the process' address space become + unlocked. */ +extern int munlockall (void) __THROW; + +#else + +/* On no-mmu systems, memory cannot be swapped out, so + * these functions will always succeed. */ +static inline int mlock (__const void *__addr, size_t __len) { return 0; } +static inline int munlock (__const void *__addr, size_t __len) { return 0; } +static inline int mlockall (int __flags) { return 0; } +static inline int munlockall (void) { return 0; } + +#endif + +#ifdef __USE_MISC +/* Remap pages mapped by the range [ADDR,ADDR+OLD_LEN) to new length + NEW_LEN. If MREMAP_MAYMOVE is set in FLAGS the returned address + may differ from ADDR. If MREMAP_FIXED is set in FLAGS the function + takes another paramter which is a fixed address at which the block + resides after a successful call. */ +extern void *mremap (void *__addr, size_t __old_len, size_t __new_len, + int __flags, ...) __THROW; + +/* mincore returns the memory residency status of the pages in the + current process's address space specified by [start, start + len). + The status is returned in a vector of bytes. The least significant + bit of each byte is 1 if the referenced page is in memory, otherwise + it is zero. */ +extern int mincore (void *__start, size_t __len, unsigned char *__vec) + __THROW; + +#if 0 +/* Remap arbitrary pages of a shared backing store within an existing + VMA. */ +extern int remap_file_pages (void *__start, size_t __size, int __prot, + size_t __pgoff, int __flags) __THROW; +#endif +#endif + + +/* Open shared memory segment. */ +extern int shm_open (__const char *__name, int __oflag, mode_t __mode); + +/* Remove shared memory segment. */ +extern int shm_unlink (__const char *__name); + +__END_DECLS + +#endif /* sys/mman.h */ diff --git a/conts/posix/libposix/include/posix/sys/mount.h b/conts/posix/libposix/include/posix/sys/mount.h new file mode 100644 index 0000000..b305549 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/mount.h @@ -0,0 +1,119 @@ +/* Header file for mounting/unmount Linux filesystems. + Copyright (C) 1996,1997,1998,1999,2000,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This is taken from /usr/include/linux/fs.h. */ + +#ifndef _SYS_MOUNT_H +#define _SYS_MOUNT_H 1 + +#include +#include + +#define BLOCK_SIZE 1024 +#define BLOCK_SIZE_BITS 10 + + +/* These are the fs-independent mount-flags: up to 16 flags are + supported */ +enum +{ + MS_RDONLY = 1, /* Mount read-only. */ +#define MS_RDONLY MS_RDONLY + MS_NOSUID = 2, /* Ignore suid and sgid bits. */ +#define MS_NOSUID MS_NOSUID + MS_NODEV = 4, /* Disallow access to device special files. */ +#define MS_NODEV MS_NODEV + MS_NOEXEC = 8, /* Disallow program execution. */ +#define MS_NOEXEC MS_NOEXEC + MS_SYNCHRONOUS = 16, /* Writes are synced at once. */ +#define MS_SYNCHRONOUS MS_SYNCHRONOUS + MS_REMOUNT = 32, /* Alter flags of a mounted FS. */ +#define MS_REMOUNT MS_REMOUNT + MS_MANDLOCK = 64, /* Allow mandatory locks on an FS. */ +#define MS_MANDLOCK MS_MANDLOCK + S_WRITE = 128, /* Write on file/directory/symlink. */ +#define S_WRITE S_WRITE + S_APPEND = 256, /* Append-only file. */ +#define S_APPEND S_APPEND + S_IMMUTABLE = 512, /* Immutable file. */ +#define S_IMMUTABLE S_IMMUTABLE + MS_NOATIME = 1024, /* Do not update access times. */ +#define MS_NOATIME MS_NOATIME + MS_NODIRATIME = 2048, /* Do not update directory access times. */ +#define MS_NODIRATIME MS_NODIRATIME + MS_BIND = 4096, /* Bind directory at different place. */ +#define MS_BIND MS_BIND +}; + +/* Flags that can be altered by MS_REMOUNT */ +#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME \ + |MS_NODIRATIME) + + +/* Magic mount flag number. Has to be or-ed to the flag values. */ + +#define MS_MGC_VAL 0xc0ed0000 /* Magic flag number to indicate "new" flags */ +#define MS_MGC_MSK 0xffff0000 /* Magic flag number mask */ + + +/* The read-only stuff doesn't really belong here, but any other place + is probably as bad and I don't want to create yet another include + file. */ + +#define BLKROSET _IO(0x12, 93) /* Set device read-only (0 = read-write). */ +#define BLKROGET _IO(0x12, 94) /* Get read-only status (0 = read_write). */ +#define BLKRRPART _IO(0x12, 95) /* Re-read partition table. */ +#define BLKGETSIZE _IO(0x12, 96) /* Return device size. */ +#define BLKFLSBUF _IO(0x12, 97) /* Flush buffer cache. */ +#define BLKRASET _IO(0x12, 98) /* Set read ahead for block device. */ +#define BLKRAGET _IO(0x12, 99) /* Get current read ahead setting. */ +#define BLKFRASET _IO(0x12,100) /* Set filesystem read-ahead. */ +#define BLKFRAGET _IO(0x12,101) /* Get filesystem read-ahead. */ +#define BLKSECTSET _IO(0x12,102) /* Set max sectors per request. */ +#define BLKSECTGET _IO(0x12,103) /* Get max sectors per request. */ +#define BLKSSZGET _IO(0x12,104) /* Get block device sector size. */ +#define BLKBSZGET _IOR(0x12,112,size_t) +#define BLKBSZSET _IOW(0x12,113,size_t) +#define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size. */ + + +/* Possible value for FLAGS parameter of `umount2'. */ +enum +{ + MNT_FORCE = 1 /* Force unmounting. */ +#define MNT_FORCE MNT_FORCE +}; + + +__BEGIN_DECLS + +/* Mount a filesystem. */ +extern int mount (__const char *__special_file, __const char *__dir, + __const char *__fstype, unsigned long int __rwflag, + __const void *__data) __THROW; + +/* Unmount a filesystem. */ +extern int umount (__const char *__special_file) __THROW; + +/* Unmount a filesystem. Force unmounting if FLAGS is set to MNT_FORCE. */ +extern int umount2 (__const char *__special_file, int __flags) __THROW; + +__END_DECLS + +#endif /* _SYS_MOUNT_H */ diff --git a/conts/posix/libposix/include/posix/sys/msg.h b/conts/posix/libposix/include/posix/sys/msg.h new file mode 100644 index 0000000..1fd64b2 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/msg.h @@ -0,0 +1,81 @@ +/* Copyright (C) 1995,1996,1997,1999,2000,2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_MSG_H +#define _SYS_MSG_H + +#include + +/* Get common definition of System V style IPC. */ +#include + +/* Get system dependent definition of `struct msqid_ds' and more. */ +#include + +/* Define types required by the standard. */ +#define __need_time_t +#include + +#ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +#endif + +#ifndef __ssize_t_defined +typedef __ssize_t ssize_t; +# define __ssize_t_defined +#endif + +/* The following System V style IPC functions implement a message queue + system. The definition is found in XPG2. */ + +#ifdef __USE_GNU +/* Template for struct to be used as argument for `msgsnd' and `msgrcv'. */ +struct msgbuf + { + long int mtype; /* type of received/sent message */ + char mtext[1]; /* text of the message */ + }; +#endif + + +__BEGIN_DECLS + +/* Message queue control operation. */ +extern int msgctl (int __msqid, int __cmd, struct msqid_ds *__buf) __THROW; + +/* Get messages queue. */ +extern int msgget (key_t __key, int __msgflg) __THROW; + +/* Receive message from message queue. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int msgrcv (int __msqid, void *__msgp, size_t __msgsz, + long int __msgtyp, int __msgflg); + +/* Send message to message queue. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int msgsnd (int __msqid, __const void *__msgp, size_t __msgsz, + int __msgflg); + +__END_DECLS + +#endif /* sys/msg.h */ diff --git a/conts/posix/libposix/include/posix/sys/mtio.h b/conts/posix/libposix/include/posix/sys/mtio.h new file mode 100644 index 0000000..51fa550 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/mtio.h @@ -0,0 +1,277 @@ +/* Structures and definitions for magnetic tape I/O control commands. + Copyright (C) 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Written by H. Bergman . */ + +#ifndef _SYS_MTIO_H +#define _SYS_MTIO_H 1 + +/* Get necessary definitions from system and kernel headers. */ +#include +#include + + +/* Structure for MTIOCTOP - magnetic tape operation command. */ +struct mtop + { + short int mt_op; /* Operations defined below. */ + int mt_count; /* How many of them. */ + }; +#define _IOT_mtop /* Hurd ioctl type field. */ \ + _IOT (_IOTS (short), 1, _IOTS (int), 1, 0, 0) + +/* Magnetic Tape operations [Not all operations supported by all drivers]. */ +#define MTRESET 0 /* +reset drive in case of problems. */ +#define MTFSF 1 /* Forward space over FileMark, + * position at first record of next file. */ +#define MTBSF 2 /* Backward space FileMark (position before FM). */ +#define MTFSR 3 /* Forward space record. */ +#define MTBSR 4 /* Backward space record. */ +#define MTWEOF 5 /* Write an end-of-file record (mark). */ +#define MTREW 6 /* Rewind. */ +#define MTOFFL 7 /* Rewind and put the drive offline (eject?). */ +#define MTNOP 8 /* No op, set status only (read with MTIOCGET). */ +#define MTRETEN 9 /* Retension tape. */ +#define MTBSFM 10 /* +backward space FileMark, position at FM. */ +#define MTFSFM 11 /* +forward space FileMark, position at FM. */ +#define MTEOM 12 /* Goto end of recorded media (for appending files). + MTEOM positions after the last FM, ready for + appending another file. */ +#define MTERASE 13 /* Erase tape -- be careful! */ + +#define MTRAS1 14 /* Run self test 1 (nondestructive). */ +#define MTRAS2 15 /* Run self test 2 (destructive). */ +#define MTRAS3 16 /* Reserved for self test 3. */ + +#define MTSETBLK 20 /* Set block length (SCSI). */ +#define MTSETDENSITY 21 /* Set tape density (SCSI). */ +#define MTSEEK 22 /* Seek to block (Tandberg, etc.). */ +#define MTTELL 23 /* Tell block (Tandberg, etc.). */ +#define MTSETDRVBUFFER 24 /* Set the drive buffering according to SCSI-2. + Ordinary buffered operation with code 1. */ +#define MTFSS 25 /* Space forward over setmarks. */ +#define MTBSS 26 /* Space backward over setmarks. */ +#define MTWSM 27 /* Write setmarks. */ + +#define MTLOCK 28 /* Lock the drive door. */ +#define MTUNLOCK 29 /* Unlock the drive door. */ +#define MTLOAD 30 /* Execute the SCSI load command. */ +#define MTUNLOAD 31 /* Execute the SCSI unload command. */ +#define MTCOMPRESSION 32/* Control compression with SCSI mode page 15. */ +#define MTSETPART 33 /* Change the active tape partition. */ +#define MTMKPART 34 /* Format the tape with one or two partitions. */ + +/* structure for MTIOCGET - mag tape get status command */ + +struct mtget + { + long int mt_type; /* Type of magtape device. */ + long int mt_resid; /* Residual count: (not sure) + number of bytes ignored, or + number of files not skipped, or + number of records not skipped. */ + /* The following registers are device dependent. */ + long int mt_dsreg; /* Status register. */ + long int mt_gstat; /* Generic (device independent) status. */ + long int mt_erreg; /* Error register. */ + /* The next two fields are not always used. */ + __daddr_t mt_fileno; /* Number of current file on tape. */ + __daddr_t mt_blkno; /* Current block number. */ + }; +#define _IOT_mtget /* Hurd ioctl type field. */ \ + _IOT (_IOTS (long), 7, 0, 0, 0, 0) + + +/* Constants for mt_type. Not all of these are supported, and + these are not all of the ones that are supported. */ +#define MT_ISUNKNOWN 0x01 +#define MT_ISQIC02 0x02 /* Generic QIC-02 tape streamer. */ +#define MT_ISWT5150 0x03 /* Wangtek 5150EQ, QIC-150, QIC-02. */ +#define MT_ISARCHIVE_5945L2 0x04 /* Archive 5945L-2, QIC-24, QIC-02?. */ +#define MT_ISCMSJ500 0x05 /* CMS Jumbo 500 (QIC-02?). */ +#define MT_ISTDC3610 0x06 /* Tandberg 6310, QIC-24. */ +#define MT_ISARCHIVE_VP60I 0x07 /* Archive VP60i, QIC-02. */ +#define MT_ISARCHIVE_2150L 0x08 /* Archive Viper 2150L. */ +#define MT_ISARCHIVE_2060L 0x09 /* Archive Viper 2060L. */ +#define MT_ISARCHIVESC499 0x0A /* Archive SC-499 QIC-36 controller. */ +#define MT_ISQIC02_ALL_FEATURES 0x0F /* Generic QIC-02 with all features. */ +#define MT_ISWT5099EEN24 0x11 /* Wangtek 5099-een24, 60MB, QIC-24. */ +#define MT_ISTEAC_MT2ST 0x12 /* Teac MT-2ST 155mb drive, + Teac DC-1 card (Wangtek type). */ +#define MT_ISEVEREX_FT40A 0x32 /* Everex FT40A (QIC-40). */ +#define MT_ISDDS1 0x51 /* DDS device without partitions. */ +#define MT_ISDDS2 0x52 /* DDS device with partitions. */ +#define MT_ISSCSI1 0x71 /* Generic ANSI SCSI-1 tape unit. */ +#define MT_ISSCSI2 0x72 /* Generic ANSI SCSI-2 tape unit. */ + +/* QIC-40/80/3010/3020 ftape supported drives. + 20bit vendor ID + 0x800000 (see vendors.h in ftape distribution). */ +#define MT_ISFTAPE_UNKNOWN 0x800000 /* obsolete */ +#define MT_ISFTAPE_FLAG 0x800000 + +struct mt_tape_info + { + long int t_type; /* Device type id (mt_type). */ + char *t_name; /* Descriptive name. */ + }; + +#define MT_TAPE_INFO \ + { \ + {MT_ISUNKNOWN, "Unknown type of tape device"}, \ + {MT_ISQIC02, "Generic QIC-02 tape streamer"}, \ + {MT_ISWT5150, "Wangtek 5150, QIC-150"}, \ + {MT_ISARCHIVE_5945L2, "Archive 5945L-2"}, \ + {MT_ISCMSJ500, "CMS Jumbo 500"}, \ + {MT_ISTDC3610, "Tandberg TDC 3610, QIC-24"}, \ + {MT_ISARCHIVE_VP60I, "Archive VP60i, QIC-02"}, \ + {MT_ISARCHIVE_2150L, "Archive Viper 2150L"}, \ + {MT_ISARCHIVE_2060L, "Archive Viper 2060L"}, \ + {MT_ISARCHIVESC499, "Archive SC-499 QIC-36 controller"}, \ + {MT_ISQIC02_ALL_FEATURES, "Generic QIC-02 tape, all features"}, \ + {MT_ISWT5099EEN24, "Wangtek 5099-een24, 60MB"}, \ + {MT_ISTEAC_MT2ST, "Teac MT-2ST 155mb data cassette drive"}, \ + {MT_ISEVEREX_FT40A, "Everex FT40A, QIC-40"}, \ + {MT_ISSCSI1, "Generic SCSI-1 tape"}, \ + {MT_ISSCSI2, "Generic SCSI-2 tape"}, \ + {0, NULL} \ + } + + +/* Structure for MTIOCPOS - mag tape get position command. */ + +struct mtpos + { + long int mt_blkno; /* Current block number. */ + }; +#define _IOT_mtpos /* Hurd ioctl type field. */ \ + _IOT_SIMPLE (long) + + +/* Structure for MTIOCGETCONFIG/MTIOCSETCONFIG primarily intended + as an interim solution for QIC-02 until DDI is fully implemented. */ +struct mtconfiginfo + { + long int mt_type; /* Drive type. */ + long int ifc_type; /* Interface card type. */ + unsigned short int irqnr; /* IRQ number to use. */ + unsigned short int dmanr; /* DMA channel to use. */ + unsigned short int port; /* IO port base address. */ + + unsigned long int debug; /* Debugging flags. */ + + unsigned have_dens:1; + unsigned have_bsf:1; + unsigned have_fsr:1; + unsigned have_bsr:1; + unsigned have_eod:1; + unsigned have_seek:1; + unsigned have_tell:1; + unsigned have_ras1:1; + unsigned have_ras2:1; + unsigned have_ras3:1; + unsigned have_qfa:1; + + unsigned pad1:5; + char reserved[10]; + }; +#define _IOT_mtconfiginfo /* Hurd ioctl type field. */ \ + _IOT (_IOTS (long), 2, _IOTS (short), 3, _IOTS (long), 1) /* XXX wrong */ + + +/* Magnetic tape I/O control commands. */ +#define MTIOCTOP _IOW('m', 1, struct mtop) /* Do a mag tape op. */ +#define MTIOCGET _IOR('m', 2, struct mtget) /* Get tape status. */ +#define MTIOCPOS _IOR('m', 3, struct mtpos) /* Get tape position.*/ + +/* The next two are used by the QIC-02 driver for runtime reconfiguration. + See tpqic02.h for struct mtconfiginfo. */ +#define MTIOCGETCONFIG _IOR('m', 4, struct mtconfiginfo) /* Get tape config.*/ +#define MTIOCSETCONFIG _IOW('m', 5, struct mtconfiginfo) /* Set tape config.*/ + +/* Generic Mag Tape (device independent) status macros for examining + mt_gstat -- HP-UX compatible. + There is room for more generic status bits here, but I don't + know which of them are reserved. At least three or so should + be added to make this really useful. */ +#define GMT_EOF(x) ((x) & 0x80000000) +#define GMT_BOT(x) ((x) & 0x40000000) +#define GMT_EOT(x) ((x) & 0x20000000) +#define GMT_SM(x) ((x) & 0x10000000) /* DDS setmark */ +#define GMT_EOD(x) ((x) & 0x08000000) /* DDS EOD */ +#define GMT_WR_PROT(x) ((x) & 0x04000000) +/* #define GMT_ ? ((x) & 0x02000000) */ +#define GMT_ONLINE(x) ((x) & 0x01000000) +#define GMT_D_6250(x) ((x) & 0x00800000) +#define GMT_D_1600(x) ((x) & 0x00400000) +#define GMT_D_800(x) ((x) & 0x00200000) +/* #define GMT_ ? ((x) & 0x00100000) */ +/* #define GMT_ ? ((x) & 0x00080000) */ +#define GMT_DR_OPEN(x) ((x) & 0x00040000) /* Door open (no tape). */ +/* #define GMT_ ? ((x) & 0x00020000) */ +#define GMT_IM_REP_EN(x) ((x) & 0x00010000) /* Immediate report mode.*/ +/* 16 generic status bits unused. */ + + +/* SCSI-tape specific definitions. Bitfield shifts in the status */ +#define MT_ST_BLKSIZE_SHIFT 0 +#define MT_ST_BLKSIZE_MASK 0xffffff +#define MT_ST_DENSITY_SHIFT 24 +#define MT_ST_DENSITY_MASK 0xff000000 + +#define MT_ST_SOFTERR_SHIFT 0 +#define MT_ST_SOFTERR_MASK 0xffff + +/* Bitfields for the MTSETDRVBUFFER ioctl. */ +#define MT_ST_OPTIONS 0xf0000000 +#define MT_ST_BOOLEANS 0x10000000 +#define MT_ST_SETBOOLEANS 0x30000000 +#define MT_ST_CLEARBOOLEANS 0x40000000 +#define MT_ST_WRITE_THRESHOLD 0x20000000 +#define MT_ST_DEF_BLKSIZE 0x50000000 +#define MT_ST_DEF_OPTIONS 0x60000000 + +#define MT_ST_BUFFER_WRITES 0x1 +#define MT_ST_ASYNC_WRITES 0x2 +#define MT_ST_READ_AHEAD 0x4 +#define MT_ST_DEBUGGING 0x8 +#define MT_ST_TWO_FM 0x10 +#define MT_ST_FAST_MTEOM 0x20 +#define MT_ST_AUTO_LOCK 0x40 +#define MT_ST_DEF_WRITES 0x80 +#define MT_ST_CAN_BSR 0x100 +#define MT_ST_NO_BLKLIMS 0x200 +#define MT_ST_CAN_PARTITIONS 0x400 +#define MT_ST_SCSI2LOGICAL 0x800 + +/* The mode parameters to be controlled. Parameter chosen with bits 20-28. */ +#define MT_ST_CLEAR_DEFAULT 0xfffff +#define MT_ST_DEF_DENSITY (MT_ST_DEF_OPTIONS | 0x100000) +#define MT_ST_DEF_COMPRESSION (MT_ST_DEF_OPTIONS | 0x200000) +#define MT_ST_DEF_DRVBUFFER (MT_ST_DEF_OPTIONS | 0x300000) + +/* The offset for the arguments for the special HP changer load command. */ +#define MT_ST_HPLOADER_OFFSET 10000 + + +/* Specify default tape device. */ +#ifndef DEFTAPE +# define DEFTAPE "/dev/tape" +#endif + +#endif /* mtio.h */ diff --git a/conts/posix/libposix/include/posix/sys/param.h b/conts/posix/libposix/include/posix/sys/param.h new file mode 100644 index 0000000..0b0424e --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/param.h @@ -0,0 +1,72 @@ +/* Copyright (C) 1995,1996,1997,2000,2001,2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_PARAM_H +#define _SYS_PARAM_H 1 + +#include +#include +#include + +/* BSD names for some values. */ + +#define NBBY CHAR_BIT +#ifndef NGROUPS +# define NGROUPS NGROUPS_MAX +#endif +#define MAXSYMLINKS 20 +#define CANBSIZ MAX_CANON +#define NCARGS ARG_MAX +#define MAXPATHLEN PATH_MAX +/* The following is not really correct but it is a value we used for a + long time and which seems to be usable. People should not use NOFILE + anyway. */ +#define NOFILE 256 + + +#include + +/* Bit map related macros. */ +#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) +#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) +#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) +#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) + +/* Macros for counting and rounding. */ +#ifndef howmany +# define howmany(x, y) (((x) + ((y) - 1)) / (y)) +#endif +#ifdef __GNUC__ +# define roundup(x, y) (__builtin_constant_p (y) && powerof2 (y) \ + ? (((x) + (y) - 1) & ~((y) - 1)) \ + : ((((x) + ((y) - 1)) / (y)) * (y))) +#else +# define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) +#endif +#define powerof2(x) ((((x) - 1) & (x)) == 0) + +/* Macros for min/max. */ +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) + + +/* Unit of `st_blocks'. */ +#define DEV_BSIZE 512 + + +#endif /* sys/param.h */ diff --git a/conts/posix/libposix/include/posix/sys/personality.h b/conts/posix/libposix/include/posix/sys/personality.h new file mode 100644 index 0000000..5d14a9b --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/personality.h @@ -0,0 +1,73 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* Taken verbatim from Linux 2.4 (include/linux/personality.h). */ + +#ifndef _SYS_PERSONALITY_H +#define _SYS_PERSONALITY_H 1 + +#include + +/* Flags for bug emulation. + These occupy the top three bytes. */ +enum + { + MMAP_PAGE_ZERO = 0x0100000, + ADDR_LIMIT_32BIT = 0x0800000, + SHORT_INODE = 0x1000000, + WHOLE_SECONDS = 0x2000000, + STICKY_TIMEOUTS = 0x4000000, + }; + +/* Personality types. + + These go in the low byte. Avoid using the top bit, it will + conflict with error returns. */ +enum + { + PER_LINUX = 0x0000, + PER_LINUX_32BIT = 0x0000 | ADDR_LIMIT_32BIT, + PER_SVR4 = 0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO, + PER_SVR3 = 0x0002 | STICKY_TIMEOUTS | SHORT_INODE, + PER_SCOSVR3 = 0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS | SHORT_INODE, + PER_OSR5 = 0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS, + PER_WYSEV386 = 0x0004 | STICKY_TIMEOUTS | SHORT_INODE, + PER_ISCR4 = 0x0005 | STICKY_TIMEOUTS, + PER_BSD = 0x0006, + PER_SUNOS = 0x0006 | STICKY_TIMEOUTS, + PER_XENIX = 0x0007 | STICKY_TIMEOUTS | SHORT_INODE, + PER_LINUX32 = 0x0008, + PER_IRIX32 = 0x0009 | STICKY_TIMEOUTS, /* IRIX5 32-bit */ + PER_IRIXN32 = 0x000a | STICKY_TIMEOUTS, /* IRIX6 new 32-bit */ + PER_IRIX64 = 0x000b | STICKY_TIMEOUTS, /* IRIX6 64-bit */ + PER_RISCOS = 0x000c, + PER_SOLARIS = 0x000d | STICKY_TIMEOUTS, + PER_UW7 = 0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO, + PER_HPUX = 0x000f, + PER_OSF4 = 0x0010, + PER_MASK = 0x00ff, + }; + +__BEGIN_DECLS + +/* Set different ABIs (personalities). */ +extern int personality (unsigned long int __persona) __THROW; + +__END_DECLS + +#endif /* sys/personality.h */ diff --git a/conts/posix/libposix/include/posix/sys/poll.h b/conts/posix/libposix/include/posix/sys/poll.h new file mode 100644 index 0000000..70f0d31 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/poll.h @@ -0,0 +1,76 @@ +/* Compatibility definitions for System V `poll' interface. + Copyright (C) 1994,1996-2001,2004,2005,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_POLL_H +#define _SYS_POLL_H 1 + +#include + +/* Get the platform dependent bits of `poll'. */ +#include +#ifdef __USE_GNU +/* Get the __sigset_t definition. */ +# include +/* Get the timespec definition. */ +# define __need_timespec +# include +/* get NULL definition. */ +# include +#endif + + +/* Type used for the number of file descriptors. */ +typedef unsigned long int nfds_t; + +/* Data structure describing a polling request. */ +struct pollfd + { + int fd; /* File descriptor to poll. */ + short int events; /* Types of events poller cares about. */ + short int revents; /* Types of events that actually occurred. */ + }; + + +__BEGIN_DECLS + +/* Poll the file descriptors described by the NFDS structures starting at + FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for + an event to occur; if TIMEOUT is -1, block until an event occurs. + Returns the number of file descriptors with events, zero if timed out, + or -1 for errors. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout); + +#ifdef __USE_GNU +/* Like poll, but before waiting the threads signal mask is replaced + with that specified in the fourth parameter. For better usability, + the timeout value is specified using a TIMESPEC object. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int ppoll (struct pollfd *__fds, nfds_t __nfds, + __const struct timespec *__timeout, + __const __sigset_t *__ss); +#endif + +__END_DECLS + +#endif /* sys/poll.h */ diff --git a/conts/posix/libposix/include/posix/sys/queue.h b/conts/posix/libposix/include/posix/sys/queue.h new file mode 100644 index 0000000..b0e6b38 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/queue.h @@ -0,0 +1,557 @@ +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)queue.h 8.5 (Berkeley) 8/20/94 + */ + +#ifndef _SYS_QUEUE_H_ +#define _SYS_QUEUE_H_ + +/* + * This file defines five types of data structures: singly-linked lists, + * lists, simple queues, tail queues, and circular queues. + * + * A singly-linked list is headed by a single forward pointer. The + * elements are singly linked for minimum space and pointer manipulation + * overhead at the expense of O(n) removal for arbitrary elements. New + * elements can be added to the list after an existing element or at the + * head of the list. Elements being removed from the head of the list + * should use the explicit macro for this purpose for optimum + * efficiency. A singly-linked list may only be traversed in the forward + * direction. Singly-linked lists are ideal for applications with large + * datasets and few or no removals or for implementing a LIFO queue. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before + * or after an existing element or at the head of the list. A list + * may only be traversed in the forward direction. + * + * A simple queue is headed by a pair of pointers, one the head of the + * list and the other to the tail of the list. The elements are singly + * linked to save space, so elements can only be removed from the + * head of the list. New elements can be added to the list after + * an existing element, at the head of the list, or at the end of the + * list. A simple queue may only be traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * A circle queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or after + * an existing element, at the head of the list, or at the end of the list. + * A circle queue may be traversed in either direction, but has a more + * complex end of list detection. + * + * For details on the use of these macros, see the queue(3) manual page. + */ + +/* + * List definitions. + */ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define LIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +/* + * List functions. + */ +#define LIST_INIT(head) do { \ + (head)->lh_first = NULL; \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_AFTER(listelm, elm, field) do { \ + if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ + (listelm)->field.le_next->field.le_prev = \ + &(elm)->field.le_next; \ + (listelm)->field.le_next = (elm); \ + (elm)->field.le_prev = &(listelm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + (elm)->field.le_next = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &(elm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.le_next = (head)->lh_first) != NULL) \ + (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ + (head)->lh_first = (elm); \ + (elm)->field.le_prev = &(head)->lh_first; \ +} while (/*CONSTCOND*/0) + +#define LIST_REMOVE(elm, field) do { \ + if ((elm)->field.le_next != NULL) \ + (elm)->field.le_next->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = (elm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define LIST_FOREACH(var, head, field) \ + for ((var) = ((head)->lh_first); \ + (var); \ + (var) = ((var)->field.le_next)) + +/* + * List access methods. + */ +#define LIST_EMPTY(head) ((head)->lh_first == NULL) +#define LIST_FIRST(head) ((head)->lh_first) +#define LIST_NEXT(elm, field) ((elm)->field.le_next) + + +/* + * Singly-linked List definitions. + */ +#define SLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} + +#define SLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define SLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} + +/* + * Singly-linked List functions. + */ +#define SLIST_INIT(head) do { \ + (head)->slh_first = NULL; \ +} while (/*CONSTCOND*/0) + +#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ + (elm)->field.sle_next = (slistelm)->field.sle_next; \ + (slistelm)->field.sle_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define SLIST_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.sle_next = (head)->slh_first; \ + (head)->slh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define SLIST_REMOVE_HEAD(head, field) do { \ + (head)->slh_first = (head)->slh_first->field.sle_next; \ +} while (/*CONSTCOND*/0) + +#define SLIST_REMOVE(head, elm, type, field) do { \ + if ((head)->slh_first == (elm)) { \ + SLIST_REMOVE_HEAD((head), field); \ + } \ + else { \ + struct type *curelm = (head)->slh_first; \ + while(curelm->field.sle_next != (elm)) \ + curelm = curelm->field.sle_next; \ + curelm->field.sle_next = \ + curelm->field.sle_next->field.sle_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define SLIST_FOREACH(var, head, field) \ + for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) + +/* + * Singly-linked List access methods. + */ +#define SLIST_EMPTY(head) ((head)->slh_first == NULL) +#define SLIST_FIRST(head) ((head)->slh_first) +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) + + +/* + * Singly-linked Tail queue declarations. + */ +#define STAILQ_HEAD(name, type) \ +struct name { \ + struct type *stqh_first; /* first element */ \ + struct type **stqh_last; /* addr of last next element */ \ +} + +#define STAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).stqh_first } + +#define STAILQ_ENTRY(type) \ +struct { \ + struct type *stqe_next; /* next element */ \ +} + +/* + * Singly-linked Tail queue functions. + */ +#define STAILQ_INIT(head) do { \ + (head)->stqh_first = NULL; \ + (head)->stqh_last = &(head)->stqh_first; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ + (head)->stqh_last = &(elm)->field.stqe_next; \ + (head)->stqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.stqe_next = NULL; \ + *(head)->stqh_last = (elm); \ + (head)->stqh_last = &(elm)->field.stqe_next; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\ + (head)->stqh_last = &(elm)->field.stqe_next; \ + (listelm)->field.stqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define STAILQ_REMOVE_HEAD(head, field) do { \ + if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \ + (head)->stqh_last = &(head)->stqh_first; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_REMOVE(head, elm, type, field) do { \ + if ((head)->stqh_first == (elm)) { \ + STAILQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->stqh_first; \ + while (curelm->field.stqe_next != (elm)) \ + curelm = curelm->field.stqe_next; \ + if ((curelm->field.stqe_next = \ + curelm->field.stqe_next->field.stqe_next) == NULL) \ + (head)->stqh_last = &(curelm)->field.stqe_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define STAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->stqh_first); \ + (var); \ + (var) = ((var)->field.stqe_next)) + +/* + * Singly-linked Tail queue access methods. + */ +#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) +#define STAILQ_FIRST(head) ((head)->stqh_first) +#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) + + +/* + * Simple queue definitions. + */ +#define SIMPLEQ_HEAD(name, type) \ +struct name { \ + struct type *sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ +} + +#define SIMPLEQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).sqh_first } + +#define SIMPLEQ_ENTRY(type) \ +struct { \ + struct type *sqe_next; /* next element */ \ +} + +/* + * Simple queue functions. + */ +#define SIMPLEQ_INIT(head) do { \ + (head)->sqh_first = NULL; \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (head)->sqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.sqe_next = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (listelm)->field.sqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_REMOVE_HEAD(head, field) do { \ + if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_REMOVE(head, elm, type, field) do { \ + if ((head)->sqh_first == (elm)) { \ + SIMPLEQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->sqh_first; \ + while (curelm->field.sqe_next != (elm)) \ + curelm = curelm->field.sqe_next; \ + if ((curelm->field.sqe_next = \ + curelm->field.sqe_next->field.sqe_next) == NULL) \ + (head)->sqh_last = &(curelm)->field.sqe_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_FOREACH(var, head, field) \ + for ((var) = ((head)->sqh_first); \ + (var); \ + (var) = ((var)->field.sqe_next)) + +/* + * Simple queue access methods. + */ +#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) +#define SIMPLEQ_FIRST(head) ((head)->sqh_first) +#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) + + +/* + * Tail queue definitions. + */ +#define _TAILQ_HEAD(name, type, qual) \ +struct name { \ + qual type *tqh_first; /* first element */ \ + qual type *qual *tqh_last; /* addr of last next element */ \ +} +#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,) + +#define TAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).tqh_first } + +#define _TAILQ_ENTRY(type, qual) \ +struct { \ + qual type *tqe_next; /* next element */ \ + qual type *qual *tqe_prev; /* address of previous next element */\ +} +#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,) + +/* + * Tail queue functions. + */ +#define TAILQ_INIT(head) do { \ + (head)->tqh_first = NULL; \ + (head)->tqh_last = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ + (head)->tqh_first->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_first = (elm); \ + (elm)->field.tqe_prev = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.tqe_next = NULL; \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ + (elm)->field.tqe_next->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (listelm)->field.tqe_next = (elm); \ + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + (elm)->field.tqe_next = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_REMOVE(head, elm, field) do { \ + if (((elm)->field.tqe_next) != NULL) \ + (elm)->field.tqe_next->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->tqh_first); \ + (var); \ + (var) = ((var)->field.tqe_next)) + +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ + (var); \ + (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) + +/* + * Tail queue access methods. + */ +#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) +#define TAILQ_FIRST(head) ((head)->tqh_first) +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) + +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) + + +/* + * Circular queue definitions. + */ +#define CIRCLEQ_HEAD(name, type) \ +struct name { \ + struct type *cqh_first; /* first element */ \ + struct type *cqh_last; /* last element */ \ +} + +#define CIRCLEQ_HEAD_INITIALIZER(head) \ + { (void *)&head, (void *)&head } + +#define CIRCLEQ_ENTRY(type) \ +struct { \ + struct type *cqe_next; /* next element */ \ + struct type *cqe_prev; /* previous element */ \ +} + +/* + * Circular queue functions. + */ +#define CIRCLEQ_INIT(head) do { \ + (head)->cqh_first = (void *)(head); \ + (head)->cqh_last = (void *)(head); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + (elm)->field.cqe_next = (listelm)->field.cqe_next; \ + (elm)->field.cqe_prev = (listelm); \ + if ((listelm)->field.cqe_next == (void *)(head)) \ + (head)->cqh_last = (elm); \ + else \ + (listelm)->field.cqe_next->field.cqe_prev = (elm); \ + (listelm)->field.cqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ + (elm)->field.cqe_next = (listelm); \ + (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ + if ((listelm)->field.cqe_prev == (void *)(head)) \ + (head)->cqh_first = (elm); \ + else \ + (listelm)->field.cqe_prev->field.cqe_next = (elm); \ + (listelm)->field.cqe_prev = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.cqe_next = (head)->cqh_first; \ + (elm)->field.cqe_prev = (void *)(head); \ + if ((head)->cqh_last == (void *)(head)) \ + (head)->cqh_last = (elm); \ + else \ + (head)->cqh_first->field.cqe_prev = (elm); \ + (head)->cqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.cqe_next = (void *)(head); \ + (elm)->field.cqe_prev = (head)->cqh_last; \ + if ((head)->cqh_first == (void *)(head)) \ + (head)->cqh_first = (elm); \ + else \ + (head)->cqh_last->field.cqe_next = (elm); \ + (head)->cqh_last = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_REMOVE(head, elm, field) do { \ + if ((elm)->field.cqe_next == (void *)(head)) \ + (head)->cqh_last = (elm)->field.cqe_prev; \ + else \ + (elm)->field.cqe_next->field.cqe_prev = \ + (elm)->field.cqe_prev; \ + if ((elm)->field.cqe_prev == (void *)(head)) \ + (head)->cqh_first = (elm)->field.cqe_next; \ + else \ + (elm)->field.cqe_prev->field.cqe_next = \ + (elm)->field.cqe_next; \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_FOREACH(var, head, field) \ + for ((var) = ((head)->cqh_first); \ + (var) != (const void *)(head); \ + (var) = ((var)->field.cqe_next)) + +#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ + for ((var) = ((head)->cqh_last); \ + (var) != (const void *)(head); \ + (var) = ((var)->field.cqe_prev)) + +/* + * Circular queue access methods. + */ +#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head)) +#define CIRCLEQ_FIRST(head) ((head)->cqh_first) +#define CIRCLEQ_LAST(head) ((head)->cqh_last) +#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) +#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) + +#define CIRCLEQ_LOOP_NEXT(head, elm, field) \ + (((elm)->field.cqe_next == (void *)(head)) \ + ? ((head)->cqh_first) \ + : (elm->field.cqe_next)) +#define CIRCLEQ_LOOP_PREV(head, elm, field) \ + (((elm)->field.cqe_prev == (void *)(head)) \ + ? ((head)->cqh_last) \ + : (elm->field.cqe_prev)) + +#endif /* sys/queue.h */ diff --git a/conts/posix/libposix/include/posix/sys/quota.h b/conts/posix/libposix/include/posix/sys/quota.h new file mode 100644 index 0000000..a6afdbe --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/quota.h @@ -0,0 +1,158 @@ +/* This just represents the non-kernel parts of . + * + * here's the corresponding copyright: + * Copyright (c) 1982, 1986 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Robert Elz at The University of Melbourne. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Version: $Id: quota.h,v 1.1 2002/01/03 04:00:09 andersen Exp $ + */ + +#ifndef _SYS_QUOTA_H +#define _SYS_QUOTA_H 1 + +#include +#include + +/* + * Convert diskblocks to blocks and the other way around. + * currently only to fool the BSD source. :-) + */ +#define dbtob(num) ((num) << 10) +#define btodb(num) ((num) >> 10) + +/* + * Convert count of filesystem blocks to diskquota blocks, meant + * for filesystems where i_blksize != BLOCK_SIZE + */ +#define fs_to_dq_blocks(num, blksize) (((num) * (blksize)) / BLOCK_SIZE) + +/* + * Definitions for disk quotas imposed on the average user + * (big brother finally hits Linux). + * + * The following constants define the amount of time given a user + * before the soft limits are treated as hard limits (usually resulting + * in an allocation failure). The timer is started when the user crosses + * their soft limit, it is reset when they go below their soft limit. + */ +#define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */ +#define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */ + +#define MAXQUOTAS 2 +#define USRQUOTA 0 /* element used for user quotas */ +#define GRPQUOTA 1 /* element used for group quotas */ + +/* + * Definitions for the default names of the quotas files. + */ +#define INITQFNAMES { \ + "user", /* USRQUOTA */ \ + "group", /* GRPQUOTA */ \ + "undefined", \ +}; + +#define QUOTAFILENAME "quota" +#define QUOTAGROUP "staff" + +#define NR_DQHASH 43 /* Just an arbitrary number any suggestions ? */ +#define NR_DQUOTS 256 /* Number of quotas active at one time */ + +/* + * Command definitions for the 'quotactl' system call. + * The commands are broken into a main command defined below + * and a subcommand that is used to convey the type of + * quota that is being manipulated (see above). + */ +#define SUBCMDMASK 0x00ff +#define SUBCMDSHIFT 8 +#define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK)) + +#define Q_QUOTAON 0x0100 /* enable quotas */ +#define Q_QUOTAOFF 0x0200 /* disable quotas */ +#define Q_GETQUOTA 0x0300 /* get limits and usage */ +#define Q_SETQUOTA 0x0400 /* set limits and usage */ +#define Q_SETUSE 0x0500 /* set usage */ +#define Q_SYNC 0x0600 /* sync disk copy of a filesystems quotas */ +#define Q_SETQLIM 0x0700 /* set limits */ +#define Q_GETSTATS 0x0800 /* get collected stats */ +#define Q_RSQUASH 0x1000 /* set root_squash option */ + +/* + * The following structure defines the format of the disk quota file + * (as it appears on disk) - the file is an array of these structures + * indexed by user or group number. + */ +struct dqblk + { + u_int32_t dqb_bhardlimit; /* absolute limit on disk blks alloc */ + u_int32_t dqb_bsoftlimit; /* preferred limit on disk blks */ + u_int32_t dqb_curblocks; /* current block count */ + u_int32_t dqb_ihardlimit; /* maximum # allocated inodes */ + u_int32_t dqb_isoftlimit; /* preferred inode limit */ + u_int32_t dqb_curinodes; /* current # allocated inodes */ + time_t dqb_btime; /* time limit for excessive disk use */ + time_t dqb_itime; /* time limit for excessive files */ + }; + +/* + * Shorthand notation. + */ +#define dq_bhardlimit dq_dqb.dqb_bhardlimit +#define dq_bsoftlimit dq_dqb.dqb_bsoftlimit +#define dq_curblocks dq_dqb.dqb_curblocks +#define dq_ihardlimit dq_dqb.dqb_ihardlimit +#define dq_isoftlimit dq_dqb.dqb_isoftlimit +#define dq_curinodes dq_dqb.dqb_curinodes +#define dq_btime dq_dqb.dqb_btime +#define dq_itime dq_dqb.dqb_itime + +#define dqoff(UID) ((loff_t)((UID) * sizeof (struct dqblk))) + +struct dqstats + { + u_int32_t lookups; + u_int32_t drops; + u_int32_t reads; + u_int32_t writes; + u_int32_t cache_hits; + u_int32_t pages_allocated; + u_int32_t allocated_dquots; + u_int32_t free_dquots; + u_int32_t syncs; + }; + +__BEGIN_DECLS + +extern int quotactl (int __cmd, const char *__special, int __id, + caddr_t __addr) __THROW; + +__END_DECLS + +#endif /* sys/quota.h */ diff --git a/conts/posix/libposix/include/posix/sys/reboot.h b/conts/posix/libposix/include/posix/sys/reboot.h new file mode 100644 index 0000000..2a719c7 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/reboot.h @@ -0,0 +1,49 @@ +/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This file should define RB_* macros to be used as flag + bits in the argument to the `reboot' system call. */ + +#ifndef _SYS_REBOOT_H +#define _SYS_REBOOT_H 1 + +#include + +/* Perform a hard reset now. */ +#define RB_AUTOBOOT 0x01234567 + +/* Halt the system. */ +#define RB_HALT_SYSTEM 0xcdef0123 + +/* Enable reboot using Ctrl-Alt-Delete keystroke. */ +#define RB_ENABLE_CAD 0x89abcdef + +/* Disable reboot using Ctrl-Alt-Delete keystroke. */ +#define RB_DISABLE_CAD 0 + +/* Stop system and switch power off if possible. */ +#define RB_POWER_OFF 0x4321fedc + +__BEGIN_DECLS + +/* Reboot or halt the system. */ +extern int reboot (int __howto) __THROW; + +__END_DECLS + +#endif /* _SYS_REBOOT_H */ diff --git a/conts/posix/libposix/include/posix/sys/resource.h b/conts/posix/libposix/include/posix/sys/resource.h new file mode 100644 index 0000000..3912741 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/resource.h @@ -0,0 +1,103 @@ +/* Copyright (C) 1992,94,1996-2000,2002,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_RESOURCE_H +#define _SYS_RESOURCE_H 1 + +#include + +/* Get the system-dependent definitions of structures and bit values. */ +#include + +#ifndef __id_t_defined +typedef __id_t id_t; +# define __id_t_defined +#endif + +__BEGIN_DECLS + +/* The X/Open standard defines that all the functions below must use + `int' as the type for the first argument. When we are compiling with + GNU extensions we change this slightly to provide better error + checking. */ +#if defined __USE_GNU && !defined __cplusplus +typedef enum __rlimit_resource __rlimit_resource_t; +typedef enum __rusage_who __rusage_who_t; +typedef enum __priority_which __priority_which_t; +#else +typedef int __rlimit_resource_t; +typedef int __rusage_who_t; +typedef int __priority_which_t; +#endif + +/* Put the soft and hard limits for RESOURCE in *RLIMITS. + Returns 0 if successful, -1 if not (and sets errno). */ +#ifndef __USE_FILE_OFFSET64 +extern int getrlimit (__rlimit_resource_t __resource, + struct rlimit *__rlimits) __THROW; +#else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (getrlimit, (__rlimit_resource_t __resource, + struct rlimit *__rlimits), getrlimit64); +# else +# define getrlimit getrlimit64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern int getrlimit64 (__rlimit_resource_t __resource, + struct rlimit64 *__rlimits) __THROW; +#endif + +/* Set the soft and hard limits for RESOURCE to *RLIMITS. + Only the super-user can increase hard limits. + Return 0 if successful, -1 if not (and sets errno). */ +#ifndef __USE_FILE_OFFSET64 +extern int setrlimit (__rlimit_resource_t __resource, + __const struct rlimit *__rlimits) __THROW; +#else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (setrlimit, (__rlimit_resource_t __resource, + __const struct rlimit *__rlimits), + setrlimit64); +# else +# define setrlimit setrlimit64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern int setrlimit64 (__rlimit_resource_t __resource, + __const struct rlimit64 *__rlimits) __THROW; +#endif + +/* Return resource usage information on process indicated by WHO + and put it in *USAGE. Returns 0 for success, -1 for failure. */ +extern int getrusage (__rusage_who_t __who, struct rusage *__usage) __THROW; + +/* Return the highest priority of any process specified by WHICH and WHO + (see above); if WHO is zero, the current process, process group, or user + (as specified by WHO) is used. A lower priority number means higher + priority. Priorities range from PRIO_MIN to PRIO_MAX (above). */ +extern int getpriority (__priority_which_t __which, id_t __who) __THROW; + +/* Set the priority of all processes specified by WHICH and WHO (see above) + to PRIO. Returns 0 on success, -1 on errors. */ +extern int setpriority (__priority_which_t __which, id_t __who, int __prio) + __THROW; + +__END_DECLS + +#endif /* sys/resource.h */ diff --git a/conts/posix/libposix/include/posix/sys/select.h b/conts/posix/libposix/include/posix/sys/select.h new file mode 100644 index 0000000..2a40843 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/select.h @@ -0,0 +1,130 @@ +/* `fd_set' type and related macros, and `select'/`pselect' declarations. + Copyright (C) 1996,97,98,99,2000,01,02,2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* POSIX 1003.1g: 6.2 Select from File Descriptor Sets */ + +#ifndef _SYS_SELECT_H +#define _SYS_SELECT_H 1 + +#include + +/* Get definition of needed basic types. */ +#include + +/* Get __FD_* definitions. */ +#include + +/* Get __sigset_t. */ +#include + +#ifndef __sigset_t_defined +# define __sigset_t_defined +typedef __sigset_t sigset_t; +#endif + +/* Get definition of timer specification structures. */ +#define __need_time_t +#define __need_timespec +#include +#define __need_timeval +#include + +#ifndef __suseconds_t_defined +typedef __suseconds_t suseconds_t; +# define __suseconds_t_defined +#endif + + +/* The fd_set member is required to be an array of longs. */ +typedef long int __fd_mask; + +/* Some versions of define these macros. */ +#undef __NFDBITS +#undef __FDELT +#undef __FDMASK +/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */ +#define __NFDBITS (8 * sizeof (__fd_mask)) +#define __FDELT(d) ((d) / __NFDBITS) +#define __FDMASK(d) ((__fd_mask) 1 << ((d) % __NFDBITS)) + +/* fd_set for select and pselect. */ +typedef struct + { + /* XPG4.2 requires this member name. Otherwise avoid the name + from the global namespace. */ +#ifdef __USE_XOPEN + __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS]; +# define __FDS_BITS(set) ((set)->fds_bits) +#else + __fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS]; +# define __FDS_BITS(set) ((set)->__fds_bits) +#endif + } fd_set; + +/* Maximum number of file descriptors in `fd_set'. */ +#define FD_SETSIZE __FD_SETSIZE + +#ifdef __USE_MISC +/* Sometimes the fd_set member is assumed to have this type. */ +typedef __fd_mask fd_mask; + +/* Number of bits per word of `fd_set' (some code assumes this is 32). */ +# define NFDBITS __NFDBITS +#endif + + +/* Access macros for `fd_set'. */ +#define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp) +#define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp) +#define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp) +#define FD_ZERO(fdsetp) __FD_ZERO (fdsetp) + + +__BEGIN_DECLS + +/* Check the first NFDS descriptors each in READFDS (if not NULL) for read + readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS + (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out + after waiting the interval specified therein. Returns the number of ready + descriptors, or -1 for errors. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int select (int __nfds, fd_set *__restrict __readfds, + fd_set *__restrict __writefds, + fd_set *__restrict __exceptfds, + struct timeval *__restrict __timeout); + +#ifdef __USE_XOPEN2K +/* Same as above only that the TIMEOUT value is given with higher + resolution and a sigmask which is been set temporarily. This version + should be used. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int pselect (int __nfds, fd_set *__restrict __readfds, + fd_set *__restrict __writefds, + fd_set *__restrict __exceptfds, + const struct timespec *__restrict __timeout, + const __sigset_t *__restrict __sigmask); +#endif + +__END_DECLS + +#endif /* sys/select.h */ diff --git a/conts/posix/libposix/include/posix/sys/sem.h b/conts/posix/libposix/include/posix/sys/sem.h new file mode 100644 index 0000000..5b1d38f --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/sem.h @@ -0,0 +1,58 @@ +/* Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_SEM_H +#define _SYS_SEM_H 1 + +#include + +#define __need_size_t +#include + +/* Get common definition of System V style IPC. */ +#include + +/* Get system dependent definition of `struct semid_ds' and more. */ +#include + +/* The following System V style IPC functions implement a semaphore + handling. The definition is found in XPG2. */ + +/* Structure used for argument to `semop' to describe operations. */ +struct sembuf +{ + unsigned short int sem_num; /* semaphore number */ + short int sem_op; /* semaphore operation */ + short int sem_flg; /* operation flag */ +}; + + +__BEGIN_DECLS + +/* Semaphore control operation. */ +extern int semctl (int __semid, int __semnum, int __cmd, ...) __THROW; + +/* Get semaphore. */ +extern int semget (key_t __key, int __nsems, int __semflg) __THROW; + +/* Operate on semaphore. */ +extern int semop (int __semid, struct sembuf *__sops, size_t __nsops) __THROW; + +__END_DECLS + +#endif /* sys/sem.h */ diff --git a/conts/posix/libposix/include/posix/sys/sendfile.h b/conts/posix/libposix/include/posix/sys/sendfile.h new file mode 100644 index 0000000..4c1367b --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/sendfile.h @@ -0,0 +1,52 @@ +/* sendfile -- copy data directly from one file descriptor to another + Copyright (C) 1998,99,01,2002,2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_SENDFILE_H +#define _SYS_SENDFILE_H 1 + +#include +#include + +__BEGIN_DECLS + +/* Send up to COUNT bytes from file associated with IN_FD starting at + *OFFSET to descriptor OUT_FD. Set *OFFSET to the IN_FD's file position + following the read bytes. If OFFSET is a null pointer, use the normal + file position instead. Return the number of written bytes, or -1 in + case of error. */ +#ifndef __USE_FILE_OFFSET64 +extern ssize_t sendfile (int __out_fd, int __in_fd, off_t *__offset, + size_t __count) __THROW; +#else +# ifdef __REDIRECT_NTH +extern ssize_t __REDIRECT_NTH (sendfile, + (int __out_fd, int __in_fd, __off64_t *__offset, + size_t __count), sendfile64); +# else +# define sendfile sendfile64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern ssize_t sendfile64 (int __out_fd, int __in_fd, __off64_t *__offset, + size_t __count) __THROW; +#endif + +__END_DECLS + +#endif /* sys/sendfile.h */ diff --git a/conts/posix/libposix/include/posix/sys/shm.h b/conts/posix/libposix/include/posix/sys/shm.h new file mode 100644 index 0000000..8ec30b4 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/shm.h @@ -0,0 +1,64 @@ +/* Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_SHM_H +#define _SYS_SHM_H 1 + +#include + +#define __need_size_t +#include + +/* Get common definition of System V style IPC. */ +#include + +/* Get system dependent definition of `struct shmid_ds' and more. */ +#include + +/* Define types required by the standard. */ +#define __need_time_t +#include + +#ifdef __USE_XOPEN +# ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +# endif +#endif /* X/Open */ + +__BEGIN_DECLS + +/* The following System V style IPC functions implement a shared memory + facility. The definition is found in XPG4.2. */ + +/* Shared memory control operation. */ +extern int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf) __THROW; + +/* Get shared memory segment. */ +extern int shmget (key_t __key, size_t __size, int __shmflg) __THROW; + +/* Attach shared memory segment. */ +extern void *shmat (int __shmid, __const void *__shmaddr, int __shmflg) + __THROW; + +/* Detach shared memory segment. */ +extern int shmdt (__const void *__shmaddr) __THROW; + +__END_DECLS + +#endif /* sys/shm.h */ diff --git a/conts/posix/libposix/include/posix/sys/signal.h b/conts/posix/libposix/include/posix/sys/signal.h new file mode 100644 index 0000000..2e602da --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/signal.h @@ -0,0 +1 @@ +#include diff --git a/conts/posix/libposix/include/posix/sys/socket.h b/conts/posix/libposix/include/posix/sys/socket.h new file mode 100644 index 0000000..4ae1ea9 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/socket.h @@ -0,0 +1,236 @@ +/* Declarations of socket constants, types, and functions. + Copyright (C) 1991,92,1994-2001,2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_SOCKET_H +#define _SYS_SOCKET_H 1 + +#include + +__BEGIN_DECLS + +#include +#define __need_size_t +#include + + +/* This operating system-specific header file defines the SOCK_*, PF_*, + AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr', + `struct msghdr', and `struct linger' types. */ +#include + +#ifdef __USE_BSD +/* This is the 4.3 BSD `struct sockaddr' format, which is used as wire + format in the grotty old 4.3 `talk' protocol. */ +struct osockaddr + { + unsigned short int sa_family; + unsigned char sa_data[14]; + }; +#endif + +/* The following constants should be used for the second parameter of + `shutdown'. */ +enum +{ + SHUT_RD = 0, /* No more receptions. */ +#define SHUT_RD SHUT_RD + SHUT_WR, /* No more transmissions. */ +#define SHUT_WR SHUT_WR + SHUT_RDWR /* No more receptions or transmissions. */ +#define SHUT_RDWR SHUT_RDWR +}; + +/* This is the type we use for generic socket address arguments. + + With GCC 2.7 and later, the funky union causes redeclarations or + uses with any of the listed types to be allowed without complaint. + G++ 2.7 does not support transparent unions so there we want the + old-style declaration, too. */ +#if defined __cplusplus || !__GNUC_PREREQ (2, 7) || !defined __USE_GNU +# define __SOCKADDR_ARG struct sockaddr *__restrict +# define __CONST_SOCKADDR_ARG __const struct sockaddr * +#else +/* Add more `struct sockaddr_AF' types here as necessary. + These are all the ones I found on NetBSD and Linux. */ +# define __SOCKADDR_ALLTYPES \ + __SOCKADDR_ONETYPE (sockaddr) \ + __SOCKADDR_ONETYPE (sockaddr_at) \ + __SOCKADDR_ONETYPE (sockaddr_ax25) \ + __SOCKADDR_ONETYPE (sockaddr_dl) \ + __SOCKADDR_ONETYPE (sockaddr_eon) \ + __SOCKADDR_ONETYPE (sockaddr_in) \ + __SOCKADDR_ONETYPE (sockaddr_in6) \ + __SOCKADDR_ONETYPE (sockaddr_inarp) \ + __SOCKADDR_ONETYPE (sockaddr_ipx) \ + __SOCKADDR_ONETYPE (sockaddr_iso) \ + __SOCKADDR_ONETYPE (sockaddr_ns) \ + __SOCKADDR_ONETYPE (sockaddr_un) \ + __SOCKADDR_ONETYPE (sockaddr_x25) + +# define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__; +typedef union { __SOCKADDR_ALLTYPES + } __SOCKADDR_ARG __attribute__ ((__transparent_union__)); +# undef __SOCKADDR_ONETYPE +# define __SOCKADDR_ONETYPE(type) __const struct type *__restrict __##type##__; +typedef union { __SOCKADDR_ALLTYPES + } __CONST_SOCKADDR_ARG __attribute__ ((__transparent_union__)); +# undef __SOCKADDR_ONETYPE +#endif + + +/* Create a new socket of type TYPE in domain DOMAIN, using + protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically. + Returns a file descriptor for the new socket, or -1 for errors. */ +extern int socket (int __domain, int __type, int __protocol) __THROW; + +/* Create two new sockets, of type TYPE in domain DOMAIN and using + protocol PROTOCOL, which are connected to each other, and put file + descriptors for them in FDS[0] and FDS[1]. If PROTOCOL is zero, + one will be chosen automatically. Returns 0 on success, -1 for errors. */ +extern int socketpair (int __domain, int __type, int __protocol, + int __fds[2]) __THROW; + +/* Give the socket FD the local address ADDR (which is LEN bytes long). */ +extern int bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len) + __THROW; + +/* Put the local address of FD into *ADDR and its length in *LEN. */ +extern int getsockname (int __fd, __SOCKADDR_ARG __addr, + socklen_t *__restrict __len) __THROW; + +/* Open a connection on socket FD to peer at ADDR (which LEN bytes long). + For connectionless socket types, just set the default address to send to + and the only address from which to accept transmissions. + Return 0 on success, -1 for errors. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len); + +/* Put the address of the peer connected to socket FD into *ADDR + (which is *LEN bytes long), and its actual length into *LEN. */ +extern int getpeername (int __fd, __SOCKADDR_ARG __addr, + socklen_t *__restrict __len) __THROW; + + +/* Send N bytes of BUF to socket FD. Returns the number sent or -1. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t send (int __fd, __const void *__buf, size_t __n, int __flags); + +/* Read N bytes into BUF from socket FD. + Returns the number read or -1 for errors. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags); + +/* Send N bytes of BUF on socket FD to peer at address ADDR (which is + ADDR_LEN bytes long). Returns the number sent, or -1 for errors. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t sendto (int __fd, __const void *__buf, size_t __n, + int __flags, __CONST_SOCKADDR_ARG __addr, + socklen_t __addr_len); + +/* Read N bytes into BUF through socket FD. + If ADDR is not NULL, fill in *ADDR_LEN bytes of it with tha address of + the sender, and store the actual size of the address in *ADDR_LEN. + Returns the number of bytes read or -1 for errors. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t recvfrom (int __fd, void *__restrict __buf, size_t __n, + int __flags, __SOCKADDR_ARG __addr, + socklen_t *__restrict __addr_len); + + +/* Send a message described MESSAGE on socket FD. + Returns the number of bytes sent, or -1 for errors. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t sendmsg (int __fd, __const struct msghdr *__message, + int __flags); + +/* Receive a message as described by MESSAGE from socket FD. + Returns the number of bytes read or -1 for errors. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t recvmsg (int __fd, struct msghdr *__message, int __flags); + + +/* Put the current value for socket FD's option OPTNAME at protocol level LEVEL + into OPTVAL (which is *OPTLEN bytes long), and set *OPTLEN to the value's + actual length. Returns 0 on success, -1 for errors. */ +extern int getsockopt (int __fd, int __level, int __optname, + void *__restrict __optval, + socklen_t *__restrict __optlen) __THROW; + +/* Set socket FD's option OPTNAME at protocol level LEVEL + to *OPTVAL (which is OPTLEN bytes long). + Returns 0 on success, -1 for errors. */ +extern int setsockopt (int __fd, int __level, int __optname, + __const void *__optval, socklen_t __optlen) __THROW; + + +/* Prepare to accept connections on socket FD. + N connection requests will be queued before further requests are refused. + Returns 0 on success, -1 for errors. */ +extern int listen (int __fd, int __n) __THROW; + +/* Await a connection on socket FD. + When a connection arrives, open a new socket to communicate with it, + set *ADDR (which is *ADDR_LEN bytes long) to the address of the connecting + peer and *ADDR_LEN to the address's actual length, and return the + new socket's descriptor, or -1 for errors. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int accept (int __fd, __SOCKADDR_ARG __addr, + socklen_t *__restrict __addr_len); + +/* Shut down all or part of the connection open on socket FD. + HOW determines what to shut down: + SHUT_RD = No more receptions; + SHUT_WR = No more transmissions; + SHUT_RDWR = No more receptions or transmissions. + Returns 0 on success, -1 for errors. */ +extern int shutdown (int __fd, int __how) __THROW; + + +#ifdef __USE_XOPEN2K +/* Determine wheter socket is at a out-of-band mark. */ +extern int sockatmark (int __fd) __THROW; +#endif + + +#ifdef __USE_MISC +/* FDTYPE is S_IFSOCK or another S_IF* macro defined in ; + returns 1 if FD is open on an object of the indicated type, 0 if not, + or -1 for errors (setting errno). */ +extern int isfdtype (int __fd, int __fdtype) __THROW; +#endif + +__END_DECLS + +#endif /* sys/socket.h */ diff --git a/conts/posix/libposix/include/posix/sys/socketvar.h b/conts/posix/libposix/include/posix/sys/socketvar.h new file mode 100644 index 0000000..b177158 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/socketvar.h @@ -0,0 +1,3 @@ +/* This header is used on many systems but for GNU we have everything + already defined in the standard header. */ +#include diff --git a/conts/posix/libposix/include/posix/sys/soundcard.h b/conts/posix/libposix/include/posix/sys/soundcard.h new file mode 100644 index 0000000..fade986 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/soundcard.h @@ -0,0 +1 @@ +#include diff --git a/conts/posix/libposix/include/posix/sys/stat.h b/conts/posix/libposix/include/posix/sys/stat.h new file mode 100644 index 0000000..5082390 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/stat.h @@ -0,0 +1,366 @@ +/* Copyright (C) 1991,1992,1995-2004,2005,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * POSIX Standard: 5.6 File Characteristics + */ + +#ifndef _SYS_STAT_H +#define _SYS_STAT_H 1 + +#include + +#include /* For __mode_t and __dev_t. */ + +#if defined __USE_XOPEN || defined __USE_MISC +# if defined __USE_XOPEN || defined __USE_XOPEN2K +# define __need_time_t +# endif +# ifdef __USE_MISC +# define __need_timespec +# endif +# include /* For time_t resp. timespec. */ +#endif + +#if defined __USE_XOPEN || defined __USE_XOPEN2K +/* The Single Unix specification says that some more types are + available here. */ +# ifndef __dev_t_defined +typedef __dev_t dev_t; +# define __dev_t_defined +# endif + +# ifndef __gid_t_defined +typedef __gid_t gid_t; +# define __gid_t_defined +# endif + +# ifndef __ino_t_defined +# ifndef __USE_FILE_OFFSET64 +typedef __ino_t ino_t; +# else +typedef __ino64_t ino_t; +# endif +# define __ino_t_defined +# endif + +# ifndef __mode_t_defined +typedef __mode_t mode_t; +# define __mode_t_defined +# endif + +# ifndef __nlink_t_defined +typedef __nlink_t nlink_t; +# define __nlink_t_defined +# endif + +# ifndef __off_t_defined +# ifndef __USE_FILE_OFFSET64 +typedef __off_t off_t; +# else +typedef __off64_t off_t; +# endif +# define __off_t_defined +# endif + +# ifndef __uid_t_defined +typedef __uid_t uid_t; +# define __uid_t_defined +# endif +#endif /* X/Open */ + +#ifdef __USE_UNIX98 +# ifndef __blkcnt_t_defined +# ifndef __USE_FILE_OFFSET64 +typedef __blkcnt_t blkcnt_t; +# else +typedef __blkcnt64_t blkcnt_t; +# endif +# define __blkcnt_t_defined +# endif + +# ifndef __blksize_t_defined +typedef __blksize_t blksize_t; +# define __blksize_t_defined +# endif +#endif /* Unix98 */ + +__BEGIN_DECLS + +#include + +#if defined __USE_BSD || defined __USE_MISC || defined __USE_XOPEN +# define S_IFMT __S_IFMT +# define S_IFDIR __S_IFDIR +# define S_IFCHR __S_IFCHR +# define S_IFBLK __S_IFBLK +# define S_IFREG __S_IFREG +# ifdef __S_IFIFO +# define S_IFIFO __S_IFIFO +# endif +# ifdef __S_IFLNK +# define S_IFLNK __S_IFLNK +# endif +# if (defined __USE_BSD || defined __USE_MISC || defined __USE_UNIX98) \ + && defined __S_IFSOCK +# define S_IFSOCK __S_IFSOCK +# endif +#endif + +/* Test macros for file types. */ + +#define __S_ISTYPE(mode, mask) (((mode) & __S_IFMT) == (mask)) + +#define S_ISDIR(mode) __S_ISTYPE((mode), __S_IFDIR) +#define S_ISCHR(mode) __S_ISTYPE((mode), __S_IFCHR) +#define S_ISBLK(mode) __S_ISTYPE((mode), __S_IFBLK) +#define S_ISREG(mode) __S_ISTYPE((mode), __S_IFREG) +#ifdef __S_IFIFO +# define S_ISFIFO(mode) __S_ISTYPE((mode), __S_IFIFO) +#endif +#ifdef __S_IFLNK +# define S_ISLNK(mode) __S_ISTYPE((mode), __S_IFLNK) +#endif + +#if defined __USE_BSD && !defined __S_IFLNK +# define S_ISLNK(mode) 0 +#endif + +#if (defined __USE_BSD || defined __USE_UNIX98) \ + && defined __S_IFSOCK +# define S_ISSOCK(mode) __S_ISTYPE((mode), __S_IFSOCK) +#endif + +/* These are from POSIX.1b. If the objects are not implemented using separate + distinct file types, the macros always will evaluate to zero. Unlike the + other S_* macros the following three take a pointer to a `struct stat' + object as the argument. */ +#ifdef __USE_POSIX199309 +# define S_TYPEISMQ(buf) __S_TYPEISMQ(buf) +# define S_TYPEISSEM(buf) __S_TYPEISSEM(buf) +# define S_TYPEISSHM(buf) __S_TYPEISSHM(buf) +#endif + + +/* Protection bits. */ + +#define S_ISUID __S_ISUID /* Set user ID on execution. */ +#define S_ISGID __S_ISGID /* Set group ID on execution. */ + +#if defined __USE_BSD || defined __USE_MISC || defined __USE_XOPEN +/* Save swapped text after use (sticky bit). This is pretty well obsolete. */ +# define S_ISVTX __S_ISVTX +#endif + +#define S_IRUSR __S_IREAD /* Read by owner. */ +#define S_IWUSR __S_IWRITE /* Write by owner. */ +#define S_IXUSR __S_IEXEC /* Execute by owner. */ +/* Read, write, and execute by owner. */ +#define S_IRWXU (__S_IREAD|__S_IWRITE|__S_IEXEC) + +#if defined __USE_MISC && defined __USE_BSD +# define S_IREAD S_IRUSR +# define S_IWRITE S_IWUSR +# define S_IEXEC S_IXUSR +#endif + +#define S_IRGRP (S_IRUSR >> 3) /* Read by group. */ +#define S_IWGRP (S_IWUSR >> 3) /* Write by group. */ +#define S_IXGRP (S_IXUSR >> 3) /* Execute by group. */ +/* Read, write, and execute by group. */ +#define S_IRWXG (S_IRWXU >> 3) + +#define S_IROTH (S_IRGRP >> 3) /* Read by others. */ +#define S_IWOTH (S_IWGRP >> 3) /* Write by others. */ +#define S_IXOTH (S_IXGRP >> 3) /* Execute by others. */ +/* Read, write, and execute by others. */ +#define S_IRWXO (S_IRWXG >> 3) + + +#ifdef __USE_BSD +/* Macros for common mode bit masks. */ +# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */ +# define ALLPERMS (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)/* 07777 */ +# define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)/* 0666*/ + +# define S_BLKSIZE 512 /* Block size for `st_blocks'. */ +#endif + + +#ifndef __USE_FILE_OFFSET64 +/* Get file attributes for FILE and put them in BUF. */ +extern int stat (__const char *__restrict __file, + struct stat *__restrict __buf) __THROW __nonnull ((1, 2)); + +/* Get file attributes for the file, device, pipe, or socket + that file descriptor FD is open on and put them in BUF. */ +extern int fstat (int __fd, struct stat *__buf) __THROW __nonnull ((2)); +#else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (stat, (__const char *__restrict __file, + struct stat *__restrict __buf), stat64) + __nonnull ((1, 2)); +extern int __REDIRECT_NTH (fstat, (int __fd, struct stat *__buf), fstat64) + __nonnull ((2)); +# else +# define stat stat64 +# define fstat fstat64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern int stat64 (__const char *__restrict __file, + struct stat64 *__restrict __buf) __THROW __nonnull ((1, 2)); +extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2)); +#endif + +#ifdef __USE_ATFILE +/* Similar to stat, get the attributes for FILE and put them in BUF. + Relative path names are interpreted relative to FD unless FD is + AT_FDCWD. */ +# ifndef __USE_FILE_OFFSET64 +extern int fstatat (int __fd, __const char *__restrict __file, + struct stat *__restrict __buf, int __flag) + __THROW __nonnull ((2, 3)); +# else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (fstatat, (int __fd, __const char *__restrict __file, + struct stat *__restrict __buf, + int __flag), + fstatat64) __nonnull ((2, 3)); +# else +# define fstatat fstatat64 +# endif +# endif + +extern int fstatat64 (int __fd, __const char *__restrict __file, + struct stat64 *__restrict __buf, int __flag) + __THROW __nonnull ((2, 3)); +#endif + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED +# ifndef __USE_FILE_OFFSET64 +/* Get file attributes about FILE and put them in BUF. + If FILE is a symbolic link, do not follow it. */ +extern int lstat (__const char *__restrict __file, + struct stat *__restrict __buf) __THROW __nonnull ((1, 2)); +# else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (lstat, + (__const char *__restrict __file, + struct stat *__restrict __buf), lstat64) + __nonnull ((1, 2)); +# else +# define lstat lstat64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int lstat64 (__const char *__restrict __file, + struct stat64 *__restrict __buf) + __THROW __nonnull ((1, 2)); +# endif +#endif + +/* Set file access permissions for FILE to MODE. + If FILE is a symbolic link, this affects its target instead. */ +extern int chmod (__const char *__file, __mode_t __mode) + __THROW __nonnull ((1)); + +#if 0 /*def __USE_BSD*/ +/* Set file access permissions for FILE to MODE. + If FILE is a symbolic link, this affects the link itself + rather than its target. */ +extern int lchmod (__const char *__file, __mode_t __mode) + __THROW __nonnull ((1)); +#endif + +/* Set file access permissions of the file FD is open on to MODE. */ +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED +extern int fchmod (int __fd, __mode_t __mode) __THROW; +#endif + +#ifdef __USE_ATFILE +/* Set file access permissions of FILE relative to + the directory FD is open on. */ +extern int fchmodat (int __fd, __const char *__file, __mode_t mode, int __flag) + __THROW __nonnull ((2)) __wur; +#endif /* Use ATFILE. */ + + + +/* Set the file creation mask of the current process to MASK, + and return the old creation mask. */ +extern __mode_t umask (__mode_t __mask) __THROW; + +#if 0 /*def __USE_GNU*/ +/* Get the current `umask' value without changing it. + This function is only available under the GNU Hurd. */ +extern __mode_t getumask (void) __THROW; +#endif + +/* Create a new directory named PATH, with permission bits MODE. */ +extern int mkdir (__const char *__path, __mode_t __mode) + __THROW __nonnull ((1)); + +#ifdef __USE_ATFILE +/* Like mkdir, create a new directory with permission bits MODE. But + interpret relative PATH names relative to the directory associated + with FD. */ +extern int mkdirat (int __fd, __const char *__path, __mode_t __mode) + __THROW __nonnull ((2)); +#endif + +/* Create a device file named PATH, with permission and special bits MODE + and device number DEV (which can be constructed from major and minor + device numbers with the `makedev' macro above). */ +#if defined __USE_MISC || defined __USE_BSD || defined __USE_XOPEN_EXTENDED +extern int mknod (__const char *__path, __mode_t __mode, __dev_t __dev) + __THROW __nonnull ((1)); +#endif + +#ifdef __USE_ATFILE +/* Like mknod, create a new device file with permission bits MODE and + device number DEV. But interpret relative PATH names relative to + the directory associated with FD. */ +extern int mknodat (int __fd, __const char *__path, __mode_t __mode, + __dev_t __dev) __THROW __nonnull ((2)); +#endif + + +/* Create a new FIFO named PATH, with permission bits MODE. */ +extern int mkfifo (__const char *__path, __mode_t __mode) + __THROW __nonnull ((1)); + +#ifdef __USE_ATFILE +/* Like mkfifo, create a new FIFO with permission bits MODE. But + interpret relative PATH names relative to the directory associated + with FD. */ +extern int mkfifoat (int __fd, __const char *__path, __mode_t __mode) + __THROW __nonnull ((2)); +#endif + +/* on uClibc we have unversioned struct stat and mknod. + * bits/stat.h is filled with wrong info, so we undo it here. */ +#undef _STAT_VER +#define _STAT_VER 0 +#undef _MKNOD_VER +#define _MKNOD_VER 0 + +__END_DECLS + + +#endif /* sys/stat.h */ diff --git a/conts/posix/libposix/include/posix/sys/statfs.h b/conts/posix/libposix/include/posix/sys/statfs.h new file mode 100644 index 0000000..3b2226b --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/statfs.h @@ -0,0 +1,68 @@ +/* Definitions for getting information about a filesystem. + Copyright (C) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_STATFS_H +#define _SYS_STATFS_H 1 + +#include + +/* Get the system-specific definition of `struct statfs'. */ +#include + +__BEGIN_DECLS + +/* Return information about the filesystem on which FILE resides. */ +#ifndef __USE_FILE_OFFSET64 +extern int statfs (__const char *__file, struct statfs *__buf) + __THROW __nonnull ((1, 2)); +#else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (statfs, + (__const char *__file, struct statfs *__buf), + statfs64) __nonnull ((1, 2)); +# else +# define statfs statfs64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern int statfs64 (__const char *__file, struct statfs64 *__buf) + __THROW __nonnull ((1, 2)); +#endif + +/* Return information about the filesystem containing the file FILDES + refers to. */ +#ifndef __USE_FILE_OFFSET64 +extern int fstatfs (int __fildes, struct statfs *__buf) + __THROW __nonnull ((2)); +#else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (fstatfs, (int __fildes, struct statfs *__buf), + fstatfs64) __nonnull ((2)); +# else +# define fstatfs fstatfs64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern int fstatfs64 (int __fildes, struct statfs64 *__buf) + __THROW __nonnull ((2)); +#endif + +__END_DECLS + +#endif /* sys/statfs.h */ diff --git a/conts/posix/libposix/include/posix/sys/statvfs.h b/conts/posix/libposix/include/posix/sys/statvfs.h new file mode 100644 index 0000000..685dd26 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/statvfs.h @@ -0,0 +1,91 @@ +/* Definitions for getting information about a filesystem. + Copyright (C) 1998, 1999, 2000, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_STATVFS_H +#define _SYS_STATVFS_H 1 + +#include + +/* Get the system-specific definition of `struct statfs'. */ +#include + +#ifndef __USE_FILE_OFFSET64 +# ifndef __fsblkcnt_t_defined +typedef __fsblkcnt_t fsblkcnt_t; /* Type to count file system blocks. */ +# define __fsblkcnt_t_defined +# endif +# ifndef __fsfilcnt_t_defined +typedef __fsfilcnt_t fsfilcnt_t; /* Type to count file system inodes. */ +# define __fsfilcnt_t_defined +# endif +#else +# ifndef __fsblkcnt_t_defined +typedef __fsblkcnt64_t fsblkcnt_t; /* Type to count file system blocks. */ +# define __fsblkcnt_t_defined +# endif +# ifndef __fsfilcnt_t_defined +typedef __fsfilcnt64_t fsfilcnt_t; /* Type to count file system inodes. */ +# define __fsfilcnt_t_defined +# endif +#endif + +__BEGIN_DECLS + +/* Return information about the filesystem on which FILE resides. */ +#ifndef __USE_FILE_OFFSET64 +extern int statvfs (__const char *__restrict __file, + struct statvfs *__restrict __buf) + __THROW __nonnull ((1, 2)); +#else +# ifdef __REDIRECT +extern int __REDIRECT (statvfs, + (__const char *__restrict __file, + struct statvfs *__restrict __buf), statvfs64) + __nonnull ((1, 2)); +# else +# define statvfs statvfs64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern int statvfs64 (__const char *__restrict __file, + struct statvfs64 *__restrict __buf) + __THROW __nonnull ((1, 2)); +#endif + +/* Return information about the filesystem containing the file FILDES + refers to. */ +#ifndef __USE_FILE_OFFSET64 +extern int fstatvfs (int __fildes, struct statvfs *__buf) + __THROW __nonnull ((2)); +#else +# ifdef __REDIRECT +extern int __REDIRECT (fstatvfs, (int __fildes, struct statvfs *__buf), + fstatvfs64) __nonnull ((2)); +# else +# define fstatvfs fstatvfs64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern int fstatvfs64 (int __fildes, struct statvfs64 *__buf) + __THROW __nonnull ((2)); +#endif + +__END_DECLS + +#endif /* sys/statvfs.h */ diff --git a/conts/posix/libposix/include/posix/sys/swap.h b/conts/posix/libposix/include/posix/sys/swap.h new file mode 100644 index 0000000..b6e7bef --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/swap.h @@ -0,0 +1,43 @@ +/* Calls to enable and disable swapping on specified locations. Linux version. + Copyright (C) 1996, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_SWAP_H + +#define _SYS_SWAP_H 1 +#include + +/* The swap priority is encoded as: + (prio << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK +*/ +#define SWAP_FLAG_PREFER 0x8000 /* Set if swap priority is specified. */ +#define SWAP_FLAG_PRIO_MASK 0x7fff +#define SWAP_FLAG_PRIO_SHIFT 0 + +__BEGIN_DECLS + +/* Make the block special device PATH available to the system for swapping. + This call is restricted to the super-user. */ +extern int swapon (__const char *__path, int __flags) __THROW; + +/* Stop using block special device PATH for swapping. */ +extern int swapoff (__const char *__path) __THROW; + +__END_DECLS + +#endif /* _SYS_SWAP_H */ diff --git a/conts/posix/libposix/include/posix/sys/syscall.h b/conts/posix/libposix/include/posix/sys/syscall.h new file mode 100644 index 0000000..4c8ede8 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/syscall.h @@ -0,0 +1,37 @@ +/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYSCALL_H +#define _SYSCALL_H 1 + +/* The _syscall#() macros are for uClibc internal use only. + * User application code should use syscall() instead. + * + * The kernel provided _syscall[0-6] macros from asm/unistd.h are not suitable + * for use in uClibc as they lack PIC support etc, so for uClibc we use our own + * local _syscall# macros to be certain all such variations are handled + * properly. + */ + +#include +#include +#if defined _LIBC && (defined IS_IN_libc || defined NOT_IN_libc) +# include +#endif + +#endif diff --git a/conts/posix/libposix/include/posix/sys/sysctl.h b/conts/posix/libposix/include/posix/sys/sysctl.h new file mode 100644 index 0000000..110efaa --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/sysctl.h @@ -0,0 +1,72 @@ +/* Copyright (C) 1996, 1999, 2002, 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_SYSCTL_H +#define _SYS_SYSCTL_H 1 + +#include +#define __need_size_t +#include +/* Prevent more kernel headers than necessary to be included. */ +#ifndef _LINUX_KERNEL_H +# define _LINUX_KERNEL_H 1 +# define __undef_LINUX_KERNEL_H +#endif +#ifndef _LINUX_TYPES_H +# define _LINUX_TYPES_H 1 +# define __undef_LINUX_TYPES_H +#endif +#ifndef _LINUX_LIST_H +# define _LINUX_LIST_H 1 +# define __undef_LINUX_LIST_H +#endif +#ifndef __LINUX_COMPILER_H +# define __LINUX_COMPILER_H 1 +# define __user +# define __undef__LINUX_COMPILER_H +#endif + +#include + +#ifdef __undef_LINUX_KERNEL_H +# undef _LINUX_KERNEL_H +# undef __undef_LINUX_KERNEL_H +#endif +#ifdef __undef_LINUX_TYPES_H +# undef _LINUX_TYPES_H +# undef __undef_LINUX_TYPES_H +#endif +#ifdef __undef_LINUX_LIST_H +# undef _LINUX_LIST_H +# undef __undef_LINUX_LIST_H +#endif +#ifdef __undef__LINUX_COMPILER_H +# undef __LINUX_COMPILER_H +# undef __user +# undef __undef__LINUX_COMPILER_H +#endif + +__BEGIN_DECLS + +/* Read or write system parameters. */ +extern int sysctl (int *__name, int __nlen, void *__oldval, + size_t *__oldlenp, void *__newval, size_t __newlen) __THROW; + +__END_DECLS + +#endif /* _SYS_SYSCTL_H */ diff --git a/conts/posix/libposix/include/posix/sys/sysinfo.h b/conts/posix/libposix/include/posix/sys/sysinfo.h new file mode 100644 index 0000000..9fd4fa8 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/sysinfo.h @@ -0,0 +1,67 @@ +/* Copyright (C) 1996, 1999, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_SYSINFO_H +#define _SYS_SYSINFO_H 1 + +#include + +#ifndef _LINUX_KERNEL_H +/* Include our own copy of struct sysinfo to avoid binary compatability + * problems with Linux 2.4, which changed things. Grumble, grumble. */ +#define SI_LOAD_SHIFT 16 +struct sysinfo { + long uptime; /* Seconds since boot */ + unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ + unsigned long totalram; /* Total usable main memory size */ + unsigned long freeram; /* Available memory size */ + unsigned long sharedram; /* Amount of shared memory */ + unsigned long bufferram; /* Memory used by buffers */ + unsigned long totalswap; /* Total swap space size */ + unsigned long freeswap; /* swap space still available */ + unsigned short procs; /* Number of current processes */ + unsigned short pad; /* Padding needed for m68k */ + unsigned long totalhigh; /* Total high memory size */ + unsigned long freehigh; /* Available high memory size */ + unsigned int mem_unit; /* Memory unit size in bytes */ + char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */ +}; +#endif + +__BEGIN_DECLS + +/* Returns information on overall system statistics. */ +extern int sysinfo (struct sysinfo *__info) __THROW; + + +/* Return number of configured processors. */ +extern int get_nprocs_conf (void) __THROW; + +/* Return number of available processors. */ +extern int get_nprocs (void) __THROW; + + +/* Return number of physical pages of memory in the system. */ +extern long int get_phys_pages (void) __THROW; + +/* Return number of available physical pages of memory in the system. */ +extern long int get_avphys_pages (void) __THROW; + +__END_DECLS + +#endif /* sys/sysinfo.h */ diff --git a/conts/posix/libposix/include/posix/sys/syslog.h b/conts/posix/libposix/include/posix/sys/syslog.h new file mode 100644 index 0000000..cbbc31e --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/syslog.h @@ -0,0 +1,206 @@ +/* + * Copyright (c) 1982, 1986, 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)syslog.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYS_SYSLOG_H +#define _SYS_SYSLOG_H 1 + +#include +#define __need___va_list +#include + + +#define _PATH_LOG "/dev/log" + +/* + * priorities/facilities are encoded into a single 32-bit quantity, where the + * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility + * (0-big number). Both the priorities and the facilities map roughly + * one-to-one to strings in the syslogd(8) source code. This mapping is + * included in this file. + * + * priorities (these are ordered) + */ +#define LOG_EMERG 0 /* system is unusable */ +#define LOG_ALERT 1 /* action must be taken immediately */ +#define LOG_CRIT 2 /* critical conditions */ +#define LOG_ERR 3 /* error conditions */ +#define LOG_WARNING 4 /* warning conditions */ +#define LOG_NOTICE 5 /* normal but significant condition */ +#define LOG_INFO 6 /* informational */ +#define LOG_DEBUG 7 /* debug-level messages */ + +#define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ + /* extract priority */ +#define LOG_PRI(p) ((p) & LOG_PRIMASK) +#define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) + +#ifdef SYSLOG_NAMES +#define INTERNAL_NOPRI 0x10 /* the "no priority" priority */ + /* mark "facility" */ +#define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) +typedef struct _code { + char *c_name; + int c_val; +} CODE; + +CODE prioritynames[] = + { + { "alert", LOG_ALERT }, + { "crit", LOG_CRIT }, + { "debug", LOG_DEBUG }, + { "emerg", LOG_EMERG }, + { "err", LOG_ERR }, + { "error", LOG_ERR }, /* DEPRECATED */ + { "info", LOG_INFO }, + { "none", INTERNAL_NOPRI }, /* INTERNAL */ + { "notice", LOG_NOTICE }, + { "panic", LOG_EMERG }, /* DEPRECATED */ + { "warn", LOG_WARNING }, /* DEPRECATED */ + { "warning", LOG_WARNING }, + { NULL, -1 } + }; +#endif + +/* facility codes */ +#define LOG_KERN (0<<3) /* kernel messages */ +#define LOG_USER (1<<3) /* random user-level messages */ +#define LOG_MAIL (2<<3) /* mail system */ +#define LOG_DAEMON (3<<3) /* system daemons */ +#define LOG_AUTH (4<<3) /* security/authorization messages */ +#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ +#define LOG_LPR (6<<3) /* line printer subsystem */ +#define LOG_NEWS (7<<3) /* network news subsystem */ +#define LOG_UUCP (8<<3) /* UUCP subsystem */ +#define LOG_CRON (9<<3) /* clock daemon */ +#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */ +#define LOG_FTP (11<<3) /* ftp daemon */ + + /* other codes through 15 reserved for system use */ +#define LOG_LOCAL0 (16<<3) /* reserved for local use */ +#define LOG_LOCAL1 (17<<3) /* reserved for local use */ +#define LOG_LOCAL2 (18<<3) /* reserved for local use */ +#define LOG_LOCAL3 (19<<3) /* reserved for local use */ +#define LOG_LOCAL4 (20<<3) /* reserved for local use */ +#define LOG_LOCAL5 (21<<3) /* reserved for local use */ +#define LOG_LOCAL6 (22<<3) /* reserved for local use */ +#define LOG_LOCAL7 (23<<3) /* reserved for local use */ + +#define LOG_NFACILITIES 24 /* current number of facilities */ +#define LOG_FACMASK 0x03f8 /* mask to extract facility part */ + /* facility of pri */ +#define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) + +#ifdef SYSLOG_NAMES +CODE facilitynames[] = + { + { "auth", LOG_AUTH }, + { "authpriv", LOG_AUTHPRIV }, + { "cron", LOG_CRON }, + { "daemon", LOG_DAEMON }, + { "ftp", LOG_FTP }, + { "kern", LOG_KERN }, + { "lpr", LOG_LPR }, + { "mail", LOG_MAIL }, + { "mark", INTERNAL_MARK }, /* INTERNAL */ + { "news", LOG_NEWS }, + { "security", LOG_AUTH }, /* DEPRECATED */ + { "syslog", LOG_SYSLOG }, + { "user", LOG_USER }, + { "uucp", LOG_UUCP }, + { "local0", LOG_LOCAL0 }, + { "local1", LOG_LOCAL1 }, + { "local2", LOG_LOCAL2 }, + { "local3", LOG_LOCAL3 }, + { "local4", LOG_LOCAL4 }, + { "local5", LOG_LOCAL5 }, + { "local6", LOG_LOCAL6 }, + { "local7", LOG_LOCAL7 }, + { NULL, -1 } + }; +#endif + +/* + * arguments to setlogmask. + */ +#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ +#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ + +/* + * Option flags for openlog. + * + * LOG_ODELAY no longer does anything. + * LOG_NDELAY is the inverse of what it used to be. + */ +#define LOG_PID 0x01 /* log the pid with each message */ +#define LOG_CONS 0x02 /* log on the console if errors in sending */ +#define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ +#define LOG_NDELAY 0x08 /* don't delay open */ +#define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ +#define LOG_PERROR 0x20 /* log to stderr as well */ + +__BEGIN_DECLS + +/* Close descriptor used to write to system logger. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void closelog (void); + +/* Open connection to system logger. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void openlog (__const char *__ident, int __option, int __facility); + +/* Set the log mask level. */ +extern int setlogmask (int __mask) __THROW; + +/* Generate a log message using FMT string and option arguments. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern void syslog (int __pri, __const char *__fmt, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); + +#ifdef __USE_BSD +/* Generate a log message using FMT and using arguments pointed to by AP. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern void vsyslog (int __pri, __const char *__fmt, __gnuc_va_list __ap) + __attribute__ ((__format__ (__printf__, 2, 0))); +#endif + +__END_DECLS + +#endif /* sys/syslog.h */ diff --git a/conts/posix/libposix/include/posix/sys/sysmacros.h b/conts/posix/libposix/include/posix/sys/sysmacros.h new file mode 100644 index 0000000..c5efca4 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/sysmacros.h @@ -0,0 +1,69 @@ +/* Definitions of macros to access `dev_t' values. + Copyright (C) 1996, 1997, 1999, 2003, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_SYSMACROS_H +#define _SYS_SYSMACROS_H 1 + +#include + +/* If the compiler does not know long long it is out of luck. We are + not going to hack weird hacks to support the dev_t representation + they need. */ +#if 1 /*def __GLIBC_HAVE_LONG_LONG uClibc note: always enable */ +__extension__ +static __inline unsigned int gnu_dev_major (unsigned long long int __dev) + __THROW; +__extension__ +static __inline unsigned int gnu_dev_minor (unsigned long long int __dev) + __THROW; +__extension__ +static __inline unsigned long long int gnu_dev_makedev (unsigned int __major, + unsigned int __minor) + __THROW; + +# if defined __GNUC__ && __GNUC__ >= 2 +__extension__ static __inline unsigned int +__NTH (gnu_dev_major (unsigned long long int __dev)) +{ + return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff); +} + +__extension__ static __inline unsigned int +__NTH (gnu_dev_minor (unsigned long long int __dev)) +{ + return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff); +} + +__extension__ static __inline unsigned long long int +__NTH (gnu_dev_makedev (unsigned int __major, unsigned int __minor)) +{ + return ((__minor & 0xff) | ((__major & 0xfff) << 8) + | (((unsigned long long int) (__minor & ~0xff)) << 12) + | (((unsigned long long int) (__major & ~0xfff)) << 32)); +} +# endif + + +/* Access the functions with their traditional names. */ +# define major(dev) gnu_dev_major (dev) +# define minor(dev) gnu_dev_minor (dev) +# define makedev(maj, min) gnu_dev_makedev (maj, min) +#endif + +#endif /* sys/sysmacros.h */ diff --git a/conts/posix/libposix/include/posix/sys/termios.h b/conts/posix/libposix/include/posix/sys/termios.h new file mode 100644 index 0000000..3e18805 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/termios.h @@ -0,0 +1,4 @@ +#ifndef _SYS_TERMIOS_H +#define _SYS_TERMIOS_H +#include +#endif diff --git a/conts/posix/libposix/include/posix/sys/time.h b/conts/posix/libposix/include/posix/sys/time.h new file mode 100644 index 0000000..66fb9e0 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/time.h @@ -0,0 +1,192 @@ +/* Copyright (C) 1991-1994,1996-2002,2003,2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_TIME_H +#define _SYS_TIME_H 1 + +#include + +#include +#define __need_time_t +#include +#define __need_timeval +#include + +#include + +#ifndef __suseconds_t_defined +typedef __suseconds_t suseconds_t; +# define __suseconds_t_defined +#endif + + +__BEGIN_DECLS + +#ifdef __USE_GNU +/* Macros for converting between `struct timeval' and `struct timespec'. */ +# define TIMEVAL_TO_TIMESPEC(tv, ts) { \ + (ts)->tv_sec = (tv)->tv_sec; \ + (ts)->tv_nsec = (tv)->tv_usec * 1000; \ +} +# define TIMESPEC_TO_TIMEVAL(tv, ts) { \ + (tv)->tv_sec = (ts)->tv_sec; \ + (tv)->tv_usec = (ts)->tv_nsec / 1000; \ +} +#endif + + +#ifdef __USE_BSD +/* Structure crudely representing a timezone. + This is obsolete and should never be used. */ +struct timezone + { + int tz_minuteswest; /* Minutes west of GMT. */ + int tz_dsttime; /* Nonzero if DST is ever in effect. */ + }; + +typedef struct timezone *__restrict __timezone_ptr_t; +#else +typedef void *__restrict __timezone_ptr_t; +#endif + +/* Get the current time of day and timezone information, + putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled. + Returns 0 on success, -1 on errors. + NOTE: This form of timezone information is obsolete. + Use the functions and variables declared in instead. */ +extern int gettimeofday (struct timeval *__restrict __tv, + __timezone_ptr_t __tz) __THROW __nonnull ((1)); + +#ifdef __USE_BSD +/* Set the current time of day and timezone information. + This call is restricted to the super-user. */ +extern int settimeofday (__const struct timeval *__tv, + __const struct timezone *__tz) + __THROW __nonnull ((1)); + +/* Adjust the current time of day by the amount in DELTA. + If OLDDELTA is not NULL, it is filled in with the amount + of time adjustment remaining to be done from the last `adjtime' call. + This call is restricted to the super-user. */ +extern int adjtime (__const struct timeval *__delta, + struct timeval *__olddelta) __THROW; +#endif + + +/* Values for the first argument to `getitimer' and `setitimer'. */ +enum __itimer_which + { + /* Timers run in real time. */ + ITIMER_REAL = 0, +#define ITIMER_REAL ITIMER_REAL + /* Timers run only when the process is executing. */ + ITIMER_VIRTUAL = 1, +#define ITIMER_VIRTUAL ITIMER_VIRTUAL + /* Timers run when the process is executing and when + the system is executing on behalf of the process. */ + ITIMER_PROF = 2 +#define ITIMER_PROF ITIMER_PROF + }; + +/* Type of the second argument to `getitimer' and + the second and third arguments `setitimer'. */ +struct itimerval + { + /* Value to put into `it_value' when the timer expires. */ + struct timeval it_interval; + /* Time to the next timer expiration. */ + struct timeval it_value; + }; + +#if defined __USE_GNU && !defined __cplusplus +/* Use the nicer parameter type only in GNU mode and not for C++ since the + strict C++ rules prevent the automatic promotion. */ +typedef enum __itimer_which __itimer_which_t; +#else +typedef int __itimer_which_t; +#endif + +/* Set *VALUE to the current setting of timer WHICH. + Return 0 on success, -1 on errors. */ +extern int getitimer (__itimer_which_t __which, + struct itimerval *__value) __THROW; + +/* Set the timer WHICH to *NEW. If OLD is not NULL, + set *OLD to the old value of timer WHICH. + Returns 0 on success, -1 on errors. */ +extern int setitimer (__itimer_which_t __which, + __const struct itimerval *__restrict __new, + struct itimerval *__restrict __old) __THROW; + +/* Change the access time of FILE to TVP[0] and the modification time of + FILE to TVP[1]. If TVP is a null pointer, use the current time instead. + Returns 0 on success, -1 on errors. */ +extern int utimes (__const char *__file, __const struct timeval __tvp[2]) + __THROW __nonnull ((1)); + +#if 0 /*def __USE_BSD*/ +/* Same as `utimes', but does not follow symbolic links. */ +extern int lutimes (__const char *__file, __const struct timeval __tvp[2]) + __THROW __nonnull ((1)); + +/* Same as `utimes', but takes an open file descriptor instead of a name. */ +extern int futimes (int __fd, __const struct timeval __tvp[2]) __THROW; +#endif + +#if 0 /*def __USE_GNU*/ +/* Change the access time of FILE relative to FD to TVP[0] and the + modification time of FILE to TVP[1]. If TVP is a null pointer, use + the current time instead. Returns 0 on success, -1 on errors. */ +extern int futimesat (int __fd, __const char *__file, + __const struct timeval __tvp[2]) __THROW; +#endif + + +#ifdef __USE_BSD +/* Convenience macros for operations on timevals. + NOTE: `timercmp' does not work for >= or <=. */ +# define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +# define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) +# define timercmp(a, b, CMP) \ + (((a)->tv_sec == (b)->tv_sec) ? \ + ((a)->tv_usec CMP (b)->tv_usec) : \ + ((a)->tv_sec CMP (b)->tv_sec)) +# define timeradd(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ + if ((result)->tv_usec >= 1000000) \ + { \ + ++(result)->tv_sec; \ + (result)->tv_usec -= 1000000; \ + } \ + } while (0) +# define timersub(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((result)->tv_usec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ + } while (0) +#endif /* BSD */ + +__END_DECLS + +#endif /* sys/time.h */ diff --git a/conts/posix/libposix/include/posix/sys/timeb.h b/conts/posix/libposix/include/posix/sys/timeb.h new file mode 100644 index 0000000..dbdbf45 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/timeb.h @@ -0,0 +1,46 @@ +/* Copyright (C) 1994, 1995, 1996, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_TIMEB_H +#define _SYS_TIMEB_H 1 + +#include + +#define __need_time_t +#include + + +__BEGIN_DECLS + +/* Structure returned by the `ftime' function. */ + +struct timeb + { + time_t time; /* Seconds since epoch, as from `time'. */ + unsigned short int millitm; /* Additional milliseconds. */ + short int timezone; /* Minutes west of GMT. */ + short int dstflag; /* Nonzero if Daylight Savings Time used. */ + }; + +/* Fill in TIMEBUF with information about the current time. */ + +extern int ftime (struct timeb *__timebuf); + +__END_DECLS + +#endif /* sys/timeb.h */ diff --git a/conts/posix/libposix/include/posix/sys/times.h b/conts/posix/libposix/include/posix/sys/times.h new file mode 100644 index 0000000..6022f2f --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/times.h @@ -0,0 +1,53 @@ +/* Copyright (C) 1991, 1992, 1996, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * POSIX Standard: 4.5.2 Process Times + */ + +#ifndef _SYS_TIMES_H +#define _SYS_TIMES_H 1 + +#include + +#define __need_clock_t +#include + + +__BEGIN_DECLS + +/* Structure describing CPU time used by a process and its children. */ +struct tms + { + clock_t tms_utime; /* User CPU time. */ + clock_t tms_stime; /* System CPU time. */ + + clock_t tms_cutime; /* User CPU time of dead children. */ + clock_t tms_cstime; /* System CPU time of dead children. */ + }; + + +/* Store the CPU time used by this process and all its + dead children (and their dead children) in BUFFER. + Return the elapsed real time, or (clock_t) -1 for errors. + All times are in CLK_TCKths of a second. */ +extern clock_t times (struct tms *__buffer) __THROW; + +__END_DECLS + +#endif /* sys/times.h */ diff --git a/conts/posix/libposix/include/posix/sys/timex.h b/conts/posix/libposix/include/posix/sys/timex.h new file mode 100644 index 0000000..773a5ab --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/timex.h @@ -0,0 +1,127 @@ +/* Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_TIMEX_H +#define _SYS_TIMEX_H 1 + +#include +#include + +/* These definitions from linux/timex.h as of 2.2.0. */ + +struct ntptimeval +{ + struct timeval time; /* current time (ro) */ + long int maxerror; /* maximum error (us) (ro) */ + long int esterror; /* estimated error (us) (ro) */ +}; + +struct timex +{ + unsigned int modes; /* mode selector */ + long int offset; /* time offset (usec) */ + long int freq; /* frequency offset (scaled ppm) */ + long int maxerror; /* maximum error (usec) */ + long int esterror; /* estimated error (usec) */ + int status; /* clock command/status */ + long int constant; /* pll time constant */ + long int precision; /* clock precision (usec) (read only) */ + long int tolerance; /* clock frequency tolerance (ppm) (read only) */ + struct timeval time; /* (read only) */ + long int tick; /* (modified) usecs between clock ticks */ + + long int ppsfreq; /* pps frequency (scaled ppm) (ro) */ + long int jitter; /* pps jitter (us) (ro) */ + int shift; /* interval duration (s) (shift) (ro) */ + long int stabil; /* pps stability (scaled ppm) (ro) */ + long int jitcnt; /* jitter limit exceeded (ro) */ + long int calcnt; /* calibration intervals (ro) */ + long int errcnt; /* calibration errors (ro) */ + long int stbcnt; /* stability limit exceeded (ro) */ + + /* ??? */ + int :32; int :32; int :32; int :32; + int :32; int :32; int :32; int :32; + int :32; int :32; int :32; int :32; +}; + +/* Mode codes (timex.mode) */ +#define ADJ_OFFSET 0x0001 /* time offset */ +#define ADJ_FREQUENCY 0x0002 /* frequency offset */ +#define ADJ_MAXERROR 0x0004 /* maximum time error */ +#define ADJ_ESTERROR 0x0008 /* estimated time error */ +#define ADJ_STATUS 0x0010 /* clock status */ +#define ADJ_TIMECONST 0x0020 /* pll time constant */ +#define ADJ_TICK 0x4000 /* tick value */ +#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ + +/* xntp 3.4 compatibility names */ +#define MOD_OFFSET ADJ_OFFSET +#define MOD_FREQUENCY ADJ_FREQUENCY +#define MOD_MAXERROR ADJ_MAXERROR +#define MOD_ESTERROR ADJ_ESTERROR +#define MOD_STATUS ADJ_STATUS +#define MOD_TIMECONST ADJ_TIMECONST +#define MOD_CLKB ADJ_TICK +#define MOD_CLKA ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */ + + +/* Status codes (timex.status) */ +#define STA_PLL 0x0001 /* enable PLL updates (rw) */ +#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */ +#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */ +#define STA_FLL 0x0008 /* select frequency-lock mode (rw) */ + +#define STA_INS 0x0010 /* insert leap (rw) */ +#define STA_DEL 0x0020 /* delete leap (rw) */ +#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */ +#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */ + +#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */ +#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */ +#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */ +#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ + +#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ + +#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ + STA_PPSERROR | STA_CLOCKERR) /* read-only bits */ + +/* Clock states (time_state) */ +#define TIME_OK 0 /* clock synchronized, no leap second */ +#define TIME_INS 1 /* insert leap second */ +#define TIME_DEL 2 /* delete leap second */ +#define TIME_OOP 3 /* leap second in progress */ +#define TIME_WAIT 4 /* leap second has occurred */ +#define TIME_ERROR 5 /* clock not synchronized */ +#define TIME_BAD TIME_ERROR /* bw compat */ + +/* Maximum time constant of the PLL. */ +#define MAXTC 6 + +__BEGIN_DECLS + +extern int __adjtimex (struct timex *__ntx) __THROW; +extern int adjtimex (struct timex *__ntx) __THROW; + +extern int ntp_gettime (struct ntptimeval *__ntv) __THROW; +extern int ntp_adjtime (struct timex *__tntx) __THROW; + +__END_DECLS + +#endif /* sys/timex.h */ diff --git a/conts/posix/libposix/include/posix/sys/ttydefaults.h b/conts/posix/libposix/include/posix/sys/ttydefaults.h new file mode 100644 index 0000000..9be168b --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/ttydefaults.h @@ -0,0 +1,100 @@ +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ttydefaults.h 8.4 (Berkeley) 1/21/94 + */ + +/* + * System wide defaults for terminal state. Linux version. + */ +#ifndef _SYS_TTYDEFAULTS_H_ +#define _SYS_TTYDEFAULTS_H_ + +/* + * Defaults on "first" open. + */ +#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY) +#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS) +#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL) +#define TTYDEF_CFLAG (CREAD | CS7 | PARENB | HUPCL) +#define TTYDEF_SPEED (B9600) + +/* + * Control Character Defaults + */ +#define CTRL(x) (x&037) +#define CEOF CTRL('d') +#ifdef _POSIX_VDISABLE +# define CEOL _POSIX_VDISABLE +#else +# define CEOL '\0' /* XXX avoid _POSIX_VDISABLE */ +#endif +#define CERASE 0177 +#define CINTR CTRL('c') +#ifdef _POSIX_VDISABLE +# define CSTATUS _POSIX_VDISABLE +#else +# define CSTATUS '\0' /* XXX avoid _POSIX_VDISABLE */ +#endif +#define CKILL CTRL('u') +#define CMIN 1 +#define CQUIT 034 /* FS, ^\ */ +#define CSUSP CTRL('z') +#define CTIME 0 +#define CDSUSP CTRL('y') +#define CSTART CTRL('q') +#define CSTOP CTRL('s') +#define CLNEXT CTRL('v') +#define CDISCARD CTRL('o') +#define CWERASE CTRL('w') +#define CREPRINT CTRL('r') +#define CEOT CEOF +/* compat */ +#define CBRK CEOL +#define CRPRNT CREPRINT +#define CFLUSH CDISCARD + +/* PROTECTED INCLUSION ENDS HERE */ +#endif /* !_SYS_TTYDEFAULTS_H_ */ + +/* + * #define TTYDEFCHARS to include an array of default control characters. + */ +#ifdef TTYDEFCHARS +cc_t ttydefchars[NCCS] = { + CEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT, + _POSIX_VDISABLE, CINTR, CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT, + CDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE +}; +#undef TTYDEFCHARS +#endif diff --git a/conts/posix/libposix/include/posix/sys/types.h b/conts/posix/libposix/include/posix/sys/types.h new file mode 100644 index 0000000..8c0b5dc --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/types.h @@ -0,0 +1,275 @@ +/* Copyright (C) 1991,1992,1994,1995,1996,1997,1998,1999,2000,2001,2002 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * POSIX Standard: 2.6 Primitive System Data Types + */ + +#ifndef _SYS_TYPES_H +#define _SYS_TYPES_H 1 + +#include + +__BEGIN_DECLS + +#include + +#ifdef __USE_BSD +# ifndef __u_char_defined +typedef __u_char u_char; +typedef __u_short u_short; +typedef __u_int u_int; +typedef __u_long u_long; +typedef __quad_t quad_t; +typedef __u_quad_t u_quad_t; +typedef __fsid_t fsid_t; +# define __u_char_defined +# endif +#endif + +typedef __loff_t loff_t; + +#ifndef __ino_t_defined +# ifndef __USE_FILE_OFFSET64 +typedef __ino_t ino_t; +# else +typedef __ino64_t ino_t; +# endif +# define __ino_t_defined +#endif +#if defined __USE_LARGEFILE64 && !defined __ino64_t_defined +typedef __ino64_t ino64_t; +# define __ino64_t_defined +#endif + +#ifndef __dev_t_defined +typedef __dev_t dev_t; +# define __dev_t_defined +#endif + +#ifndef __gid_t_defined +typedef __gid_t gid_t; +# define __gid_t_defined +#endif + +#ifndef __mode_t_defined +typedef __mode_t mode_t; +# define __mode_t_defined +#endif + +#ifndef __nlink_t_defined +typedef __nlink_t nlink_t; +# define __nlink_t_defined +#endif + +#ifndef __uid_t_defined +typedef __uid_t uid_t; +# define __uid_t_defined +#endif + +#ifndef __off_t_defined +# ifndef __USE_FILE_OFFSET64 +typedef __off_t off_t; +# else +typedef __off64_t off_t; +# endif +# define __off_t_defined +#endif +#if defined __USE_LARGEFILE64 && !defined __off64_t_defined +typedef __off64_t off64_t; +# define __off64_t_defined +#endif + +#ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +#endif + +#if (defined __USE_SVID || defined __USE_XOPEN) && !defined __id_t_defined +typedef __id_t id_t; +# define __id_t_defined +#endif + +#ifndef __ssize_t_defined +typedef __ssize_t ssize_t; +# define __ssize_t_defined +#endif + +#ifdef __USE_BSD +# ifndef __daddr_t_defined +typedef __daddr_t daddr_t; +typedef __caddr_t caddr_t; +# define __daddr_t_defined +# endif +#endif + +#if (defined __USE_SVID || defined __USE_XOPEN) && !defined __key_t_defined +typedef __key_t key_t; +# define __key_t_defined +#endif + +#ifdef __USE_XOPEN +# define __need_clock_t +#endif +#define __need_time_t +#define __need_timer_t +#define __need_clockid_t +#include + +#ifdef __USE_XOPEN +# ifndef __useconds_t_defined +typedef __useconds_t useconds_t; +# define __useconds_t_defined +# endif +# ifndef __suseconds_t_defined +typedef __suseconds_t suseconds_t; +# define __suseconds_t_defined +# endif +#endif + +#define __need_size_t +#include + +#ifdef __USE_MISC +/* Old compatibility names for C types. */ +typedef unsigned long int ulong; +typedef unsigned short int ushort; +typedef unsigned int uint; +#endif + +/* These size-specific names are used by some of the inet code. */ + +#if !__GNUC_PREREQ (2, 7) + +/* These types are defined by the ISO C99 header . */ +# ifndef __int8_t_defined +# define __int8_t_defined +typedef char int8_t; +typedef short int int16_t; +typedef int int32_t; +# if __WORDSIZE == 64 +typedef long int int64_t; +# elif defined __GNUC__ || defined __ICC +__extension__ typedef long long int int64_t; +# endif +# endif + +/* But these were defined by ISO C without the first `_'. */ +typedef unsigned char u_int8_t; +typedef unsigned short int u_int16_t; +typedef unsigned int u_int32_t; +# if __WORDSIZE == 64 +typedef unsigned long int u_int64_t; +# elif defined __GNUC__ || defined __ICC +__extension__ typedef unsigned long long int u_int64_t; +# endif + +typedef int register_t; + +#else + +/* For GCC 2.7 and later, we can use specific type-size attributes. */ +# define __intN_t(N, MODE) \ + typedef int int##N##_t __attribute__ ((__mode__ (MODE))) +# define __u_intN_t(N, MODE) \ + typedef unsigned int u_int##N##_t __attribute__ ((__mode__ (MODE))) + +# ifndef __int8_t_defined +# define __int8_t_defined +__intN_t (8, __QI__); +__intN_t (16, __HI__); +__intN_t (32, __SI__); +__intN_t (64, __DI__); +# endif + +__u_intN_t (8, __QI__); +__u_intN_t (16, __HI__); +__u_intN_t (32, __SI__); +__u_intN_t (64, __DI__); + +typedef int register_t __attribute__ ((__mode__ (__word__))); + + +/* Some code from BIND tests this macro to see if the types above are + defined. */ +#endif +#define __BIT_TYPES_DEFINED__ 1 + + +#ifdef __USE_BSD +/* In BSD is expected to define BYTE_ORDER. */ +# include + +/* It also defines `fd_set' and the FD_* macros for `select'. */ +# include + +/* BSD defines these symbols, so we follow. */ +# include +#endif /* Use BSD. */ + + +#if defined __USE_UNIX98 && !defined __blksize_t_defined +typedef __blksize_t blksize_t; +# define __blksize_t_defined +#endif + +/* Types from the Large File Support interface. */ +#ifndef __USE_FILE_OFFSET64 +# ifndef __blkcnt_t_defined +typedef __blkcnt_t blkcnt_t; /* Type to count number of disk blocks. */ +# define __blkcnt_t_defined +# endif +# ifndef __fsblkcnt_t_defined +typedef __fsblkcnt_t fsblkcnt_t; /* Type to count file system blocks. */ +# define __fsblkcnt_t_defined +# endif +# ifndef __fsfilcnt_t_defined +typedef __fsfilcnt_t fsfilcnt_t; /* Type to count file system inodes. */ +# define __fsfilcnt_t_defined +# endif +#else +# ifndef __blkcnt_t_defined +typedef __blkcnt64_t blkcnt_t; /* Type to count number of disk blocks. */ +# define __blkcnt_t_defined +# endif +# ifndef __fsblkcnt_t_defined +typedef __fsblkcnt64_t fsblkcnt_t; /* Type to count file system blocks. */ +# define __fsblkcnt_t_defined +# endif +# ifndef __fsfilcnt_t_defined +typedef __fsfilcnt64_t fsfilcnt_t; /* Type to count file system inodes. */ +# define __fsfilcnt_t_defined +# endif +#endif + +#ifdef __USE_LARGEFILE64 +typedef __blkcnt64_t blkcnt64_t; /* Type to count number of disk blocks. */ +typedef __fsblkcnt64_t fsblkcnt64_t; /* Type to count file system blocks. */ +typedef __fsfilcnt64_t fsfilcnt64_t; /* Type to count file system inodes. */ +#endif + + +/* Now add the thread types. */ +#if (defined __USE_POSIX199506 || defined __USE_UNIX98) && defined __UCLIBC_HAS_THREADS__ +# include +#endif + +__END_DECLS + +#endif /* sys/types.h */ diff --git a/conts/posix/libposix/include/posix/sys/uio.h b/conts/posix/libposix/include/posix/sys/uio.h new file mode 100644 index 0000000..1b203f7 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/uio.h @@ -0,0 +1,54 @@ +/* Copyright (C) 1991, 92, 96, 97, 98, 99, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_UIO_H +#define _SYS_UIO_H 1 + +#include + +#include + +__BEGIN_DECLS + +/* This file defines `struct iovec'. */ +#include + + +/* Read data from file descriptor FD, and put the result in the + buffers described by IOVEC, which is a vector of COUNT `struct iovec's. + The buffers are filled in the order specified. + Operates just like `read' (see ) except that data are + put in IOVEC instead of a contiguous buffer. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t readv (int __fd, __const struct iovec *__iovec, int __count); + +/* Write data pointed by the buffers described by IOVEC, which + is a vector of COUNT `struct iovec's, to file descriptor FD. + The data is written in the order specified. + Operates just like `write' (see ) except that the data + are taken from IOVEC instead of a contiguous buffer. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t writev (int __fd, __const struct iovec *__iovec, int __count); + +__END_DECLS + +#endif /* sys/uio.h */ diff --git a/conts/posix/libposix/include/posix/sys/un.h b/conts/posix/libposix/include/posix/sys/un.h new file mode 100644 index 0000000..1fa10e4 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/un.h @@ -0,0 +1,47 @@ +/* Copyright (C) 1991, 1995, 1996, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_UN_H +#define _SYS_UN_H 1 + +#include + +/* Get the definition of the macro to define the common sockaddr members. */ +#include + +__BEGIN_DECLS + +/* Structure describing the address of an AF_LOCAL (aka AF_UNIX) socket. */ +struct sockaddr_un + { + __SOCKADDR_COMMON (sun_); + char sun_path[108]; /* Path name. */ + }; + + +#ifdef __USE_MISC +# include /* For prototype of `strlen'. */ + +/* Evaluate to actual length of the `sockaddr_un' structure. */ +# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \ + + strlen ((ptr)->sun_path)) +#endif + +__END_DECLS + +#endif /* sys/un.h */ diff --git a/conts/posix/libposix/include/posix/sys/unistd.h b/conts/posix/libposix/include/posix/sys/unistd.h new file mode 100644 index 0000000..1e823fb --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/unistd.h @@ -0,0 +1 @@ +#include diff --git a/conts/posix/libposix/include/posix/sys/ustat.h b/conts/posix/libposix/include/posix/sys/ustat.h new file mode 100644 index 0000000..7a9cdac --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/ustat.h @@ -0,0 +1,38 @@ +/* Header describing obsolete `ustat' interface. + Copyright (C) 1996, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * This interface is obsolete. Use instead. + */ + +#ifndef _SYS_USTAT_H +#define _SYS_USTAT_H 1 + +#include + +#include +#include + +__BEGIN_DECLS + +extern int ustat (__dev_t __dev, struct ustat *__ubuf) __THROW; + +__END_DECLS + +#endif /* sys/ustat.h */ diff --git a/conts/posix/libposix/include/posix/sys/utsname.h b/conts/posix/libposix/include/posix/sys/utsname.h new file mode 100644 index 0000000..ca195cb --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/utsname.h @@ -0,0 +1,74 @@ +/* Copyright (C) 1991, 92, 94, 96, 97, 99 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * POSIX Standard: 4.4 System Identification + */ + +#ifndef _SYS_UTSNAME_H +#define _SYS_UTSNAME_H 1 + +#include + +__BEGIN_DECLS + +#include + +#ifndef _UTSNAME_NODENAME_LENGTH +# define _UTSNAME_NODENAME_LENGTH _UTSNAME_LENGTH +#endif + +/* Structure describing the system and machine. */ +struct utsname + { + /* Name of the implementation of the operating system. */ + char sysname[_UTSNAME_LENGTH]; + + /* Name of this node on the network. */ + char nodename[_UTSNAME_NODENAME_LENGTH]; + + /* Current release level of this implementation. */ + char release[_UTSNAME_LENGTH]; + /* Current version level of this release. */ + char version[_UTSNAME_LENGTH]; + + /* Name of the hardware type the system is running on. */ + char machine[_UTSNAME_LENGTH]; + +#if _UTSNAME_DOMAIN_LENGTH - 0 + /* Name of the domain of this node on the network. */ +# ifdef __USE_GNU + char domainname[_UTSNAME_DOMAIN_LENGTH]; +# else + char __domainname[_UTSNAME_DOMAIN_LENGTH]; +# endif +#endif + }; + +#ifdef __USE_SVID +# define SYS_NMLN _UTSNAME_LENGTH +#endif + + +/* Put information about the system in NAME. */ +extern int uname (struct utsname *__name) __THROW; + + +__END_DECLS + +#endif /* sys/utsname.h */ diff --git a/conts/posix/libposix/include/posix/sys/vfs.h b/conts/posix/libposix/include/posix/sys/vfs.h new file mode 100644 index 0000000..fa22d31 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/vfs.h @@ -0,0 +1,4 @@ +/* Other systems declare `struct statfs' et al in , + so we have this file to be compatible with programs expecting it. */ + +#include diff --git a/conts/posix/libposix/include/posix/sys/vt.h b/conts/posix/libposix/include/posix/sys/vt.h new file mode 100644 index 0000000..834abfb --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/vt.h @@ -0,0 +1 @@ +#include diff --git a/conts/posix/libposix/include/posix/sys/wait.h b/conts/posix/libposix/include/posix/sys/wait.h new file mode 100644 index 0000000..81a54fc --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/wait.h @@ -0,0 +1,186 @@ +/* Copyright (C) 1991-1994,1996-2001,2003,2004,2005 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * POSIX Standard: 3.2.1 Wait for Process Termination + */ + +#ifndef _SYS_WAIT_H +#define _SYS_WAIT_H 1 + +#include + +__BEGIN_DECLS + +#include +#include + +/* These macros could also be defined in . */ +#if !defined _STDLIB_H || !defined __USE_XOPEN +/* This will define the `W*' macros for the flag + bits to `waitpid', `wait3', and `wait4'. */ +# include + +# ifdef __USE_BSD + +/* Lots of hair to allow traditional BSD use of `union wait' + as well as POSIX.1 use of `int' for the status word. */ + +# if defined __GNUC__ && !defined __cplusplus +# define __WAIT_INT(status) \ + (__extension__ (((union { __typeof(status) __in; int __i; }) \ + { .__in = (status) }).__i)) +# else +# define __WAIT_INT(status) (*(__const int *) &(status)) +# endif + +/* This is the type of the argument to `wait'. The funky union + causes redeclarations with ether `int *' or `union wait *' to be + allowed without complaint. __WAIT_STATUS_DEFN is the type used in + the actual function definitions. */ + +# if !defined __GNUC__ || __GNUC__ < 2 || defined __cplusplus +# define __WAIT_STATUS void * +# define __WAIT_STATUS_DEFN void * +# else +/* This works in GCC 2.6.1 and later. */ +typedef union + { + union wait *__uptr; + int *__iptr; + } __WAIT_STATUS __attribute__ ((__transparent_union__)); +# define __WAIT_STATUS_DEFN int * +# endif + +# else /* Don't use BSD. */ + +# define __WAIT_INT(status) (status) +# define __WAIT_STATUS int * +# define __WAIT_STATUS_DEFN int * + +# endif /* Use BSD. */ + +/* This will define all the `__W*' macros. */ +# include + +# define WEXITSTATUS(status) __WEXITSTATUS(__WAIT_INT(status)) +# define WTERMSIG(status) __WTERMSIG(__WAIT_INT(status)) +# define WSTOPSIG(status) __WSTOPSIG(__WAIT_INT(status)) +# define WIFEXITED(status) __WIFEXITED(__WAIT_INT(status)) +# define WIFSIGNALED(status) __WIFSIGNALED(__WAIT_INT(status)) +# define WIFSTOPPED(status) __WIFSTOPPED(__WAIT_INT(status)) +# if 0 /*def __WIFCONTINUED*/ +# define WIFCONTINUED(status) __WIFCONTINUED(__WAIT_INT(status)) +# endif +#endif /* not included. */ + +#ifdef __USE_BSD +# define WCOREFLAG __WCOREFLAG +# define WCOREDUMP(status) __WCOREDUMP(__WAIT_INT(status)) +# define W_EXITCODE(ret, sig) __W_EXITCODE(ret, sig) +# define W_STOPCODE(sig) __W_STOPCODE(sig) +#endif + +/* The following values are used by the `waitid' function. */ +#if defined __USE_SVID || defined __USE_XOPEN +typedef enum +{ + P_ALL, /* Wait for any child. */ + P_PID, /* Wait for specified process. */ + P_PGID /* Wait for members of process group. */ +} idtype_t; +#endif + + +/* Wait for a child to die. When one does, put its status in *STAT_LOC + and return its process ID. For errors, return (pid_t) -1. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern __pid_t wait (__WAIT_STATUS __stat_loc); + +#ifdef __USE_BSD +/* Special values for the PID argument to `waitpid' and `wait4'. */ +# define WAIT_ANY (-1) /* Any process. */ +# define WAIT_MYPGRP 0 /* Any process in my process group. */ +#endif + +/* Wait for a child matching PID to die. + If PID is greater than 0, match any process whose process ID is PID. + If PID is (pid_t) -1, match any process. + If PID is (pid_t) 0, match any process with the + same process group as the current process. + If PID is less than -1, match any process whose + process group is the absolute value of PID. + If the WNOHANG bit is set in OPTIONS, and that child + is not already dead, return (pid_t) 0. If successful, + return PID and store the dead child's status in STAT_LOC. + Return (pid_t) -1 for errors. If the WUNTRACED bit is + set in OPTIONS, return status for stopped children; otherwise don't. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options); + +#if defined __USE_SVID || defined __USE_XOPEN +# define __need_siginfo_t +# include +/* Wait for a childing matching IDTYPE and ID to change the status and + place appropriate information in *INFOP. + If IDTYPE is P_PID, match any process whose process ID is ID. + If IDTYPE is P_PGID, match any process whose process group is ID. + If IDTYPE is P_ALL, match any process. + If the WNOHANG bit is set in OPTIONS, and that child + is not already dead, clear *INFOP and return 0. If successful, store + exit code and status in *INFOP. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop, + int __options); +#endif + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED +/* This being here makes the prototypes valid whether or not + we have already included to define `struct rusage'. */ +struct rusage; + +/* Wait for a child to exit. When one does, put its status in *STAT_LOC and + return its process ID. For errors return (pid_t) -1. If USAGE is not + nil, store information about the child's resource usage there. If the + WUNTRACED bit is set in OPTIONS, return status for stopped children; + otherwise don't. */ +extern __pid_t wait3 (__WAIT_STATUS __stat_loc, int __options, + struct rusage * __usage) __THROW; +#endif + +#ifdef __USE_BSD +/* This being here makes the prototypes valid whether or not + we have already included to define `struct rusage'. */ +struct rusage; + +/* PID is like waitpid. Other args are like wait3. */ +extern __pid_t wait4 (__pid_t __pid, __WAIT_STATUS __stat_loc, int __options, + struct rusage *__usage) __THROW; +#endif /* Use BSD. */ + + +__END_DECLS + +#endif /* sys/wait.h */ diff --git a/conts/posix/libposix/include/posix/sys/xattr.h b/conts/posix/libposix/include/posix/sys/xattr.h new file mode 100644 index 0000000..2737f90 --- /dev/null +++ b/conts/posix/libposix/include/posix/sys/xattr.h @@ -0,0 +1,104 @@ +/* Copyright (C) 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_XATTR_H +#define _SYS_XATTR_H 1 + +#include +#include + + +__BEGIN_DECLS + +/* The following constants should be used for the fifth parameter of + `*setxattr'. */ +enum +{ + XATTR_CREATE = 1, /* set value, fail if attr already exists. */ +#define XATTR_CREATE XATTR_CREATE + XATTR_REPLACE = 2 /* set value, fail if attr does not exist. */ +#define XATTR_REPLACE XATTR_REPLACE +}; + +/* Set the attribute NAME of the file pointed to by PATH to VALUE (which + is SIZE bytes long). Return 0 on success, -1 for errors. */ +extern int setxattr (__const char *__path, __const char *__name, + __const void *__value, size_t __size, int __flags) + __THROW; + +/* Set the attribute NAME of the file pointed to by PATH to VALUE (which is + SIZE bytes long), not following symlinks for the last pathname component. + Return 0 on success, -1 for errors. */ +extern int lsetxattr (__const char *__path, __const char *__name, + __const void *__value, size_t __size, int __flags) + __THROW; + +/* Set the attribute NAME of the file descriptor FD to VALUE (which is SIZE + bytes long). Return 0 on success, -1 for errors. */ +extern int fsetxattr (int __fd, __const char *__name, __const void *__value, + size_t __size, int __flags) __THROW; + +/* Get the attribute NAME of the file pointed to by PATH to VALUE (which is + SIZE bytes long). Return 0 on success, -1 for errors. */ +extern ssize_t getxattr (__const char *__path, __const char *__name, + void *__value, size_t __size) __THROW; + +/* Get the attribute NAME of the file pointed to by PATH to VALUE (which is + SIZE bytes long), not following symlinks for the last pathname component. + Return 0 on success, -1 for errors. */ +extern ssize_t lgetxattr (__const char *__path, __const char *__name, + void *__value, size_t __size) __THROW; + +/* Get the attribute NAME of the file descriptor FD to VALUE (which is SIZE + bytes long). Return 0 on success, -1 for errors. */ +extern ssize_t fgetxattr (int __fd, __const char *__name, void *__value, + size_t __size) __THROW; + +/* List attributes of the file pointed to by PATH into the user-supplied + buffer LIST (which is SIZE bytes big). Return 0 on success, -1 for + errors. */ +extern ssize_t listxattr (__const char *__path, char *__list, size_t __size) + __THROW; + +/* List attributes of the file pointed to by PATH into the user-supplied + buffer LIST (which is SIZE bytes big), not following symlinks for the + last pathname component. Return 0 on success, -1 for errors. */ +extern ssize_t llistxattr (__const char *__path, char *__list, size_t __size) + __THROW; + +/* List attributes of the file descriptor FD into the user-supplied buffer + LIST (which is SIZE bytes big). Return 0 on success, -1 for errors. */ +extern ssize_t flistxattr (int __fd, char *__list, size_t __size) + __THROW; + +/* Remove the attribute NAME from the file pointed to by PATH. Return 0 + on success, -1 for errors. */ +extern int removexattr (__const char *__path, __const char *__name) __THROW; + +/* Remove the attribute NAME from the file pointed to by PATH, not + following symlinks for the last pathname component. Return 0 on + success, -1 for errors. */ +extern int lremovexattr (__const char *__path, __const char *__name) __THROW; + +/* Remove the attribute NAME from the file descriptor FD. Return 0 on + success, -1 for errors. */ +extern int fremovexattr (int __fd, __const char *__name) __THROW; + +__END_DECLS + +#endif /* sys/xattr.h */ diff --git a/conts/posix/libposix/include/posix/syscall.h b/conts/posix/libposix/include/posix/syscall.h new file mode 100644 index 0000000..4c30578 --- /dev/null +++ b/conts/posix/libposix/include/posix/syscall.h @@ -0,0 +1 @@ +#include diff --git a/conts/posix/libposix/include/posix/sysexits.h b/conts/posix/libposix/include/posix/sysexits.h new file mode 100644 index 0000000..37246b6 --- /dev/null +++ b/conts/posix/libposix/include/posix/sysexits.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 1987, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)sysexits.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYSEXITS_H +#define _SYSEXITS_H 1 + +/* + * SYSEXITS.H -- Exit status codes for system programs. + * + * This include file attempts to categorize possible error + * exit statuses for system programs, notably delivermail + * and the Berkeley network. + * + * Error numbers begin at EX__BASE to reduce the possibility of + * clashing with other exit statuses that random programs may + * already return. The meaning of the codes is approximately + * as follows: + * + * EX_USAGE -- The command was used incorrectly, e.g., with + * the wrong number of arguments, a bad flag, a bad + * syntax in a parameter, or whatever. + * EX_DATAERR -- The input data was incorrect in some way. + * This should only be used for user's data & not + * system files. + * EX_NOINPUT -- An input file (not a system file) did not + * exist or was not readable. This could also include + * errors like "No message" to a mailer (if it cared + * to catch it). + * EX_NOUSER -- The user specified did not exist. This might + * be used for mail addresses or remote logins. + * EX_NOHOST -- The host specified did not exist. This is used + * in mail addresses or network requests. + * EX_UNAVAILABLE -- A service is unavailable. This can occur + * if a support program or file does not exist. This + * can also be used as a catchall message when something + * you wanted to do doesn't work, but you don't know + * why. + * EX_SOFTWARE -- An internal software error has been detected. + * This should be limited to non-operating system related + * errors as possible. + * EX_OSERR -- An operating system error has been detected. + * This is intended to be used for such things as "cannot + * fork", "cannot create pipe", or the like. It includes + * things like getuid returning a user that does not + * exist in the passwd file. + * EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp, + * etc.) does not exist, cannot be opened, or has some + * sort of error (e.g., syntax error). + * EX_CANTCREAT -- A (user specified) output file cannot be + * created. + * EX_IOERR -- An error occurred while doing I/O on some file. + * EX_TEMPFAIL -- temporary failure, indicating something that + * is not really an error. In sendmail, this means + * that a mailer (e.g.) could not create a connection, + * and the request should be reattempted later. + * EX_PROTOCOL -- the remote system returned something that + * was "not possible" during a protocol exchange. + * EX_NOPERM -- You did not have sufficient permission to + * perform the operation. This is not intended for + * file system problems, which should use NOINPUT or + * CANTCREAT, but rather for higher level permissions. + */ + +#define EX_OK 0 /* successful termination */ + +#define EX__BASE 64 /* base value for error messages */ + +#define EX_USAGE 64 /* command line usage error */ +#define EX_DATAERR 65 /* data format error */ +#define EX_NOINPUT 66 /* cannot open input */ +#define EX_NOUSER 67 /* addressee unknown */ +#define EX_NOHOST 68 /* host name unknown */ +#define EX_UNAVAILABLE 69 /* service unavailable */ +#define EX_SOFTWARE 70 /* internal software error */ +#define EX_OSERR 71 /* system error (e.g., can't fork) */ +#define EX_OSFILE 72 /* critical OS file missing */ +#define EX_CANTCREAT 73 /* can't create (user) output file */ +#define EX_IOERR 74 /* input/output error */ +#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */ +#define EX_PROTOCOL 76 /* remote error in protocol */ +#define EX_NOPERM 77 /* permission denied */ +#define EX_CONFIG 78 /* configuration error */ + +#define EX__MAX 78 /* maximum listed value */ + +#endif /* sysexits.h */ diff --git a/conts/posix/libposix/include/posix/syslog.h b/conts/posix/libposix/include/posix/syslog.h new file mode 100644 index 0000000..830b492 --- /dev/null +++ b/conts/posix/libposix/include/posix/syslog.h @@ -0,0 +1 @@ +#include diff --git a/conts/posix/libposix/include/posix/tar.h b/conts/posix/libposix/include/posix/tar.h new file mode 100644 index 0000000..ddfef75 --- /dev/null +++ b/conts/posix/libposix/include/posix/tar.h @@ -0,0 +1,108 @@ +/* Extended tar format from POSIX.1. + Copyright (C) 1992, 1996 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Written by David J. MacKenzie. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _TAR_H +#define _TAR_H 1 + +/* A tar archive consists of 512-byte blocks. + Each file in the archive has a header block followed by 0+ data blocks. + Two blocks of NUL bytes indicate the end of the archive. */ + +/* The fields of header blocks: + All strings are stored as ISO 646 (approximately ASCII) strings. + + Fields are numeric unless otherwise noted below; numbers are ISO 646 + representations of octal numbers, with leading zeros as needed. + + linkname is only valid when typeflag==LNKTYPE. It doesn't use prefix; + files that are links to pathnames >100 chars long can not be stored + in a tar archive. + + If typeflag=={LNKTYPE,SYMTYPE,DIRTYPE} then size must be 0. + + devmajor and devminor are only valid for typeflag=={BLKTYPE,CHRTYPE}. + + chksum contains the sum of all 512 bytes in the header block, + treating each byte as an 8-bit unsigned value and treating the + 8 bytes of chksum as blank characters. + + uname and gname are used in preference to uid and gid, if those + names exist locally. + + Field Name Byte Offset Length in Bytes Field Type + name 0 100 NUL-terminated if NUL fits + mode 100 8 + uid 108 8 + gid 116 8 + size 124 12 + mtime 136 12 + chksum 148 8 + typeflag 156 1 see below + linkname 157 100 NUL-terminated if NUL fits + magic 257 6 must be TMAGIC (NUL term.) + version 263 2 must be TVERSION + uname 265 32 NUL-terminated + gname 297 32 NUL-terminated + devmajor 329 8 + devminor 337 8 + prefix 345 155 NUL-terminated if NUL fits + + If the first character of prefix is '\0', the file name is name; + otherwise, it is prefix/name. Files whose pathnames don't fit in that + length can not be stored in a tar archive. */ + +/* The bits in mode: */ +#define TSUID 04000 +#define TSGID 02000 +#define TSVTX 01000 +#define TUREAD 00400 +#define TUWRITE 00200 +#define TUEXEC 00100 +#define TGREAD 00040 +#define TGWRITE 00020 +#define TGEXEC 00010 +#define TOREAD 00004 +#define TOWRITE 00002 +#define TOEXEC 00001 + +/* The values for typeflag: + Values 'A'-'Z' are reserved for custom implementations. + All other values are reserved for future POSIX.1 revisions. */ + +#define REGTYPE '0' /* Regular file (preferred code). */ +#define AREGTYPE '\0' /* Regular file (alternate code). */ +#define LNKTYPE '1' /* Hard link. */ +#define SYMTYPE '2' /* Symbolic link (hard if not supported). */ +#define CHRTYPE '3' /* Character special. */ +#define BLKTYPE '4' /* Block special. */ +#define DIRTYPE '5' /* Directory. */ +#define FIFOTYPE '6' /* Named pipe. */ +#define CONTTYPE '7' /* Contiguous file */ + /* (regular file if not supported). */ + +/* Contents of magic field and its length. */ +#define TMAGIC "ustar" +#define TMAGLEN 6 + +/* Contents of the version field and its length. */ +#define TVERSION "00" +#define TVERSLEN 2 + +#endif /* tar.h */ diff --git a/conts/posix/libposix/include/posix/termio.h b/conts/posix/libposix/include/posix/termio.h new file mode 100644 index 0000000..0e610f0 --- /dev/null +++ b/conts/posix/libposix/include/posix/termio.h @@ -0,0 +1,6 @@ +/* Compatible for old `struct termio' ioctl interface. + This is obsolete; use the POSIX.1 `struct termios' interface + defined in instead. */ + +#include +#include diff --git a/conts/posix/libposix/include/posix/termios.h b/conts/posix/libposix/include/posix/termios.h new file mode 100644 index 0000000..9698b1f --- /dev/null +++ b/conts/posix/libposix/include/posix/termios.h @@ -0,0 +1,110 @@ +/* Copyright (C) 1991,92,93,94,96,97,98,99, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * POSIX Standard: 7.1-2 General Terminal Interface + */ + +#ifndef _TERMIOS_H +#define _TERMIOS_H 1 + +#include +#ifdef __USE_UNIX98 +/* We need `pid_t'. */ +# include +# ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +# endif +#endif + +__BEGIN_DECLS + +/* Get the system-dependent definitions of `struct termios', `tcflag_t', + `cc_t', `speed_t', and all the macros specifying the flag bits. */ +#include + +#ifdef __USE_BSD +/* Compare a character C to a value VAL from the `c_cc' array in a + `struct termios'. If VAL is _POSIX_VDISABLE, no character can match it. */ +# define CCEQ(val, c) ((c) == (val) && (val) != _POSIX_VDISABLE) +#endif + +/* Return the output baud rate stored in *TERMIOS_P. */ +extern speed_t cfgetospeed (__const struct termios *__termios_p) __THROW; + +/* Return the input baud rate stored in *TERMIOS_P. */ +extern speed_t cfgetispeed (__const struct termios *__termios_p) __THROW; + +/* Set the output baud rate stored in *TERMIOS_P to SPEED. */ +extern int cfsetospeed (struct termios *__termios_p, speed_t __speed) __THROW; + +/* Set the input baud rate stored in *TERMIOS_P to SPEED. */ +extern int cfsetispeed (struct termios *__termios_p, speed_t __speed) __THROW; + +#ifdef __USE_BSD +/* Set both the input and output baud rates in *TERMIOS_OP to SPEED. */ +extern int cfsetspeed (struct termios *__termios_p, speed_t __speed) __THROW; +#endif + + +/* Put the state of FD into *TERMIOS_P. */ +extern int tcgetattr (int __fd, struct termios *__termios_p) __THROW; + +/* Set the state of FD to *TERMIOS_P. + Values for OPTIONAL_ACTIONS (TCSA*) are in . */ +extern int tcsetattr (int __fd, int __optional_actions, + __const struct termios *__termios_p) __THROW; + + +#ifdef __USE_BSD +/* Set *TERMIOS_P to indicate raw mode. */ +extern void cfmakeraw (struct termios *__termios_p) __THROW; +#endif + +/* Send zero bits on FD. */ +extern int tcsendbreak (int __fd, int __duration) __THROW; + +/* Wait for pending output to be written on FD. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int tcdrain (int __fd); + +/* Flush pending data on FD. + Values for QUEUE_SELECTOR (TC{I,O,IO}FLUSH) are in . */ +extern int tcflush (int __fd, int __queue_selector) __THROW; + +/* Suspend or restart transmission on FD. + Values for ACTION (TC[IO]{OFF,ON}) are in . */ +extern int tcflow (int __fd, int __action) __THROW; + + +#ifdef __USE_UNIX98 +/* Get process group ID for session leader for controlling terminal FD. */ +extern __pid_t tcgetsid (int __fd) __THROW; +#endif + + +#ifdef __USE_BSD +# include +#endif + +__END_DECLS + +#endif /* termios.h */ diff --git a/conts/posix/libposix/include/posix/tgmath.h b/conts/posix/libposix/include/posix/tgmath.h new file mode 100644 index 0000000..b146121 --- /dev/null +++ b/conts/posix/libposix/include/posix/tgmath.h @@ -0,0 +1,430 @@ +/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard: 7.22 Type-generic math + */ + +#ifndef _TGMATH_H +#define _TGMATH_H 1 + +/* Include the needed headers. */ +#include +#include + + +/* Since `complex' is currently not really implemented in most C compilers + and if it is implemented, the implementations differ. This makes it + quite difficult to write a generic implementation of this header. We + do not try this for now and instead concentrate only on GNU CC. Once + we have more information support for other compilers might follow. */ + +#if __GNUC_PREREQ(2, 7) + +# ifdef __NO_LONG_DOUBLE_MATH +# define __tgml(fct) fct +# else +# define __tgml(fct) fct ## l +# endif + +/* This is ugly but unless gcc gets appropriate builtins we have to do + something like this. Don't ask how it works. */ + +/* 1 if 'type' is a floating type, 0 if 'type' is an integer type. + Allows for _Bool. Expands to an integer constant expression. */ +# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1)) + +/* The tgmath real type for T, where E is 0 if T is an integer type and + 1 for a floating type. */ +# define __tgmath_real_type_sub(T, E) \ + __typeof__(*(0 ? (__typeof__ (0 ? (double *) 0 : (void *) (E))) 0 \ + : (__typeof__ (0 ? (T *) 0 : (void *) (!(E)))) 0)) + +/* The tgmath real type of EXPR. */ +# define __tgmath_real_type(expr) \ + __tgmath_real_type_sub(__typeof__(expr), __floating_type(__typeof__(expr))) + + +/* We have two kinds of generic macros: to support functions which are + only defined on real valued parameters and those which are defined + for complex functions as well. */ +# define __TGMATH_UNARY_REAL_ONLY(Val, Fct) \ + (__extension__ ({ __tgmath_real_type (Val) __tgmres; \ + if (sizeof (Val) == sizeof (double) \ + || __builtin_classify_type (Val) != 8) \ + __tgmres = Fct (Val); \ + else if (sizeof (Val) == sizeof (float)) \ + __tgmres = Fct##f (Val); \ + else \ + __tgmres = __tgml(Fct) (Val); \ + __tgmres; })) + +# define __TGMATH_BINARY_FIRST_REAL_ONLY(Val1, Val2, Fct) \ + (__extension__ ({ __tgmath_real_type (Val1) __tgmres; \ + if (sizeof (Val1) == sizeof (double) \ + || __builtin_classify_type (Val1) != 8) \ + __tgmres = Fct (Val1, Val2); \ + else if (sizeof (Val1) == sizeof (float)) \ + __tgmres = Fct##f (Val1, Val2); \ + else \ + __tgmres = __tgml(Fct) (Val1, Val2); \ + __tgmres; })) + +# define __TGMATH_BINARY_REAL_ONLY(Val1, Val2, Fct) \ + (__extension__ ({ __tgmath_real_type ((Val1) + (Val2)) __tgmres; \ + if ((sizeof (Val1) > sizeof (double) \ + || sizeof (Val2) > sizeof (double)) \ + && __builtin_classify_type ((Val1) + (Val2)) == 8) \ + __tgmres = __tgml(Fct) (Val1, Val2); \ + else if (sizeof (Val1) == sizeof (double) \ + || sizeof (Val2) == sizeof (double) \ + || __builtin_classify_type (Val1) != 8 \ + || __builtin_classify_type (Val2) != 8) \ + __tgmres = Fct (Val1, Val2); \ + else \ + __tgmres = Fct##f (Val1, Val2); \ + __tgmres; })) + +# define __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY(Val1, Val2, Val3, Fct) \ + (__extension__ ({ __tgmath_real_type ((Val1) + (Val2)) __tgmres; \ + if ((sizeof (Val1) > sizeof (double) \ + || sizeof (Val2) > sizeof (double)) \ + && __builtin_classify_type ((Val1) + (Val2)) == 8) \ + __tgmres = __tgml(Fct) (Val1, Val2, Val3); \ + else if (sizeof (Val1) == sizeof (double) \ + || sizeof (Val2) == sizeof (double) \ + || __builtin_classify_type (Val1) != 8 \ + || __builtin_classify_type (Val2) != 8) \ + __tgmres = Fct (Val1, Val2, Val3); \ + else \ + __tgmres = Fct##f (Val1, Val2, Val3); \ + __tgmres; })) + +# define __TGMATH_TERNARY_REAL_ONLY(Val1, Val2, Val3, Fct) \ + (__extension__ ({ __tgmath_real_type ((Val1) + (Val2) + (Val3)) __tgmres;\ + if ((sizeof (Val1) > sizeof (double) \ + || sizeof (Val2) > sizeof (double) \ + || sizeof (Val3) > sizeof (double)) \ + && __builtin_classify_type ((Val1) + (Val2) \ + + (Val3)) == 8) \ + __tgmres = __tgml(Fct) (Val1, Val2, Val3); \ + else if (sizeof (Val1) == sizeof (double) \ + || sizeof (Val2) == sizeof (double) \ + || sizeof (Val3) == sizeof (double) \ + || __builtin_classify_type (Val1) != 8 \ + || __builtin_classify_type (Val2) != 8 \ + || __builtin_classify_type (Val3) != 8) \ + __tgmres = Fct (Val1, Val2, Val3); \ + else \ + __tgmres = Fct##f (Val1, Val2, Val3); \ + __tgmres; })) + +/* XXX This definition has to be changed as soon as the compiler understands + the imaginary keyword. */ +# define __TGMATH_UNARY_REAL_IMAG(Val, Fct, Cfct) \ + (__extension__ ({ __tgmath_real_type (Val) __tgmres; \ + if (sizeof (__real__ (Val)) > sizeof (double) \ + && __builtin_classify_type (__real__ (Val)) == 8) \ + { \ + if (sizeof (__real__ (Val)) == sizeof (Val)) \ + __tgmres = __tgml(Fct) (Val); \ + else \ + __tgmres = __tgml(Cfct) (Val); \ + } \ + else if (sizeof (__real__ (Val)) == sizeof (double) \ + || __builtin_classify_type (__real__ (Val)) \ + != 8) \ + { \ + if (sizeof (__real__ (Val)) == sizeof (Val)) \ + __tgmres = Fct (Val); \ + else \ + __tgmres = Cfct (Val); \ + } \ + else \ + { \ + if (sizeof (__real__ (Val)) == sizeof (Val)) \ + __tgmres = Fct##f (Val); \ + else \ + __tgmres = Cfct##f (Val); \ + } \ + __tgmres; })) + +/* XXX This definition has to be changed as soon as the compiler understands + the imaginary keyword. */ +# define __TGMATH_UNARY_IMAG_ONLY(Val, Fct) \ + (__extension__ ({ __tgmath_real_type (Val) __tgmres; \ + if (sizeof (Val) == sizeof (__complex__ double) \ + || __builtin_classify_type (__real__ (Val)) != 8) \ + __tgmres = Fct (Val); \ + else if (sizeof (Val) == sizeof (__complex__ float)) \ + __tgmres = Fct##f (Val); \ + else \ + __tgmres = __tgml(Fct) (Val); \ + __tgmres; })) + +/* XXX This definition has to be changed as soon as the compiler understands + the imaginary keyword. */ +# define __TGMATH_BINARY_REAL_IMAG(Val1, Val2, Fct, Cfct) \ + (__extension__ ({ __tgmath_real_type ((Val1) + (Val2)) __tgmres; \ + if ((sizeof (__real__ (Val1)) > sizeof (double) \ + || sizeof (__real__ (Val2)) > sizeof (double)) \ + && __builtin_classify_type (__real__ (Val1) \ + + __real__ (Val2)) \ + == 8) \ + { \ + if (sizeof (__real__ (Val1)) == sizeof (Val1) \ + && sizeof (__real__ (Val2)) == sizeof (Val2)) \ + __tgmres = __tgml(Fct) (Val1, Val2); \ + else \ + __tgmres = __tgml(Cfct) (Val1, Val2); \ + } \ + else if (sizeof (__real__ (Val1)) == sizeof (double) \ + || sizeof (__real__ (Val2)) == sizeof(double) \ + || (__builtin_classify_type (__real__ (Val1)) \ + != 8) \ + || (__builtin_classify_type (__real__ (Val2)) \ + != 8)) \ + { \ + if (sizeof (__real__ (Val1)) == sizeof (Val1) \ + && sizeof (__real__ (Val2)) == sizeof (Val2)) \ + __tgmres = Fct (Val1, Val2); \ + else \ + __tgmres = Cfct (Val1, Val2); \ + } \ + else \ + { \ + if (sizeof (__real__ (Val1)) == sizeof (Val1) \ + && sizeof (__real__ (Val2)) == sizeof (Val2)) \ + __tgmres = Fct##f (Val1, Val2); \ + else \ + __tgmres = Cfct##f (Val1, Val2); \ + } \ + __tgmres; })) +#else +# error "Unsupported compiler; you cannot use " +#endif + + +/* Unary functions defined for real and complex values. */ + + +/* Trigonometric functions. */ + +/* Arc cosine of X. */ +#define acos(Val) __TGMATH_UNARY_REAL_IMAG (Val, acos, cacos) +/* Arc sine of X. */ +#define asin(Val) __TGMATH_UNARY_REAL_IMAG (Val, asin, casin) +/* Arc tangent of X. */ +#define atan(Val) __TGMATH_UNARY_REAL_IMAG (Val, atan, catan) +/* Arc tangent of Y/X. */ +#define atan2(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, atan2) + +/* Cosine of X. */ +#define cos(Val) __TGMATH_UNARY_REAL_IMAG (Val, cos, ccos) +/* Sine of X. */ +#define sin(Val) __TGMATH_UNARY_REAL_IMAG (Val, sin, csin) +/* Tangent of X. */ +#define tan(Val) __TGMATH_UNARY_REAL_IMAG (Val, tan, ctan) + + +/* Hyperbolic functions. */ + +/* Hyperbolic arc cosine of X. */ +#define acosh(Val) __TGMATH_UNARY_REAL_IMAG (Val, acosh, cacosh) +/* Hyperbolic arc sine of X. */ +#define asinh(Val) __TGMATH_UNARY_REAL_IMAG (Val, asinh, casinh) +/* Hyperbolic arc tangent of X. */ +#define atanh(Val) __TGMATH_UNARY_REAL_IMAG (Val, atanh, catanh) + +/* Hyperbolic cosine of X. */ +#define cosh(Val) __TGMATH_UNARY_REAL_IMAG (Val, cosh, ccosh) +/* Hyperbolic sine of X. */ +#define sinh(Val) __TGMATH_UNARY_REAL_IMAG (Val, sinh, csinh) +/* Hyperbolic tangent of X. */ +#define tanh(Val) __TGMATH_UNARY_REAL_IMAG (Val, tanh, ctanh) + + +/* Exponential and logarithmic functions. */ + +/* Exponential function of X. */ +#define exp(Val) __TGMATH_UNARY_REAL_IMAG (Val, exp, cexp) + +/* Break VALUE into a normalized fraction and an integral power of 2. */ +#define frexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, frexp) + +/* X times (two to the EXP power). */ +#define ldexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, ldexp) + +/* Natural logarithm of X. */ +#define log(Val) __TGMATH_UNARY_REAL_IMAG (Val, log, clog) + +/* Base-ten logarithm of X. */ +#ifdef __USE_GNU +# define log10(Val) __TGMATH_UNARY_REAL_IMAG (Val, log10, __clog10) +#else +# define log10(Val) __TGMATH_UNARY_REAL_ONLY (Val, log10) +#endif + +/* Return exp(X) - 1. */ +#define expm1(Val) __TGMATH_UNARY_REAL_ONLY (Val, expm1) + +/* Return log(1 + X). */ +#define log1p(Val) __TGMATH_UNARY_REAL_ONLY (Val, log1p) + +/* Return the base 2 signed integral exponent of X. */ +#define logb(Val) __TGMATH_UNARY_REAL_ONLY (Val, logb) + +/* Compute base-2 exponential of X. */ +#define exp2(Val) __TGMATH_UNARY_REAL_ONLY (Val, exp2) + +/* Compute base-2 logarithm of X. */ +#define log2(Val) __TGMATH_UNARY_REAL_ONLY (Val, log2) + + +/* Power functions. */ + +/* Return X to the Y power. */ +#define pow(Val1, Val2) __TGMATH_BINARY_REAL_IMAG (Val1, Val2, pow, cpow) + +/* Return the square root of X. */ +#define sqrt(Val) __TGMATH_UNARY_REAL_IMAG (Val, sqrt, csqrt) + +/* Return `sqrt(X*X + Y*Y)'. */ +#define hypot(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, hypot) + +/* Return the cube root of X. */ +#define cbrt(Val) __TGMATH_UNARY_REAL_ONLY (Val, cbrt) + + +/* Nearest integer, absolute value, and remainder functions. */ + +/* Smallest integral value not less than X. */ +#define ceil(Val) __TGMATH_UNARY_REAL_ONLY (Val, ceil) + +/* Absolute value of X. */ +#define fabs(Val) __TGMATH_UNARY_REAL_IMAG (Val, fabs, cabs) + +/* Largest integer not greater than X. */ +#define floor(Val) __TGMATH_UNARY_REAL_ONLY (Val, floor) + +/* Floating-point modulo remainder of X/Y. */ +#define fmod(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmod) + +/* Round X to integral valuein floating-point format using current + rounding direction, but do not raise inexact exception. */ +#define nearbyint(Val) __TGMATH_UNARY_REAL_ONLY (Val, nearbyint) + +/* Round X to nearest integral value, rounding halfway cases away from + zero. */ +#define round(Val) __TGMATH_UNARY_REAL_ONLY (Val, round) + +/* Round X to the integral value in floating-point format nearest but + not larger in magnitude. */ +#define trunc(Val) __TGMATH_UNARY_REAL_ONLY (Val, trunc) + +/* Compute remainder of X and Y and put in *QUO a value with sign of x/y + and magnitude congruent `mod 2^n' to the magnitude of the integral + quotient x/y, with n >= 3. */ +#define remquo(Val1, Val2, Val3) \ + __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY (Val1, Val2, Val3, remquo) + +/* Round X to nearest integral value according to current rounding + direction. */ +#define lrint(Val) __TGMATH_UNARY_REAL_ONLY (Val, lrint) +#define llrint(Val) __TGMATH_UNARY_REAL_ONLY (Val, llrint) + +/* Round X to nearest integral value, rounding halfway cases away from + zero. */ +#define lround(Val) __TGMATH_UNARY_REAL_ONLY (Val, lround) +#define llround(Val) __TGMATH_UNARY_REAL_ONLY (Val, llround) + + +/* Return X with its signed changed to Y's. */ +#define copysign(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, copysign) + +/* Error and gamma functions. */ +#define erf(Val) __TGMATH_UNARY_REAL_ONLY (Val, erf) +#define erfc(Val) __TGMATH_UNARY_REAL_ONLY (Val, erfc) +#define tgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, tgamma) +#define lgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, lgamma) + + +/* Return the integer nearest X in the direction of the + prevailing rounding mode. */ +#define rint(Val) __TGMATH_UNARY_REAL_ONLY (Val, rint) + +/* Return X + epsilon if X < Y, X - epsilon if X > Y. */ +#define nextafter(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, nextafter) +#define nexttoward(Val1, Val2) \ + __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, nexttoward) + +/* Return the remainder of integer divison X / Y with infinite precision. */ +#define remainder(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, remainder) + +/* Return X times (2 to the Nth power). */ +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +# define scalb(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, scalb) +#endif + +/* Return X times (2 to the Nth power). */ +#define scalbn(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbn) + +/* Return X times (2 to the Nth power). */ +#define scalbln(Val1, Val2) \ + __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbln) + +/* Return the binary exponent of X, which must be nonzero. */ +#define ilogb(Val) __TGMATH_UNARY_REAL_ONLY (Val, ilogb) + + +/* Return positive difference between X and Y. */ +#define fdim(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fdim) + +/* Return maximum numeric value from X and Y. */ +#define fmax(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmax) + +/* Return minimum numeric value from X and Y. */ +#define fmin(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmin) + + +/* Multiply-add function computed as a ternary operation. */ +#define fma(Val1, Val2, Val3) \ + __TGMATH_TERNARY_REAL_ONLY (Val1, Val2, Val3, fma) + + +/* Absolute value, conjugates, and projection. */ + +/* Argument value of Z. */ +#define carg(Val) __TGMATH_UNARY_IMAG_ONLY (Val, carg) + +/* Complex conjugate of Z. */ +#define conj(Val) __TGMATH_UNARY_IMAG_ONLY (Val, conj) + +/* Projection of Z onto the Riemann sphere. */ +#define cproj(Val) __TGMATH_UNARY_IMAG_ONLY (Val, cproj) + + +/* Decomposing complex values. */ + +/* Imaginary part of Z. */ +#define cimag(Val) __TGMATH_UNARY_IMAG_ONLY (Val, cimag) + +/* Real part of Z. */ +#define creal(Val) __TGMATH_UNARY_IMAG_ONLY (Val, creal) + +#endif /* tgmath.h */ diff --git a/conts/posix/libposix/include/posix/time.h b/conts/posix/libposix/include/posix/time.h new file mode 100644 index 0000000..425b71b --- /dev/null +++ b/conts/posix/libposix/include/posix/time.h @@ -0,0 +1,435 @@ +/* Copyright (C) 1991-1999,2000,2001,2002,2003,2006 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard: 7.23 Date and time + */ + +#ifndef _TIME_H + +#if (! defined __need_time_t && !defined __need_clock_t && \ + ! defined __need_timespec) +# define _TIME_H 1 +# include + +__BEGIN_DECLS + +#endif + +#ifdef _TIME_H +/* Get size_t and NULL from . */ +# define __need_size_t +# define __need_NULL +# include + +/* This defines CLOCKS_PER_SEC, which is the number of processor clock + ticks per second. */ +# include + +/* This is the obsolete POSIX.1-1988 name for the same constant. */ +# if !defined __STRICT_ANSI__ && !defined __USE_XOPEN2K +# ifndef CLK_TCK +# define CLK_TCK CLOCKS_PER_SEC +# endif +# endif + +#endif /* included. */ + +#if !defined __clock_t_defined && (defined _TIME_H || defined __need_clock_t) +# define __clock_t_defined 1 + +# include + +__BEGIN_NAMESPACE_STD +/* Returned by `clock'. */ +typedef __clock_t clock_t; +__END_NAMESPACE_STD +#if defined __USE_XOPEN || defined __USE_POSIX || defined __USE_MISC +__USING_NAMESPACE_STD(clock_t) +#endif + +#endif /* clock_t not defined and or need clock_t. */ +#undef __need_clock_t + +#if !defined __time_t_defined && (defined _TIME_H || defined __need_time_t) +# define __time_t_defined 1 + +# include + +__BEGIN_NAMESPACE_STD +/* Returned by `time'. */ +typedef __time_t time_t; +__END_NAMESPACE_STD +#if defined __USE_POSIX || defined __USE_MISC || defined __USE_SVID +__USING_NAMESPACE_STD(time_t) +#endif + +#endif /* time_t not defined and or need time_t. */ +#undef __need_time_t + +#if !defined __clockid_t_defined && \ + ((defined _TIME_H && defined __USE_POSIX199309) || defined __need_clockid_t) +# define __clockid_t_defined 1 + +# include + +/* Clock ID used in clock and timer functions. */ +typedef __clockid_t clockid_t; + +#endif /* clockid_t not defined and or need clockid_t. */ +#undef __clockid_time_t + +#if !defined __timer_t_defined && \ + ((defined _TIME_H && defined __USE_POSIX199309) || defined __need_timer_t) +# define __timer_t_defined 1 + +# include + +/* Timer ID returned by `timer_create'. */ +typedef __timer_t timer_t; + +#endif /* timer_t not defined and or need timer_t. */ +#undef __need_timer_t + + +#if !defined __timespec_defined && \ + ((defined _TIME_H && \ + (defined __USE_POSIX199309 || defined __USE_MISC)) || \ + defined __need_timespec) +# define __timespec_defined 1 + +# include /* This defines __time_t for us. */ + +/* POSIX.1b structure for a time value. This is like a `struct timeval' but + has nanoseconds instead of microseconds. */ +struct timespec + { + __time_t tv_sec; /* Seconds. */ + long int tv_nsec; /* Nanoseconds. */ + }; + +#endif /* timespec not defined and or need timespec. */ +#undef __need_timespec + + +#ifdef _TIME_H +__BEGIN_NAMESPACE_STD +/* Used by other time functions. */ +struct tm +{ + int tm_sec; /* Seconds. [0-60] (1 leap second) */ + int tm_min; /* Minutes. [0-59] */ + int tm_hour; /* Hours. [0-23] */ + int tm_mday; /* Day. [1-31] */ + int tm_mon; /* Month. [0-11] */ + int tm_year; /* Year - 1900. */ + int tm_wday; /* Day of week. [0-6] */ + int tm_yday; /* Days in year.[0-365] */ + int tm_isdst; /* DST. [-1/0/1]*/ + +#ifdef __UCLIBC_HAS_TM_EXTENSIONS__ +#ifdef __USE_BSD + long int tm_gmtoff; /* Seconds east of UTC. */ + __const char *tm_zone; /* Timezone abbreviation. */ +#else + long int __tm_gmtoff; /* Seconds east of UTC. */ + __const char *__tm_zone; /* Timezone abbreviation. */ +#endif +#endif /* __UCLIBC_HAS_TM_EXTENSIONS__ */ +}; +__END_NAMESPACE_STD +#if defined __USE_XOPEN || defined __USE_POSIX || defined __USE_MISC +__USING_NAMESPACE_STD(tm) +#endif + + +#ifdef __USE_POSIX199309 +/* POSIX.1b structure for timer start values and intervals. */ +struct itimerspec + { + struct timespec it_interval; + struct timespec it_value; + }; + +/* We can use a simple forward declaration. */ +struct sigevent; + +#endif /* POSIX.1b */ + +#ifdef __USE_XOPEN2K +# ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +# endif +#endif + + +__BEGIN_NAMESPACE_STD +/* Time used by the program so far (user time + system time). + The result / CLOCKS_PER_SECOND is program time in seconds. */ +extern clock_t clock (void) __THROW; + +/* Return the current time and put it in *TIMER if TIMER is not NULL. */ +extern time_t time (time_t *__timer) __THROW; + +#ifdef __UCLIBC_HAS_FLOATS__ +/* Return the difference between TIME1 and TIME0. */ +extern double difftime (time_t __time1, time_t __time0) + __THROW __attribute__ ((__const__)); +#endif /* __UCLIBC_HAS_FLOATS__ */ + +/* Return the `time_t' representation of TP and normalize TP. */ +extern time_t mktime (struct tm *__tp) __THROW; + + +/* Format TP into S according to FORMAT. + Write no more than MAXSIZE characters and return the number + of characters written, or 0 if it would exceed MAXSIZE. */ +extern size_t strftime (char *__restrict __s, size_t __maxsize, + __const char *__restrict __format, + __const struct tm *__restrict __tp) __THROW; +__END_NAMESPACE_STD + +# ifdef __USE_XOPEN +/* Parse S according to FORMAT and store binary time information in TP. + The return value is a pointer to the first unparsed character in S. */ +extern char *strptime (__const char *__restrict __s, + __const char *__restrict __fmt, struct tm *__tp) + __THROW; +# endif + +#ifdef __UCLIBC_HAS_XLOCALE__ +# ifdef __USE_GNU +/* Similar to the two functions above but take the information from + the provided locale and not the global locale. */ +# include + +extern size_t strftime_l (char *__restrict __s, size_t __maxsize, + __const char *__restrict __format, + __const struct tm *__restrict __tp, + __locale_t __loc) __THROW; + +extern char *strptime_l (__const char *__restrict __s, + __const char *__restrict __fmt, struct tm *__tp, + __locale_t __loc) __THROW; +# endif +#endif + + +__BEGIN_NAMESPACE_STD +/* Return the `struct tm' representation of *TIMER + in Universal Coordinated Time (aka Greenwich Mean Time). */ +extern struct tm *gmtime (__const time_t *__timer) __THROW; + +/* Return the `struct tm' representation + of *TIMER in the local timezone. */ +extern struct tm *localtime (__const time_t *__timer) __THROW; +__END_NAMESPACE_STD + +# if defined __USE_POSIX || defined __USE_MISC +/* Return the `struct tm' representation of *TIMER in UTC, + using *TP to store the result. */ +extern struct tm *gmtime_r (__const time_t *__restrict __timer, + struct tm *__restrict __tp) __THROW; + +/* Return the `struct tm' representation of *TIMER in local time, + using *TP to store the result. */ +extern struct tm *localtime_r (__const time_t *__restrict __timer, + struct tm *__restrict __tp) __THROW; +# endif /* POSIX or misc */ + +__BEGIN_NAMESPACE_STD +/* Return a string of the form "Day Mon dd hh:mm:ss yyyy\n" + that is the representation of TP in this format. */ +extern char *asctime (__const struct tm *__tp) __THROW; + +/* Equivalent to `asctime (localtime (timer))'. */ +extern char *ctime (__const time_t *__timer) __THROW; +__END_NAMESPACE_STD + +# if defined __USE_POSIX || defined __USE_MISC +/* Reentrant versions of the above functions. */ + +/* Return in BUF a string of the form "Day Mon dd hh:mm:ss yyyy\n" + that is the representation of TP in this format. */ +extern char *asctime_r (__const struct tm *__restrict __tp, + char *__restrict __buf) __THROW; + +/* Equivalent to `asctime_r (localtime_r (timer, *TMP*), buf)'. */ +extern char *ctime_r (__const time_t *__restrict __timer, + char *__restrict __buf) __THROW; +# endif /* POSIX or misc */ + + +/* Defined in localtime.c. */ +#ifdef __UCLIBC_MJN3_ONLY__ +#warning "mjn3 FIXME: __tzname, __daylight, and __timezone have a prototype but are not defined." +extern char *__tzname[2]; /* Current timezone names. */ +extern int __daylight; /* If daylight-saving time is ever in use. */ +extern long int __timezone; /* Seconds west of UTC. */ +#endif /* __UCLIBC_MJN3_ONLY__ */ + + +# ifdef __USE_POSIX +/* Same as above. */ +extern char *tzname[2]; + +/* Set time conversion information from the TZ environment variable. + If TZ is not defined, a locale-dependent default is used. */ +extern void tzset (void) __THROW; +# endif + +# if defined __USE_SVID || defined __USE_XOPEN +extern int daylight; +extern long int timezone; +# endif + +# ifdef __USE_SVID +/* Set the system time to *WHEN. + This call is restricted to the superuser. */ +extern int stime (__const time_t *__when) __THROW; +# endif + + +/* Nonzero if YEAR is a leap year (every 4 years, + except every 100th isn't, and every 400th is). */ +# define __isleap(year) \ + ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) + + +# ifdef __USE_MISC +/* Miscellaneous functions many Unices inherited from the public domain + localtime package. These are included only for compatibility. */ + +/* Like `mktime', but for TP represents Universal Time, not local time. */ +extern time_t timegm (struct tm *__tp) __THROW; + +/* Another name for `mktime'. */ +extern time_t timelocal (struct tm *__tp) __THROW; + +/* Return the number of days in YEAR. */ +extern int dysize (int __year) __THROW __attribute__ ((__const__)); +# endif + + +# ifdef __USE_POSIX199309 +/* Pause execution for a number of nanoseconds. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int nanosleep (__const struct timespec *__requested_time, + struct timespec *__remaining); + + +/* Get resolution of clock CLOCK_ID. */ +extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __THROW; + +/* Get current value of clock CLOCK_ID and store it in TP. */ +extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW; + +/* Set clock CLOCK_ID to value TP. */ +extern int clock_settime (clockid_t __clock_id, __const struct timespec *__tp) + __THROW; + +#ifdef __UCLIBC_MJN3_ONLY__ +#warning "mjn3 FIXME: a bunch of unimplemented function prototypes." +# ifdef __USE_XOPEN2K +/* High-resolution sleep with the specified clock. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int clock_nanosleep (clockid_t __clock_id, int __flags, + __const struct timespec *__req, + struct timespec *__rem); + +/* Return clock ID for CPU-time clock. */ +extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) __THROW; +# endif +#endif /* __UCLIBC_MJN3_ONLY__ */ + + +/* Create new per-process timer using CLOCK_ID. */ +extern int timer_create (clockid_t __clock_id, + struct sigevent *__restrict __evp, + timer_t *__restrict __timerid) __THROW; + +/* Delete timer TIMERID. */ +extern int timer_delete (timer_t __timerid) __THROW; + +/* Set timer TIMERID to VALUE, returning old value in OVLAUE. */ +extern int timer_settime (timer_t __timerid, int __flags, + __const struct itimerspec *__restrict __value, + struct itimerspec *__restrict __ovalue) __THROW; + +/* Get current value of timer TIMERID and store it in VLAUE. */ +extern int timer_gettime (timer_t __timerid, struct itimerspec *__value) + __THROW; + +/* Get expiration overrun for timer TIMERID. */ +extern int timer_getoverrun (timer_t __timerid) __THROW; +# endif + + +#ifdef __UCLIBC_MJN3_ONLY__ +#warning "mjn3 FIXME: a bunch of unimplemented function prototypes." +# ifdef __USE_XOPEN_EXTENDED +/* Set to one of the following values to indicate an error. + 1 the DATEMSK environment variable is null or undefined, + 2 the template file cannot be opened for reading, + 3 failed to get file status information, + 4 the template file is not a regular file, + 5 an error is encountered while reading the template file, + 6 memory allication failed (not enough memory available), + 7 there is no line in the template that matches the input, + 8 invalid input specification Example: February 31 or a time is + specified that can not be represented in a time_t (representing + the time in seconds since 00:00:00 UTC, January 1, 1970) */ +extern int getdate_err; + +/* Parse the given string as a date specification and return a value + representing the value. The templates from the file identified by + the environment variable DATEMSK are used. In case of an error + `getdate_err' is set. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +extern struct tm *getdate (__const char *__string); +# endif + +# ifdef __USE_GNU +/* Since `getdate' is not reentrant because of the use of `getdate_err' + and the static buffer to return the result in, we provide a thread-safe + variant. The functionality is the same. The result is returned in + the buffer pointed to by RESBUFP and in case of an error the return + value is != 0 with the same values as given above for `getdate_err'. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int getdate_r (__const char *__restrict __string, + struct tm *__restrict __resbufp); +# endif +#endif /* __UCLIBC_MJN3_ONLY__ */ + +__END_DECLS + +#endif /* included. */ + +#endif /* not already included. */ diff --git a/conts/posix/libposix/include/posix/ttyent.h b/conts/posix/libposix/include/posix/ttyent.h new file mode 100644 index 0000000..0b221bc --- /dev/null +++ b/conts/posix/libposix/include/posix/ttyent.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ttyent.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _TTYENT_H +#define _TTYENT_H 1 + +#include + +#define _PATH_TTYS "/etc/ttys" + +#define _TTYS_OFF "off" +#define _TTYS_ON "on" +#define _TTYS_SECURE "secure" +#define _TTYS_WINDOW "window" + +struct ttyent { + char *ty_name; /* terminal device name */ + char *ty_getty; /* command to execute, usually getty */ + char *ty_type; /* terminal type for termcap */ +#define TTY_ON 0x01 /* enable logins (start ty_getty program) */ +#define TTY_SECURE 0x02 /* allow uid of 0 to login */ + int ty_status; /* status flags */ + char *ty_window; /* command to start up window manager */ + char *ty_comment; /* comment field */ +}; + + +__BEGIN_DECLS + +extern struct ttyent *getttyent (void) __THROW; +extern struct ttyent *getttynam (__const char *__tty) __THROW; +extern int setttyent (void) __THROW; +extern int endttyent (void) __THROW; + +__END_DECLS + +#endif /* ttyent.h */ diff --git a/conts/posix/libposix/include/posix/ucontext.h b/conts/posix/libposix/include/posix/ucontext.h new file mode 100644 index 0000000..5bd4645 --- /dev/null +++ b/conts/posix/libposix/include/posix/ucontext.h @@ -0,0 +1,32 @@ +/* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _UCONTEXT_H +#define _UCONTEXT_H 1 + +#include + +/* Get machine dependent definition of data structures. */ +#include + +/* The System V ABI user-level context switching support functions + * are marked obsolescent by SuSv3, and are not implemented by + * uClibc. This header is therefore empty. */ + + +#endif /* ucontext.h */ diff --git a/conts/posix/libposix/include/posix/ulimit.h b/conts/posix/libposix/include/posix/ulimit.h new file mode 100644 index 0000000..93b5f37 --- /dev/null +++ b/conts/posix/libposix/include/posix/ulimit.h @@ -0,0 +1,48 @@ +/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _ULIMIT_H +#define _ULIMIT_H 1 + +#include + +/* Constants used as the first parameter for `ulimit'. They denote limits + which can be set or retrieved using this function. */ +enum +{ + UL_GETFSIZE = 1, /* Return limit on the size of a file, + in units of 512 bytes. */ +#define UL_GETFSIZE UL_GETFSIZE + UL_SETFSIZE, /* Set limit on the size of a file to + second argument. */ +#define UL_SETFSIZE UL_SETFSIZE + __UL_GETMAXBRK, /* Return the maximum possible address + of the data segment. */ + __UL_GETOPENMAX /* Return the maximum number of files + that the calling process can open.*/ +}; + + +__BEGIN_DECLS + +/* Control process limits according to CMD. */ +extern long int ulimit (int __cmd, ...) __THROW; + +__END_DECLS + +#endif /* ulimit.h */ diff --git a/conts/posix/libposix/include/posix/unistd.h b/conts/posix/libposix/include/posix/unistd.h new file mode 100644 index 0000000..94d2fd8 --- /dev/null +++ b/conts/posix/libposix/include/posix/unistd.h @@ -0,0 +1,1116 @@ +/* Copyright (C) 1991-2002,2003,2004,2005,2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * POSIX Standard: 2.10 Symbolic Constants + */ + +#ifndef _UNISTD_H +#define _UNISTD_H 1 + +#include + +__BEGIN_DECLS + +/* These may be used to determine what facilities are present at compile time. + Their values can be obtained at run time from `sysconf'. */ + +/* POSIX Standard approved as ISO/IEC 9945-1 as of December 2001. */ +#define _POSIX_VERSION 200112L + +/* These are not #ifdef __USE_POSIX2 because they are + in the theoretically application-owned namespace. */ + +/* The utilities on GNU systems also correspond to this version. */ +#define _POSIX2_VERSION 200112L + +/* If defined, the implementation supports the + C Language Bindings Option. */ +#define _POSIX2_C_BIND 200112L + +/* If defined, the implementation supports the + C Language Development Utilities Option. */ +#define _POSIX2_C_DEV 200112L + +/* If defined, the implementation supports the + Software Development Utilities Option. */ +#define _POSIX2_SW_DEV 200112L + +/* If defined, the implementation supports the + creation of locales with the localedef utility. */ +#define _POSIX2_LOCALEDEF 200112L + +/* X/Open version number to which the library conforms. It is selectable. */ +#ifdef __USE_UNIX98 +# define _XOPEN_VERSION 500 +#else +# define _XOPEN_VERSION 4 +#endif + +/* Commands and utilities from XPG4 are available. */ +#define _XOPEN_XCU_VERSION 4 + +/* We are compatible with the old published standards as well. */ +#define _XOPEN_XPG2 1 +#define _XOPEN_XPG3 1 +#define _XOPEN_XPG4 1 + +/* The X/Open Unix extensions are available. */ +#define _XOPEN_UNIX 1 + +/* Encryption is present. */ +#define _XOPEN_CRYPT 1 + +/* The enhanced internationalization capabilities according to XPG4.2 + are present. */ +#define _XOPEN_ENH_I18N 1 + +/* The legacy interfaces are also available. */ +#define _XOPEN_LEGACY 1 + + +/* Get values of POSIX options: + + If these symbols are defined, the corresponding features are + always available. If not, they may be available sometimes. + The current values can be obtained with `sysconf'. + + _POSIX_JOB_CONTROL Job control is supported. + _POSIX_SAVED_IDS Processes have a saved set-user-ID + and a saved set-group-ID. + _POSIX_REALTIME_SIGNALS Real-time, queued signals are supported. + _POSIX_PRIORITY_SCHEDULING Priority scheduling is supported. + _POSIX_TIMERS POSIX.4 clocks and timers are supported. + _POSIX_ASYNCHRONOUS_IO Asynchronous I/O is supported. + _POSIX_PRIORITIZED_IO Prioritized asynchronous I/O is supported. + _POSIX_SYNCHRONIZED_IO Synchronizing file data is supported. + _POSIX_FSYNC The fsync function is present. + _POSIX_MAPPED_FILES Mapping of files to memory is supported. + _POSIX_MEMLOCK Locking of all memory is supported. + _POSIX_MEMLOCK_RANGE Locking of ranges of memory is supported. + _POSIX_MEMORY_PROTECTION Setting of memory protections is supported. + _POSIX_MESSAGE_PASSING POSIX.4 message queues are supported. + _POSIX_SEMAPHORES POSIX.4 counting semaphores are supported. + _POSIX_SHARED_MEMORY_OBJECTS POSIX.4 shared memory objects are supported. + _POSIX_THREADS POSIX.1c pthreads are supported. + _POSIX_THREAD_ATTR_STACKADDR Thread stack address attribute option supported. + _POSIX_THREAD_ATTR_STACKSIZE Thread stack size attribute option supported. + _POSIX_THREAD_SAFE_FUNCTIONS Thread-safe functions are supported. + _POSIX_THREAD_PRIORITY_SCHEDULING + POSIX.1c thread execution scheduling supported. + _POSIX_THREAD_PRIO_INHERIT Thread priority inheritance option supported. + _POSIX_THREAD_PRIO_PROTECT Thread priority protection option supported. + _POSIX_THREAD_PROCESS_SHARED Process-shared synchronization supported. + _POSIX_PII Protocol-independent interfaces are supported. + _POSIX_PII_XTI XTI protocol-indep. interfaces are supported. + _POSIX_PII_SOCKET Socket protocol-indep. interfaces are supported. + _POSIX_PII_INTERNET Internet family of protocols supported. + _POSIX_PII_INTERNET_STREAM Connection-mode Internet protocol supported. + _POSIX_PII_INTERNET_DGRAM Connectionless Internet protocol supported. + _POSIX_PII_OSI ISO/OSI family of protocols supported. + _POSIX_PII_OSI_COTS Connection-mode ISO/OSI service supported. + _POSIX_PII_OSI_CLTS Connectionless ISO/OSI service supported. + _POSIX_POLL Implementation supports `poll' function. + _POSIX_SELECT Implementation supports `select' and `pselect'. + + _XOPEN_REALTIME X/Open realtime support is available. + _XOPEN_REALTIME_THREADS X/Open realtime thread support is available. + _XOPEN_SHM Shared memory interface according to XPG4.2. + + _XBS5_ILP32_OFF32 Implementation provides environment with 32-bit + int, long, pointer, and off_t types. + _XBS5_ILP32_OFFBIG Implementation provides environment with 32-bit + int, long, and pointer and off_t with at least + 64 bits. + _XBS5_LP64_OFF64 Implementation provides environment with 32-bit + int, and 64-bit long, pointer, and off_t types. + _XBS5_LPBIG_OFFBIG Implementation provides environment with at + least 32 bits int and long, pointer, and off_t + with at least 64 bits. + + If any of these symbols is defined as -1, the corresponding option is not + true for any file. If any is defined as other than -1, the corresponding + option is true for all files. If a symbol is not defined at all, the value + for a specific file can be obtained from `pathconf' and `fpathconf'. + + _POSIX_CHOWN_RESTRICTED Only the super user can use `chown' to change + the owner of a file. `chown' can only be used + to change the group ID of a file to a group of + which the calling process is a member. + _POSIX_NO_TRUNC Pathname components longer than + NAME_MAX generate an error. + _POSIX_VDISABLE If defined, if the value of an element of the + `c_cc' member of `struct termios' is + _POSIX_VDISABLE, no character will have the + effect associated with that element. + _POSIX_SYNC_IO Synchronous I/O may be performed. + _POSIX_ASYNC_IO Asynchronous I/O may be performed. + _POSIX_PRIO_IO Prioritized Asynchronous I/O may be performed. + + Support for the Large File Support interface is not generally available. + If it is available the following constants are defined to one. + _LFS64_LARGEFILE Low-level I/O supports large files. + _LFS64_STDIO Standard I/O supports large files. + */ + +#include + +/* Get the environment definitions from Unix98. */ +#ifdef __USE_UNIX98 +# include +#endif + +/* Standard file descriptors. */ +#define STDIN_FILENO 0 /* Standard input. */ +#define STDOUT_FILENO 1 /* Standard output. */ +#define STDERR_FILENO 2 /* Standard error output. */ + + +/* All functions that are not declared anywhere else. */ + +#include + +#ifndef __ssize_t_defined +typedef __ssize_t ssize_t; +# define __ssize_t_defined +#endif + +#define __need_size_t +#define __need_NULL +#include + +#if defined __USE_XOPEN || defined __USE_XOPEN2K +/* The Single Unix specification says that some more types are + available here. */ +# ifndef __gid_t_defined +typedef __gid_t gid_t; +# define __gid_t_defined +# endif + +# ifndef __uid_t_defined +typedef __uid_t uid_t; +# define __uid_t_defined +# endif + +# ifndef __off_t_defined +# ifndef __USE_FILE_OFFSET64 +typedef __off_t off_t; +# else +typedef __off64_t off_t; +# endif +# define __off_t_defined +# endif +# if defined __USE_LARGEFILE64 && !defined __off64_t_defined +typedef __off64_t off64_t; +# define __off64_t_defined +# endif + +# ifndef __useconds_t_defined +typedef __useconds_t useconds_t; +# define __useconds_t_defined +# endif + +# ifndef __pid_t_defined +typedef __pid_t pid_t; +# define __pid_t_defined +# endif +#endif /* X/Open */ + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED +# ifndef __intptr_t_defined +typedef __intptr_t intptr_t; +# define __intptr_t_defined +# endif +#endif + +#if defined __USE_BSD || defined __USE_XOPEN +# ifndef __socklen_t_defined +typedef __socklen_t socklen_t; +# define __socklen_t_defined +# endif +#endif + +/* Values for the second argument to access. + These may be OR'd together. */ +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +#define X_OK 1 /* Test for execute permission. */ +#define F_OK 0 /* Test for existence. */ + +/* Test for access to NAME using the real UID and real GID. */ +extern int access (__const char *__name, int __type) __THROW __nonnull ((1)); + +#if 0 /*def __USE_GNU*/ +/* Test for access to NAME using the effective UID and GID + (as normal file operations use). */ +extern int euidaccess (__const char *__name, int __type) + __THROW __nonnull ((1)); + +/* An alias for `euidaccess', used by some other systems. */ +extern int eaccess (__const char *__name, int __type) + __THROW __nonnull ((1)); +#endif + +#ifdef __USE_ATFILE +/* Test for access to FILE relative to the directory FD is open on. + If AT_EACCESS is set in FLAG, then use effective IDs like `eaccess', + otherwise use real IDs like `access'. */ +extern int faccessat (int __fd, __const char *__file, int __type, int __flag) + __THROW __nonnull ((2)) __wur; +#endif /* Use GNU. */ + + +/* Values for the WHENCE argument to lseek. */ +#ifndef _STDIO_H /* has the same definitions. */ +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +#endif +#ifndef SEEK_CUR +# define SEEK_CUR 1 /* Seek from current position. */ +#endif +#ifndef SEEK_END +# define SEEK_END 2 /* Seek from end of file. */ +#endif +#endif + +#if defined __USE_BSD && !defined L_SET +/* Old BSD names for the same constants; just for compatibility. */ +# define L_SET SEEK_SET +# define L_INCR SEEK_CUR +# define L_XTND SEEK_END +#endif + + +/* Move FD's file position to OFFSET bytes from the + beginning of the file (if WHENCE is SEEK_SET), + the current position (if WHENCE is SEEK_CUR), + or the end of the file (if WHENCE is SEEK_END). + Return the new file position. */ +#ifndef __USE_FILE_OFFSET64 +extern __off_t lseek (int __fd, __off_t __offset, int __whence) __THROW; +#else +# ifdef __REDIRECT_NTH +extern __off64_t __REDIRECT_NTH (lseek, + (int __fd, __off64_t __offset, int __whence), + lseek64); +# else +# define lseek lseek64 +# endif +#endif +#ifdef __USE_LARGEFILE64 +extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence) + __THROW; +#endif + +/* Close the file descriptor FD. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int close (int __fd); + +/* Read NBYTES into BUF from FD. Return the + number read, -1 for errors or 0 for EOF. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur; + +/* Write N bytes of BUF to FD. Return the number written, or -1. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t write (int __fd, __const void *__buf, size_t __n) __wur; + +#ifdef __USE_UNIX98 +# ifndef __USE_FILE_OFFSET64 +/* Read NBYTES into BUF from FD at the given position OFFSET without + changing the file pointer. Return the number read, -1 for errors + or 0 for EOF. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t pread (int __fd, void *__buf, size_t __nbytes, + __off_t __offset) __wur; + +/* Write N bytes of BUF to FD at the given position OFFSET without + changing the file pointer. Return the number written, or -1. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t pwrite (int __fd, __const void *__buf, size_t __n, + __off_t __offset) __wur; +# else +# ifdef __REDIRECT +extern ssize_t __REDIRECT (pread, (int __fd, void *__buf, size_t __nbytes, + __off64_t __offset), + pread64) __wur; +extern ssize_t __REDIRECT (pwrite, (int __fd, __const void *__buf, + size_t __nbytes, __off64_t __offset), + pwrite64) __wur; +# else +# define pread pread64 +# define pwrite pwrite64 +# endif +# endif + +# ifdef __USE_LARGEFILE64 +/* Read NBYTES into BUF from FD at the given position OFFSET without + changing the file pointer. Return the number read, -1 for errors + or 0 for EOF. */ +extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes, + __off64_t __offset) __wur; +/* Write N bytes of BUF to FD at the given position OFFSET without + changing the file pointer. Return the number written, or -1. */ +extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n, + __off64_t __offset) __wur; +# endif +#endif + +/* Create a one-way communication channel (pipe). + If successful, two file descriptors are stored in PIPEDES; + bytes written on PIPEDES[1] can be read from PIPEDES[0]. + Returns 0 if successful, -1 if not. */ +extern int pipe (int __pipedes[2]) __THROW __wur; + +/* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM. + If SECONDS is zero, any currently scheduled alarm will be cancelled. + The function returns the number of seconds remaining until the last + alarm scheduled would have signaled, or zero if there wasn't one. + There is no return value to indicate an error, but you can set `errno' + to 0 and check its value after calling `alarm', and this might tell you. + The signal may come late due to processor scheduling. */ +extern unsigned int alarm (unsigned int __seconds) __THROW; + +/* Make the process sleep for SECONDS seconds, or until a signal arrives + and is not ignored. The function returns the number of seconds less + than SECONDS which it actually slept (thus zero if it slept the full time). + If a signal handler does a `longjmp' or modifies the handling of the + SIGALRM signal while inside `sleep' call, the handling of the SIGALRM + signal afterwards is undefined. There is no return value to indicate + error, but if `sleep' returns SECONDS, it probably didn't work. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern unsigned int sleep (unsigned int __seconds); + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED +/* Set an alarm to go off (generating a SIGALRM signal) in VALUE + microseconds. If INTERVAL is nonzero, when the alarm goes off, the + timer is reset to go off every INTERVAL microseconds thereafter. + Returns the number of microseconds remaining before the alarm. */ +extern __useconds_t ualarm (__useconds_t __value, __useconds_t __interval) + __THROW; + +/* Sleep USECONDS microseconds, or until a signal arrives that is not blocked + or ignored. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int usleep (__useconds_t __useconds); +#endif + + +/* Suspend the process until a signal arrives. + This always returns -1 and sets `errno' to EINTR. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int pause (void); + + +/* Change the owner and group of FILE. */ +extern int chown (__const char *__file, __uid_t __owner, __gid_t __group) + __THROW __nonnull ((1)) __wur; + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED +/* Change the owner and group of the file that FD is open on. */ +extern int fchown (int __fd, __uid_t __owner, __gid_t __group) __THROW __wur; + + +/* Change owner and group of FILE, if it is a symbolic + link the ownership of the symbolic link is changed. */ +extern int lchown (__const char *__file, __uid_t __owner, __gid_t __group) + __THROW __nonnull ((1)) __wur; + +#endif /* Use BSD || X/Open Unix. */ + +#ifdef __USE_ATFILE +/* Change the owner and group of FILE relative to the directory FD is open + on. */ +extern int fchownat (int __fd, __const char *__file, __uid_t __owner, + __gid_t __group, int __flag) + __THROW __nonnull ((2)) __wur; +#endif /* Use GNU. */ + +/* Change the process's working directory to PATH. */ +extern int chdir (__const char *__path) __THROW __nonnull ((1)) __wur; + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED +/* Change the process's working directory to the one FD is open on. */ +extern int fchdir (int __fd) __THROW __wur; +#endif + +/* Get the pathname of the current working directory, + and put it in SIZE bytes of BUF. Returns NULL if the + directory couldn't be determined or SIZE was too small. + If successful, returns BUF. In GNU, if BUF is NULL, + an array is allocated with `malloc'; the array is SIZE + bytes long, unless SIZE == 0, in which case it is as + big as necessary. */ +extern char *getcwd (char *__buf, size_t __size) __THROW __wur; + +#ifdef __USE_GNU +/* Return a malloc'd string containing the current directory name. + If the environment variable `PWD' is set, and its value is correct, + that value is used. */ +extern char *get_current_dir_name (void) __THROW; +#endif + +#if 0 /*defined __USE_BSD || defined __USE_XOPEN_EXTENDED*/ +/* Put the absolute pathname of the current working directory in BUF. + If successful, return BUF. If not, put an error message in + BUF and return NULL. BUF should be at least PATH_MAX bytes long. */ +extern char *getwd (char *__buf) + __THROW __nonnull ((1)) __attribute_deprecated__ __wur; +#endif + + +/* Duplicate FD, returning a new file descriptor on the same file. */ +extern int dup (int __fd) __THROW __wur; + +/* Duplicate FD to FD2, closing FD2 and making it open on the same file. */ +extern int dup2 (int __fd, int __fd2) __THROW; + +/* NULL-terminated array of "NAME=VALUE" environment variables. */ +extern char **__environ; +#ifdef __USE_GNU +extern char **environ; +#endif + + +/* Replace the current process, executing PATH with arguments ARGV and + environment ENVP. ARGV and ENVP are terminated by NULL pointers. */ +extern int execve (__const char *__path, char *__const __argv[], + char *__const __envp[]) __THROW __nonnull ((1)); + +#if 0 /*def __USE_GNU*/ +/* Execute the file FD refers to, overlaying the running program image. + ARGV and ENVP are passed to the new program, as for `execve'. */ +extern int fexecve (int __fd, char *__const __argv[], char *__const __envp[]) + __THROW; +#endif + + +/* Execute PATH with arguments ARGV and environment from `environ'. */ +extern int execv (__const char *__path, char *__const __argv[]) + __THROW __nonnull ((1)); + +/* Execute PATH with all arguments after PATH until a NULL pointer, + and the argument after that for environment. */ +extern int execle (__const char *__path, __const char *__arg, ...) + __THROW __nonnull ((1)); + +/* Execute PATH with all arguments after PATH until + a NULL pointer and environment from `environ'. */ +extern int execl (__const char *__path, __const char *__arg, ...) + __THROW __nonnull ((1)); + +/* Execute FILE, searching in the `PATH' environment variable if it contains + no slashes, with arguments ARGV and environment from `environ'. */ +extern int execvp (__const char *__file, char *__const __argv[]) + __THROW __nonnull ((1)); + +/* Execute FILE, searching in the `PATH' environment variable if + it contains no slashes, with all arguments after FILE until a + NULL pointer and environment from `environ'. */ +extern int execlp (__const char *__file, __const char *__arg, ...) + __THROW __nonnull ((1)); + + +#if defined __USE_MISC || defined __USE_XOPEN +/* Add INC to priority of the current process. */ +extern int nice (int __inc) __THROW __wur; +#endif + + +/* Terminate program execution with the low-order 8 bits of STATUS. */ +extern void _exit (int __status) __attribute__ ((__noreturn__)); + + +/* Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf'; + the `_SC_*' symbols for the NAME argument to `sysconf'; + and the `_CS_*' symbols for the NAME argument to `confstr'. */ +#include + +/* Get file-specific configuration information about PATH. */ +extern long int pathconf (__const char *__path, int __name) + __THROW __nonnull ((1)); + +/* Get file-specific configuration about descriptor FD. */ +extern long int fpathconf (int __fd, int __name) __THROW; + +/* Get the value of the system variable NAME. */ +extern long int sysconf (int __name) __THROW; + +#ifdef __USE_POSIX2 +/* Get the value of the string-valued system variable NAME. */ +extern size_t confstr (int __name, char *__buf, size_t __len) __THROW; +#endif + + +/* Get the process ID of the calling process. */ +extern __pid_t getpid (void) __THROW; + +/* Get the process ID of the calling process's parent. */ +extern __pid_t getppid (void) __THROW; + +/* Get the process group ID of the calling process. + This function is different on old BSD. */ +#ifndef __FAVOR_BSD +extern __pid_t getpgrp (void) __THROW; +#else +# ifdef __REDIRECT_NTH +extern __pid_t __REDIRECT_NTH (getpgrp, (__pid_t __pid), __getpgid); +# else +# define getpgrp __getpgid +# endif +#endif + +/* Get the process group ID of process PID. */ +extern __pid_t __getpgid (__pid_t __pid) __THROW; +#ifdef __USE_XOPEN_EXTENDED +extern __pid_t getpgid (__pid_t __pid) __THROW; +#endif + + +/* Set the process group ID of the process matching PID to PGID. + If PID is zero, the current process's process group ID is set. + If PGID is zero, the process ID of the process is used. */ +extern int setpgid (__pid_t __pid, __pid_t __pgid) __THROW; + +#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED +/* Both System V and BSD have `setpgrp' functions, but with different + calling conventions. The BSD function is the same as POSIX.1 `setpgid' + (above). The System V function takes no arguments and puts the calling + process in its on group like `setpgid (0, 0)'. + + New programs should always use `setpgid' instead. + + The default in GNU is to provide the System V function. The BSD + function is available under -D_BSD_SOURCE. */ + +# ifndef __FAVOR_BSD + +/* Set the process group ID of the calling process to its own PID. + This is exactly the same as `setpgid (0, 0)'. */ +extern int setpgrp (void) __THROW; + +# else + +/* Another name for `setpgid' (above). */ +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (setpgrp, (__pid_t __pid, __pid_t __pgrp), setpgid); +# else +# define setpgrp setpgid +# endif + +# endif /* Favor BSD. */ +#endif /* Use SVID or BSD. */ + +/* Create a new session with the calling process as its leader. + The process group IDs of the session and the calling process + are set to the process ID of the calling process, which is returned. */ +extern __pid_t setsid (void) __THROW; + +#ifdef __USE_XOPEN_EXTENDED +/* Return the session ID of the given process. */ +extern __pid_t getsid (__pid_t __pid) __THROW; +#endif + +/* Get the real user ID of the calling process. */ +extern __uid_t getuid (void) __THROW; + +/* Get the effective user ID of the calling process. */ +extern __uid_t geteuid (void) __THROW; + +/* Get the real group ID of the calling process. */ +extern __gid_t getgid (void) __THROW; + +/* Get the effective group ID of the calling process. */ +extern __gid_t getegid (void) __THROW; + +/* If SIZE is zero, return the number of supplementary groups + the calling process is in. Otherwise, fill in the group IDs + of its supplementary groups in LIST and return the number written. */ +extern int getgroups (int __size, __gid_t __list[]) __THROW __wur; + +#if 0 /*def __USE_GNU*/ +/* Return nonzero iff the calling process is in group GID. */ +extern int group_member (__gid_t __gid) __THROW; +#endif + +/* Set the user ID of the calling process to UID. + If the calling process is the super-user, set the real + and effective user IDs, and the saved set-user-ID to UID; + if not, the effective user ID is set to UID. */ +extern int setuid (__uid_t __uid) __THROW; + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED +/* Set the real user ID of the calling process to RUID, + and the effective user ID of the calling process to EUID. */ +extern int setreuid (__uid_t __ruid, __uid_t __euid) __THROW; +#endif + +#if defined __USE_BSD || defined __USE_XOPEN2K +/* Set the effective user ID of the calling process to UID. */ +extern int seteuid (__uid_t __uid) __THROW; +#endif /* Use BSD. */ + +/* Set the group ID of the calling process to GID. + If the calling process is the super-user, set the real + and effective group IDs, and the saved set-group-ID to GID; + if not, the effective group ID is set to GID. */ +extern int setgid (__gid_t __gid) __THROW; + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED +/* Set the real group ID of the calling process to RGID, + and the effective group ID of the calling process to EGID. */ +extern int setregid (__gid_t __rgid, __gid_t __egid) __THROW; +#endif + +#if defined __USE_BSD || defined __USE_XOPEN2K +/* Set the effective group ID of the calling process to GID. */ +extern int setegid (__gid_t __gid) __THROW; +#endif /* Use BSD. */ + +#ifdef __USE_GNU +/* Fetch the real user ID, effective user ID, and saved-set user ID, + of the calling process. */ +extern int getresuid (__uid_t *__ruid, __uid_t *__euid, __uid_t *__suid) + __THROW; + +/* Fetch the real group ID, effective group ID, and saved-set group ID, + of the calling process. */ +extern int getresgid (__gid_t *__rgid, __gid_t *__egid, __gid_t *__sgid) + __THROW; + +/* Set the real user ID, effective user ID, and saved-set user ID, + of the calling process to RUID, EUID, and SUID, respectively. */ +extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid) + __THROW; + +/* Set the real group ID, effective group ID, and saved-set group ID, + of the calling process to RGID, EGID, and SGID, respectively. */ +extern int setresgid (__gid_t __rgid, __gid_t __egid, __gid_t __sgid) + __THROW; +#endif + + +#ifdef __ARCH_USE_MMU__ +/* Clone the calling process, creating an exact copy. + Return -1 for errors, 0 to the new process, + and the process ID of the new process to the old process. */ +extern __pid_t fork (void) __THROW; +#endif + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED +/* Clone the calling process, but without copying the whole address space. + The calling process is suspended until the new process exits or is + replaced by a call to `execve'. Return -1 for errors, 0 to the new process, + and the process ID of the new process to the old process. */ +extern __pid_t vfork (void) __THROW; +#endif /* Use BSD. */ + + +/* Return the pathname of the terminal FD is open on, or NULL on errors. + The returned storage is good only until the next call to this function. */ +extern char *ttyname (int __fd) __THROW; + +/* Store at most BUFLEN characters of the pathname of the terminal FD is + open on in BUF. Return 0 on success, otherwise an error number. */ +extern int ttyname_r (int __fd, char *__buf, size_t __buflen) + __THROW __nonnull ((2)) __wur; + +/* Return 1 if FD is a valid descriptor associated + with a terminal, zero if not. */ +extern int isatty (int __fd) __THROW; + +#if 0 /*defined __USE_BSD \ + || (defined __USE_XOPEN_EXTENDED && !defined __USE_UNIX98)*/ +/* Return the index into the active-logins file (utmp) for + the controlling terminal. */ +extern int ttyslot (void) __THROW; +#endif + + +/* Make a link to FROM named TO. */ +extern int link (__const char *__from, __const char *__to) + __THROW __nonnull ((1, 2)) __wur; + +#ifdef __USE_ATFILE +/* Like link but relative paths in TO and FROM are interpreted relative + to FROMFD and TOFD respectively. */ +extern int linkat (int __fromfd, __const char *__from, int __tofd, + __const char *__to, int __flags) + __THROW __nonnull ((2, 4)) __wur; +#endif + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K +/* Make a symbolic link to FROM named TO. */ +extern int symlink (__const char *__from, __const char *__to) + __THROW __nonnull ((1, 2)) __wur; + +/* Read the contents of the symbolic link PATH into no more than + LEN bytes of BUF. The contents are not null-terminated. + Returns the number of characters read, or -1 for errors. */ +extern ssize_t readlink (__const char *__restrict __path, + char *__restrict __buf, size_t __len) + __THROW __nonnull ((1, 2)) __wur; +#endif /* Use BSD. */ + +#ifdef __USE_ATFILE +/* Like symlink but a relative path in TO is interpreted relative to TOFD. */ +extern int symlinkat (__const char *__from, int __tofd, + __const char *__to) __THROW __nonnull ((1, 3)) __wur; + +/* Like readlink but a relative PATH is interpreted relative to FD. */ +extern ssize_t readlinkat (int __fd, __const char *__restrict __path, + char *__restrict __buf, size_t __len) + __THROW __nonnull ((2, 3)) __wur; +#endif + +/* Remove the link NAME. */ +extern int unlink (__const char *__name) __THROW __nonnull ((1)); + +#ifdef __USE_ATFILE +/* Remove the link NAME relative to FD. */ +extern int unlinkat (int __fd, __const char *__name, int __flag) + __THROW __nonnull ((2)); +#endif + +/* Remove the directory PATH. */ +extern int rmdir (__const char *__path) __THROW __nonnull ((1)); + + +/* Return the foreground process group ID of FD. */ +extern __pid_t tcgetpgrp (int __fd) __THROW; + +/* Set the foreground process group ID of FD set PGRP_ID. */ +extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) __THROW; + + +/* Return the login name of the user. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +extern char *getlogin (void); +#if defined __USE_REENTRANT || defined __USE_POSIX199506 +/* Return at most NAME_LEN characters of the login name of the user in NAME. + If it cannot be determined or some other error occurred, return the error + code. Otherwise return 0. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +extern int getlogin_r (char *__name, size_t __name_len) __nonnull ((1)); +#endif + +#if 0 /*def __USE_BSD*/ +/* Set the login name returned by `getlogin'. */ +extern int setlogin (__const char *__name) __THROW __nonnull ((1)); +#endif + + +#ifdef __USE_POSIX2 +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. */ +# define __need_getopt +/* keep this for uClibc in bits/, we need it when GNU_GETOPT is disabled */ +# include +#endif + + +#if defined __USE_BSD || defined __USE_UNIX98 +/* Put the name of the current host in no more than LEN bytes of NAME. + The result is null-terminated if LEN is large enough for the full + name and the terminator. */ +extern int gethostname (char *__name, size_t __len) __THROW __nonnull ((1)); +#endif + + +#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_UNIX98) +/* Set the name of the current host to NAME, which is LEN bytes long. + This call is restricted to the super-user. */ +extern int sethostname (__const char *__name, size_t __len) + __THROW __nonnull ((1)) __wur; + +/* Set the current machine's Internet number to ID. + This call is restricted to the super-user. */ +extern int sethostid (long int __id) __THROW __wur; + + +/* Get and set the NIS (aka YP) domain name, if any. + Called just like `gethostname' and `sethostname'. + The NIS domain name is usually the empty string when not using NIS. */ +extern int getdomainname (char *__name, size_t __len) + __THROW __nonnull ((1)) __wur; +extern int setdomainname (__const char *__name, size_t __len) + __THROW __nonnull ((1)) __wur; + + +/* Revoke access permissions to all processes currently communicating + with the control terminal, and then send a SIGHUP signal to the process + group of the control terminal. */ +extern int vhangup (void) __THROW; + +#if 0 +/* Revoke the access of all descriptors currently open on FILE. */ +extern int revoke (__const char *__file) __THROW __nonnull ((1)) __wur; + + +/* Enable statistical profiling, writing samples of the PC into at most + SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling + is enabled, the system examines the user PC and increments + SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536]. If SCALE is zero, + disable profiling. Returns zero on success, -1 on error. */ +extern int profil (unsigned short int *__sample_buffer, size_t __size, + size_t __offset, unsigned int __scale) + __THROW __nonnull ((1)); +#endif + + +/* Turn accounting on if NAME is an existing file. The system will then write + a record for each process as it terminates, to this file. If NAME is NULL, + turn accounting off. This call is restricted to the super-user. */ +extern int acct (__const char *__name) __THROW; + + +/* Successive calls return the shells listed in `/etc/shells'. */ +extern char *getusershell (void) __THROW; +extern void endusershell (void) __THROW; /* Discard cached info. */ +extern void setusershell (void) __THROW; /* Rewind and re-read the file. */ + + +#ifdef __ARCH_USE_MMU__ +/* Put the program in the background, and dissociate from the controlling + terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero, + redirects stdin, stdout, and stderr to /dev/null. */ +extern int daemon (int __nochdir, int __noclose) __THROW __wur; +#endif +#endif /* Use BSD || X/Open. */ + + +#if defined __USE_BSD || (defined __USE_XOPEN && !defined __USE_XOPEN2K) +/* Make PATH be the root directory (the starting point for absolute paths). + This call is restricted to the super-user. */ +extern int chroot (__const char *__path) __THROW __nonnull ((1)) __wur; + +/* Prompt with PROMPT and read a string from the terminal without echoing. + Uses /dev/tty if possible; otherwise stderr and stdin. */ +extern char *getpass (__const char *__prompt) __nonnull ((1)); +#endif /* Use BSD || X/Open. */ + + +#if defined __USE_BSD || defined __USE_XOPEN +/* Make all changes done to FD actually appear on disk. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern int fsync (int __fd); +#endif /* Use BSD || X/Open. */ + + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED + +/* Return identifier for the current host. */ +extern long int gethostid (void); + +/* Make all changes done to all files actually appear on disk. */ +extern void sync (void) __THROW; + + +/* Return the number of bytes in a page. This is the system's page size, + which is not necessarily the same as the hardware page size. */ +extern int getpagesize (void) __THROW __attribute__ ((__const__)); + + +/* Return the maximum number of file descriptors + the current process could possibly have. */ +extern int getdtablesize (void) __THROW; + + +/* Truncate FILE to LENGTH bytes. */ +# ifndef __USE_FILE_OFFSET64 +extern int truncate (__const char *__file, __off_t __length) + __THROW __nonnull ((1)) __wur; +# else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (truncate, + (__const char *__file, __off64_t __length), + truncate64) __nonnull ((1)) __wur; +# else +# define truncate truncate64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int truncate64 (__const char *__file, __off64_t __length) + __THROW __nonnull ((1)) __wur; +# endif + +#endif /* Use BSD || X/Open Unix. */ + +#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K + +/* Truncate the file FD is open on to LENGTH bytes. */ +# ifndef __USE_FILE_OFFSET64 +extern int ftruncate (int __fd, __off_t __length) __THROW __wur; +# else +# ifdef __REDIRECT_NTH +extern int __REDIRECT_NTH (ftruncate, (int __fd, __off64_t __length), + ftruncate64) __wur; +# else +# define ftruncate ftruncate64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int ftruncate64 (int __fd, __off64_t __length) __THROW __wur; +# endif + +#endif /* Use BSD || X/Open Unix || POSIX 2003. */ + + +#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED + +/* Set the end of accessible data space (aka "the break") to ADDR. + Returns zero on success and -1 for errors (with errno set). */ +extern int brk (void *__addr) __THROW __wur; + +/* Increase or decrease the end of accessible data space by DELTA bytes. + If successful, returns the address the previous end of data space + (i.e. the beginning of the new space, if DELTA > 0); + returns (void *) -1 for errors (with errno set). */ +extern void *sbrk (intptr_t __delta) __THROW; +#endif + + +#ifdef __USE_MISC +/* Invoke `system call' number SYSNO, passing it the remaining arguments. + This is completely system-dependent, and not often useful. + + In Unix, `syscall' sets `errno' for all errors and most calls return -1 + for errors; in many systems you cannot pass arguments or get return + values for all system calls (`pipe', `fork', and `getppid' typically + among them). + + In Mach, all system calls take normal arguments and always return an + error code (zero for success). */ +extern long int syscall (long int __sysno, ...) __THROW; + +#endif /* Use misc. */ + + +#if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) && !defined F_LOCK +/* NOTE: These declarations also appear in ; be sure to keep both + files consistent. Some systems have them there and some here, and some + software depends on the macros being defined without including both. */ + +/* `lockf' is a simpler interface to the locking facilities of `fcntl'. + LEN is always relative to the current file position. + The CMD argument is one of the following. + + This function is a cancellation point and therefore not marked with + __THROW. */ + +# define F_ULOCK 0 /* Unlock a previously locked region. */ +# define F_LOCK 1 /* Lock a region for exclusive use. */ +# define F_TLOCK 2 /* Test and lock a region for exclusive use. */ +# define F_TEST 3 /* Test a region for other processes locks. */ + +# ifndef __USE_FILE_OFFSET64 +extern int lockf (int __fd, int __cmd, __off_t __len) __wur; +# else +# ifdef __REDIRECT +extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), + lockf64) __wur; +# else +# define lockf lockf64 +# endif +# endif +# ifdef __USE_LARGEFILE64 +extern int lockf64 (int __fd, int __cmd, __off64_t __len) __wur; +# endif +#endif /* Use misc and F_LOCK not already defined. */ + + +#ifdef __USE_GNU + +/* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno' + set to EINTR. */ + +# define TEMP_FAILURE_RETRY(expression) \ + (__extension__ \ + ({ long int __result; \ + do __result = (long int) (expression); \ + while (__result == -1L && errno == EINTR); \ + __result; })) +#endif + +#if defined __USE_POSIX199309 || defined __USE_UNIX98 +/* Synchronize at least the data part of a file with the underlying + media. */ +extern int fdatasync (int __fildes) __THROW; +#endif /* Use POSIX199309 */ + + +/* XPG4.2 specifies that prototypes for the encryption functions must + be defined here. */ +#ifdef __USE_XOPEN +/* Encrypt at most 8 characters from KEY using salt to perturb DES. */ +extern char *crypt (__const char *__key, __const char *__salt) + __THROW __nonnull ((1, 2)); + +/* Encrypt data in BLOCK in place if EDFLAG is zero; otherwise decrypt + block in place. */ +extern void encrypt (char *__block, int __edflag) __THROW __nonnull ((1)); + + +/* Swab pairs bytes in the first N bytes of the area pointed to by + FROM and copy the result to TO. The value of TO must not be in the + range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM + is without partner. */ +extern void swab (__const void *__restrict __from, void *__restrict __to, + ssize_t __n) __THROW __nonnull ((1, 2)); +#endif + + +/* The Single Unix specification demands this prototype to be here. + It is also found in . */ +#ifdef __USE_XOPEN +/* Return the name of the controlling terminal. */ +extern char *ctermid (char *__s) __THROW; +#endif + + +/* Define some macros helping to catch buffer overflows. */ +#if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus +# include +#endif + +__END_DECLS + +#endif /* unistd.h */ diff --git a/conts/posix/libposix/include/posix/ustat.h b/conts/posix/libposix/include/posix/ustat.h new file mode 100644 index 0000000..cba150e --- /dev/null +++ b/conts/posix/libposix/include/posix/ustat.h @@ -0,0 +1 @@ +#include diff --git a/conts/posix/libposix/include/posix/utime.h b/conts/posix/libposix/include/posix/utime.h new file mode 100644 index 0000000..dd5d265 --- /dev/null +++ b/conts/posix/libposix/include/posix/utime.h @@ -0,0 +1,52 @@ +/* Copyright (C) 1991, 92, 96, 97, 98, 99, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * POSIX Standard: 5.6.6 Set File Access and Modification Times + */ + +#ifndef _UTIME_H +#define _UTIME_H 1 + +#include + +__BEGIN_DECLS + +#include + +#if defined __USE_XOPEN || defined __USE_XOPEN2K +# define __need_time_t +# include +#endif + +/* Structure describing file times. */ +struct utimbuf + { + __time_t actime; /* Access time. */ + __time_t modtime; /* Modification time. */ + }; + +/* Set the access and modification times of FILE to those given in + *FILE_TIMES. If FILE_TIMES is NULL, set them to the current time. */ +extern int utime (__const char *__file, + __const struct utimbuf *__file_times) + __THROW __nonnull ((1)); + +__END_DECLS + +#endif /* utime.h */ diff --git a/conts/posix/libposix/include/posix/utmp.h b/conts/posix/libposix/include/posix/utmp.h new file mode 100644 index 0000000..585aad1 --- /dev/null +++ b/conts/posix/libposix/include/posix/utmp.h @@ -0,0 +1,97 @@ +/* Copyright (C) 1993, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _UTMP_H +#define _UTMP_H 1 + +#include + +#include + + +__BEGIN_DECLS + +/* Get system dependent values and data structures. */ +#include + +/* Compatibility names for the strings of the canonical file names. */ +#define UTMP_FILE _PATH_UTMP +#define UTMP_FILENAME _PATH_UTMP +#define WTMP_FILE _PATH_WTMP +#define WTMP_FILENAME _PATH_WTMP + + + +/* Make FD be the controlling terminal, stdin, stdout, and stderr; + then close FD. Returns 0 on success, nonzero on error. */ +extern int login_tty (int __fd) __THROW; + + +/* Write the given entry into utmp and wtmp. */ +extern void login (__const struct utmp *__entry) __THROW; + +/* Write the utmp entry to say the user on UT_LINE has logged out. */ +extern int logout (__const char *__ut_line) __THROW; + +/* Append to wtmp an entry for the current time and the given info. */ +extern void logwtmp (__const char *__ut_line, __const char *__ut_name, + __const char *__ut_host) __THROW; + +/* Append entry UTMP to the wtmp-like file WTMP_FILE. */ +extern void updwtmp (__const char *__wtmp_file, __const struct utmp *__utmp) + __THROW; + +/* Change name of the utmp file to be examined. */ +extern int utmpname (__const char *__file) __THROW; + +/* Read next entry from a utmp-like file. */ +extern struct utmp *getutent (void) __THROW; + +/* Reset the input stream to the beginning of the file. */ +extern void setutent (void) __THROW; + +/* Close the current open file. */ +extern void endutent (void) __THROW; + +/* Search forward from the current point in the utmp file until the + next entry with a ut_type matching ID->ut_type. */ +extern struct utmp *getutid (__const struct utmp *__id) __THROW; + +/* Search forward from the current point in the utmp file until the + next entry with a ut_line matching LINE->ut_line. */ +extern struct utmp *getutline (__const struct utmp *__line) __THROW; + +/* Write out entry pointed to by UTMP_PTR into the utmp file. */ +extern struct utmp *pututline (__const struct utmp *__utmp_ptr) __THROW; + + +#if 0 /* def __USE_MISC */ +/* Reentrant versions of the file for handling utmp files. */ +extern int getutent_r (struct utmp *__buffer, struct utmp **__result) __THROW; + +extern int getutid_r (__const struct utmp *__id, struct utmp *__buffer, + struct utmp **__result) __THROW; + +extern int getutline_r (__const struct utmp *__line, + struct utmp *__buffer, struct utmp **__result) __THROW; + +#endif /* Use misc. */ + +__END_DECLS + +#endif /* utmp.h */ diff --git a/conts/posix/libposix/include/posix/values.h b/conts/posix/libposix/include/posix/values.h new file mode 100644 index 0000000..d8bd8b5 --- /dev/null +++ b/conts/posix/libposix/include/posix/values.h @@ -0,0 +1,71 @@ +/* Old compatibility names for and constants. + Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* This interface is obsolete. New programs should use + and/or instead of . */ + +#ifndef _VALUES_H +#define _VALUES_H 1 + +#include + +#include + +#define _TYPEBITS(type) (sizeof (type) * CHAR_BIT) + +#define CHARBITS _TYPEBITS (char) +#define SHORTBITS _TYPEBITS (short int) +#define INTBITS _TYPEBITS (int) +#define LONGBITS _TYPEBITS (long int) +#define PTRBITS _TYPEBITS (char *) +#define DOUBLEBITS _TYPEBITS (double) +#define FLOATBITS _TYPEBITS (float) + +#define MINSHORT SHRT_MIN +#define MININT INT_MIN +#define MINLONG LONG_MIN + +#define MAXSHORT SHRT_MAX +#define MAXINT INT_MAX +#define MAXLONG LONG_MAX + +#define HIBITS MINSHORT +#define HIBITL MINLONG + + +#ifdef __UCLIBC_HAS_FLOATS__ +#include + +#define MAXDOUBLE DBL_MAX +#define MAXFLOAT FLT_MAX +#define MINDOUBLE DBL_MIN +#define MINFLOAT FLT_MIN +#define DMINEXP DBL_MIN_EXP +#define FMINEXP FLT_MIN_EXP +#define DMAXEXP DBL_MAX_EXP +#define FMAXEXP FLT_MAX_EXP +#endif /* __UCLIBC_HAS_FLOATS__ */ + + +#ifdef __USE_MISC +/* Some systems define this name instead of CHAR_BIT or CHARBITS. */ +# define BITSPERBYTE CHAR_BIT +#endif + +#endif /* values.h */ diff --git a/conts/posix/libposix/include/posix/wait.h b/conts/posix/libposix/include/posix/wait.h new file mode 100644 index 0000000..d01b811 --- /dev/null +++ b/conts/posix/libposix/include/posix/wait.h @@ -0,0 +1 @@ +#include diff --git a/conts/posix/libposix/include/posix/wchar.h b/conts/posix/libposix/include/posix/wchar.h new file mode 100644 index 0000000..e461f71 --- /dev/null +++ b/conts/posix/libposix/include/posix/wchar.h @@ -0,0 +1,752 @@ +/* Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard: 7.24 + * Extended multibyte and wide character utilities + */ + +#ifndef _WCHAR_H + +#ifndef __need_mbstate_t +# define _WCHAR_H 1 +# include +#endif + +#ifndef __UCLIBC_HAS_WCHAR__ +#error Attempted to include wchar.h when uClibc built without wide char support. +#endif + +#ifdef _WCHAR_H +/* Get FILE definition. */ +# define __need___FILE +# ifdef __USE_UNIX98 +# define __need_FILE +# endif +# include +/* Get va_list definition. */ +# define __need___va_list +# include + +/* Get size_t, wchar_t, wint_t and NULL from . */ +# define __need_size_t +# define __need_wchar_t +# define __need_NULL +#endif +#define __need_wint_t +#include + +#include + +/* We try to get wint_t from , but not all GCC versions define it + there. So define it ourselves if it remains undefined. */ +#ifndef _WINT_T +/* Integral type unchanged by default argument promotions that can + hold any value corresponding to members of the extended character + set, as well as at least one value that does not correspond to any + member of the extended character set. */ +# define _WINT_T +typedef unsigned int wint_t; +#else +/* Work around problems with the file which doesn't put + wint_t in the std namespace. */ +# if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES \ + && defined __WINT_TYPE__ +__BEGIN_NAMESPACE_STD +typedef __WINT_TYPE__ wint_t; +__END_NAMESPACE_STD +# endif +#endif + + +#ifndef __mbstate_t_defined +# define __mbstate_t_defined 1 +/* Conversion state information. */ +#if 1 +typedef struct +{ + wchar_t __mask; + wchar_t __wc; +} __mbstate_t; +#else +typedef struct +{ + int __count; + union + { + wint_t __wch; + char __wchb[4]; + } __value; /* Value so far. */ +} __mbstate_t; +#endif +#endif +#undef __need_mbstate_t + + +/* The rest of the file is only used if used if __need_mbstate_t is not + defined. */ +#ifdef _WCHAR_H + +__BEGIN_NAMESPACE_C99 +/* Public type. */ +typedef __mbstate_t mbstate_t; +__END_NAMESPACE_C99 +#ifdef __USE_GNU +__USING_NAMESPACE_C99(mbstate_t) +#endif + +#ifndef WCHAR_MIN +/* These constants might also be defined in . */ +# define WCHAR_MIN __WCHAR_MIN +# define WCHAR_MAX __WCHAR_MAX +#endif + +#ifndef WEOF +# define WEOF (0xffffffffu) +#endif + +/* For XPG4 compliance we have to define the stuff from here + as well. */ +#if defined __USE_XOPEN && !defined __USE_UNIX98 +# include +#endif + + +__BEGIN_DECLS + +__BEGIN_NAMESPACE_STD +/* This incomplete type is defined in but needed here because + of `wcsftime'. */ +struct tm; +/* XXX We have to clean this up at some point. Since tm is in the std + namespace but wcsftime is in __c99 the type wouldn't be found + without inserting it in the global namespace. */ +__USING_NAMESPACE_STD(tm) +__END_NAMESPACE_STD + + +__BEGIN_NAMESPACE_C99 +/* Copy SRC to DEST. */ +extern wchar_t *wcscpy (wchar_t *__restrict __dest, + __const wchar_t *__restrict __src) __THROW; +/* Copy no more than N wide-characters of SRC to DEST. */ +extern wchar_t *wcsncpy (wchar_t *__restrict __dest, + __const wchar_t *__restrict __src, size_t __n) + __THROW; + +/* Append SRC onto DEST. */ +extern wchar_t *wcscat (wchar_t *__restrict __dest, + __const wchar_t *__restrict __src) __THROW; +/* Append no more than N wide-characters of SRC onto DEST. */ +extern wchar_t *wcsncat (wchar_t *__restrict __dest, + __const wchar_t *__restrict __src, size_t __n) + __THROW; + +/* Compare S1 and S2. */ +extern int wcscmp (__const wchar_t *__s1, __const wchar_t *__s2) + __THROW __attribute_pure__; +/* Compare N wide-characters of S1 and S2. */ +extern int wcsncmp (__const wchar_t *__s1, __const wchar_t *__s2, size_t __n) + __THROW __attribute_pure__; +__END_NAMESPACE_C99 + +#ifdef __USE_GNU +/* Compare S1 and S2, ignoring case. */ +extern int wcscasecmp (__const wchar_t *__s1, __const wchar_t *__s2) __THROW; + +/* Compare no more than N chars of S1 and S2, ignoring case. */ +extern int wcsncasecmp (__const wchar_t *__s1, __const wchar_t *__s2, + size_t __n) __THROW; + +#ifdef __UCLIBC_HAS_XLOCALE__ +/* Similar to the two functions above but take the information from + the provided locale and not the global locale. */ +# include + +extern int wcscasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2, + __locale_t __loc) __THROW; + +extern int wcsncasecmp_l (__const wchar_t *__s1, __const wchar_t *__s2, + size_t __n, __locale_t __loc) __THROW; +#endif /* __UCLIBC_HAS_XLOCALE__ */ +#endif + +__BEGIN_NAMESPACE_C99 +/* Compare S1 and S2, both interpreted as appropriate to the + LC_COLLATE category of the current locale. */ +extern int wcscoll (__const wchar_t *__s1, __const wchar_t *__s2) __THROW; +/* Transform S2 into array pointed to by S1 such that if wcscmp is + applied to two transformed strings the result is the as applying + `wcscoll' to the original strings. */ +extern size_t wcsxfrm (wchar_t *__restrict __s1, + __const wchar_t *__restrict __s2, size_t __n) __THROW; +__END_NAMESPACE_C99 + +#ifdef __USE_GNU +#ifdef __UCLIBC_HAS_XLOCALE__ +/* Similar to the two functions above but take the information from + the provided locale and not the global locale. */ + +/* Compare S1 and S2, both interpreted as appropriate to the + LC_COLLATE category of the given locale. */ +extern int wcscoll_l (__const wchar_t *__s1, __const wchar_t *__s2, + __locale_t __loc) __THROW; + +/* Transform S2 into array pointed to by S1 such that if wcscmp is + applied to two transformed strings the result is the as applying + `wcscoll' to the original strings. */ +extern size_t wcsxfrm_l (wchar_t *__s1, __const wchar_t *__s2, + size_t __n, __locale_t __loc) __THROW; + +#endif /* __UCLIBC_HAS_XLOCALE__ */ + +/* Duplicate S, returning an identical malloc'd string. */ +extern wchar_t *wcsdup (__const wchar_t *__s) __THROW __attribute_malloc__; +#endif + +__BEGIN_NAMESPACE_C99 +/* Find the first occurrence of WC in WCS. */ +extern wchar_t *wcschr (__const wchar_t *__wcs, wchar_t __wc) + __THROW __attribute_pure__; +/* Find the last occurrence of WC in WCS. */ +extern wchar_t *wcsrchr (__const wchar_t *__wcs, wchar_t __wc) + __THROW __attribute_pure__; +__END_NAMESPACE_C99 + +#ifdef __USE_GNU +/* This function is similar to `wcschr'. But it returns a pointer to + the closing NUL wide character in case C is not found in S. */ +extern wchar_t *wcschrnul (__const wchar_t *__s, wchar_t __wc) + __THROW __attribute_pure__; +#endif + +__BEGIN_NAMESPACE_C99 +/* Return the length of the initial segmet of WCS which + consists entirely of wide characters not in REJECT. */ +extern size_t wcscspn (__const wchar_t *__wcs, __const wchar_t *__reject) + __THROW __attribute_pure__; +/* Return the length of the initial segmet of WCS which + consists entirely of wide characters in ACCEPT. */ +extern size_t wcsspn (__const wchar_t *__wcs, __const wchar_t *__accept) + __THROW __attribute_pure__; +/* Find the first occurrence in WCS of any character in ACCEPT. */ +extern wchar_t *wcspbrk (__const wchar_t *__wcs, __const wchar_t *__accept) + __THROW __attribute_pure__; +/* Find the first occurrence of NEEDLE in HAYSTACK. */ +extern wchar_t *wcsstr (__const wchar_t *__haystack, __const wchar_t *__needle) + __THROW __attribute_pure__; + +/* Divide WCS into tokens separated by characters in DELIM. */ +extern wchar_t *wcstok (wchar_t *__restrict __s, + __const wchar_t *__restrict __delim, + wchar_t **__restrict __ptr) __THROW; + +/* Return the number of wide characters in S. */ +extern size_t wcslen (__const wchar_t *__s) __THROW __attribute_pure__; +__END_NAMESPACE_C99 + +#ifdef __USE_XOPEN +/* Another name for `wcsstr' from XPG4. */ +extern wchar_t *wcswcs (__const wchar_t *__haystack, __const wchar_t *__needle) + __THROW __attribute_pure__; +#endif + +#ifdef __USE_GNU +/* Return the number of wide characters in S, but at most MAXLEN. */ +extern size_t wcsnlen (__const wchar_t *__s, size_t __maxlen) + __THROW __attribute_pure__; +#endif + + +__BEGIN_NAMESPACE_C99 +/* Search N wide characters of S for C. */ +extern wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c, size_t __n) + __THROW __attribute_pure__; + +/* Compare N wide characters of S1 and S2. */ +extern int wmemcmp (__const wchar_t *__restrict __s1, + __const wchar_t *__restrict __s2, size_t __n) + __THROW __attribute_pure__; + +/* Copy N wide characters of SRC to DEST. */ +extern wchar_t *wmemcpy (wchar_t *__restrict __s1, + __const wchar_t *__restrict __s2, size_t __n) __THROW; + +/* Copy N wide characters of SRC to DEST, guaranteeing + correct behavior for overlapping strings. */ +extern wchar_t *wmemmove (wchar_t *__s1, __const wchar_t *__s2, size_t __n) + __THROW; + +/* Set N wide characters of S to C. */ +extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW; +__END_NAMESPACE_C99 + +#ifdef __USE_GNU +/* Copy N wide characters of SRC to DEST and return pointer to following + wide character. */ +extern wchar_t *wmempcpy (wchar_t *__restrict __s1, + __const wchar_t *__restrict __s2, size_t __n) + __THROW; +#endif + + +__BEGIN_NAMESPACE_C99 +/* Determine whether C constitutes a valid (one-byte) multibyte + character. */ +extern wint_t btowc (int __c) __THROW; + +/* Determine whether C corresponds to a member of the extended + character set whose multibyte representation is a single byte. */ +extern int wctob (wint_t __c) __THROW; + +/* Determine whether PS points to an object representing the initial + state. */ +extern int mbsinit (__const mbstate_t *__ps) __THROW __attribute_pure__; + +/* Write wide character representation of multibyte character pointed + to by S to PWC. */ +extern size_t mbrtowc (wchar_t *__restrict __pwc, + __const char *__restrict __s, size_t __n, + mbstate_t *__p) __THROW; + +/* Write multibyte representation of wide character WC to S. */ +extern size_t wcrtomb (char *__restrict __s, wchar_t __wc, + mbstate_t *__restrict __ps) __THROW; + +/* Return number of bytes in multibyte character pointed to by S. */ +#if 0 /* uClibc: disabled */ +extern size_t __mbrlen (__const char *__restrict __s, size_t __n, + mbstate_t *__restrict __ps) __THROW; +#endif +extern size_t mbrlen (__const char *__restrict __s, size_t __n, + mbstate_t *__restrict __ps) __THROW; + +/* Write wide character representation of multibyte character string + SRC to DST. */ +extern size_t mbsrtowcs (wchar_t *__restrict __dst, + __const char **__restrict __src, size_t __len, + mbstate_t *__restrict __ps) __THROW; + +/* Write multibyte character representation of wide character string + SRC to DST. */ +extern size_t wcsrtombs (char *__restrict __dst, + __const wchar_t **__restrict __src, size_t __len, + mbstate_t *__restrict __ps) __THROW; +__END_NAMESPACE_C99 + + +#ifdef __USE_GNU +/* Write wide character representation of at most NMC bytes of the + multibyte character string SRC to DST. */ +extern size_t mbsnrtowcs (wchar_t *__restrict __dst, + __const char **__restrict __src, size_t __nmc, + size_t __len, mbstate_t *__restrict __ps) __THROW; + +/* Write multibyte character representation of at most NWC characters + from the wide character string SRC to DST. */ +extern size_t wcsnrtombs (char *__restrict __dst, + __const wchar_t **__restrict __src, + size_t __nwc, size_t __len, + mbstate_t *__restrict __ps) __THROW; +#endif /* use GNU */ + + +/* The following functions are extensions found in X/Open CAE. */ +#ifdef __USE_XOPEN +/* Determine number of column positions required for C. */ +extern int wcwidth (wchar_t __c) __THROW; + +/* Determine number of column positions required for first N wide + characters (or fewer if S ends before this) in S. */ +extern int wcswidth (__const wchar_t *__s, size_t __n) __THROW; +#endif /* Use X/Open. */ + + +__BEGIN_NAMESPACE_C99 +#ifdef __UCLIBC_HAS_FLOATS__ +/* Convert initial portion of the wide string NPTR to `double' + representation. */ +extern double wcstod (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; + +#ifdef __USE_ISOC99 +/* Likewise for `float' and `long double' sizes of floating-point numbers. */ +extern float wcstof (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +extern long double wcstold (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr) __THROW; +#endif /* C99 */ +#endif /* __UCLIBC_HAS_FLOATS__ */ + + +/* Convert initial portion of wide string NPTR to `long int' + representation. */ +extern long int wcstol (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, int __base) __THROW; + +/* Convert initial portion of wide string NPTR to `unsigned long int' + representation. */ +extern unsigned long int wcstoul (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, int __base) + __THROW; + +#if defined __USE_ISOC99 || (defined __GNUC__ && defined __USE_GNU) +/* Convert initial portion of wide string NPTR to `long int' + representation. */ +__extension__ +extern long long int wcstoll (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, int __base) + __THROW; + +/* Convert initial portion of wide string NPTR to `unsigned long long int' + representation. */ +__extension__ +extern unsigned long long int wcstoull (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + int __base) __THROW; +#endif /* ISO C99 or GCC and GNU. */ +__END_NAMESPACE_C99 + +#if defined __GNUC__ && defined __USE_GNU +/* Convert initial portion of wide string NPTR to `long int' + representation. */ +__extension__ +extern long long int wcstoq (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, int __base) + __THROW; + +/* Convert initial portion of wide string NPTR to `unsigned long long int' + representation. */ +__extension__ +extern unsigned long long int wcstouq (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + int __base) __THROW; +#endif /* GCC and use GNU. */ + +#ifdef __USE_GNU +#ifdef __UCLIBC_HAS_XLOCALE__ +/* The concept of one static locale per category is not very well + thought out. Many applications will need to process its data using + information from several different locales. Another application is + the implementation of the internationalization handling in the + upcoming ISO C++ standard library. To support this another set of + the functions using locale data exist which have an additional + argument. + + Attention: all these functions are *not* standardized in any form. + This is a proof-of-concept implementation. */ + +/* Structure for reentrant locale using functions. This is an + (almost) opaque type for the user level programs. */ +# include + +/* Special versions of the functions above which take the locale to + use as an additional parameter. */ +extern long int wcstol_l (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, int __base, + __locale_t __loc) __THROW; + +extern unsigned long int wcstoul_l (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + int __base, __locale_t __loc) __THROW; + +__extension__ +extern long long int wcstoll_l (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + int __base, __locale_t __loc) __THROW; + +__extension__ +extern unsigned long long int wcstoull_l (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + int __base, __locale_t __loc) + __THROW; + +#ifdef __UCLIBC_HAS_FLOATS__ +extern double wcstod_l (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, __locale_t __loc) + __THROW; + +extern float wcstof_l (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, __locale_t __loc) + __THROW; + +extern long double wcstold_l (__const wchar_t *__restrict __nptr, + wchar_t **__restrict __endptr, + __locale_t __loc) __THROW; +#endif /* __UCLIBC_HAS_FLOATS__ */ +#endif /* __UCLIBC_HAS_XLOCALE__ */ +#endif /* GNU */ + + +#ifdef __USE_GNU +/* Copy SRC to DEST, returning the address of the terminating L'\0' in + DEST. */ +extern wchar_t *wcpcpy (wchar_t *__dest, __const wchar_t *__src) __THROW; + +/* Copy no more than N characters of SRC to DEST, returning the address of + the last character written into DEST. */ +extern wchar_t *wcpncpy (wchar_t *__dest, __const wchar_t *__src, size_t __n) + __THROW; +#endif /* use GNU */ + + +/* Wide character I/O functions. */ +#if defined __USE_ISOC99 || defined __USE_UNIX98 +__BEGIN_NAMESPACE_C99 + +/* Select orientation for stream. */ +extern int fwide (__FILE *__fp, int __mode) __THROW; + + +/* Write formatted output to STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fwprintf (__FILE *__restrict __stream, + __const wchar_t *__restrict __format, ...) + /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */; +/* Write formatted output to stdout. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int wprintf (__const wchar_t *__restrict __format, ...) + /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */; +/* Write formatted output of at most N characters to S. */ +extern int swprintf (wchar_t *__restrict __s, size_t __n, + __const wchar_t *__restrict __format, ...) + __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */; + +/* Write formatted output to S from argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vfwprintf (__FILE *__restrict __s, + __const wchar_t *__restrict __format, + __gnuc_va_list __arg) + /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */; +/* Write formatted output to stdout from argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vwprintf (__const wchar_t *__restrict __format, + __gnuc_va_list __arg) + /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */; +/* Write formatted output of at most N character to S from argument + list ARG. */ +extern int vswprintf (wchar_t *__restrict __s, size_t __n, + __const wchar_t *__restrict __format, + __gnuc_va_list __arg) + __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */; + + +/* Read formatted input from STREAM. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int fwscanf (__FILE *__restrict __stream, + __const wchar_t *__restrict __format, ...) + /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; +/* Read formatted input from stdin. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int wscanf (__const wchar_t *__restrict __format, ...) + /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */; +/* Read formatted input from S. */ +extern int swscanf (__const wchar_t *__restrict __s, + __const wchar_t *__restrict __format, ...) + __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; + +__END_NAMESPACE_C99 +#endif /* Use ISO C99 and Unix98. */ + +#ifdef __USE_ISOC99 +__BEGIN_NAMESPACE_C99 + +/* Read formatted input from S into argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vfwscanf (__FILE *__restrict __s, + __const wchar_t *__restrict __format, + __gnuc_va_list __arg) + /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; +/* Read formatted input from stdin into argument list ARG. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int vwscanf (__const wchar_t *__restrict __format, + __gnuc_va_list __arg) + /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */; +/* Read formatted input from S into argument list ARG. */ +extern int vswscanf (__const wchar_t *__restrict __s, + __const wchar_t *__restrict __format, + __gnuc_va_list __arg) + __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */; + +__END_NAMESPACE_C99 +#endif /* Use ISO C99. */ + + +__BEGIN_NAMESPACE_C99 +/* Read a character from STREAM. + + These functions are possible cancellation points and therefore not + marked with __THROW. */ +extern wint_t fgetwc (__FILE *__stream); +extern wint_t getwc (__FILE *__stream); + +/* Read a character from stdin. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern wint_t getwchar (void); + + +/* Write a character to STREAM. + + These functions are possible cancellation points and therefore not + marked with __THROW. */ +extern wint_t fputwc (wchar_t __wc, __FILE *__stream); +extern wint_t putwc (wchar_t __wc, __FILE *__stream); + +/* Write a character to stdout. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +extern wint_t putwchar (wchar_t __wc); + + +/* Get a newline-terminated wide character string of finite length + from STREAM. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n, + __FILE *__restrict __stream); + +/* Write a string to STREAM. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +extern int fputws (__const wchar_t *__restrict __ws, + __FILE *__restrict __stream); + + +/* Push a character back onto the input buffer of STREAM. + + This function is a possible cancellation points and therefore not + marked with __THROW. */ +extern wint_t ungetwc (wint_t __wc, __FILE *__stream); +__END_NAMESPACE_C99 + + +#ifdef __USE_GNU +/* These are defined to be equivalent to the `char' functions defined + in POSIX.1:1996. + + These functions are not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation they are cancellation points and + therefore not marked with __THROW. */ +extern wint_t getwc_unlocked (__FILE *__stream); +extern wint_t getwchar_unlocked (void); + +/* This is the wide character version of a GNU extension. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern wint_t fgetwc_unlocked (__FILE *__stream); + +/* Faster version when locking is not necessary. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream); + +/* These are defined to be equivalent to the `char' functions defined + in POSIX.1:1996. + + These functions are not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation they are cancellation points and + therefore not marked with __THROW. */ +extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream); +extern wint_t putwchar_unlocked (wchar_t __wc); + + +/* This function does the same as `fgetws' but does not lock the stream. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n, + __FILE *__restrict __stream); + +/* This function does the same as `fputws' but does not lock the stream. + + This function is not part of POSIX and therefore no official + cancellation point. But due to similarity with an POSIX interface + or due to the implementation it is a cancellation point and + therefore not marked with __THROW. */ +extern int fputws_unlocked (__const wchar_t *__restrict __ws, + __FILE *__restrict __stream); +#endif + + +__BEGIN_NAMESPACE_C99 +/* Format TP into S according to FORMAT. + Write no more than MAXSIZE wide characters and return the number + of wide characters written, or 0 if it would exceed MAXSIZE. */ +extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize, + __const wchar_t *__restrict __format, + __const struct tm *__restrict __tp) __THROW; +__END_NAMESPACE_C99 + +# if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__ +# include + +/* Similar to `wcsftime' but takes the information from + the provided locale and not the global locale. */ +extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize, + __const wchar_t *__restrict __format, + __const struct tm *__restrict __tp, + __locale_t __loc) __THROW; +# endif + +/* The X/Open standard demands that most of the functions defined in + the header must also appear here. This is probably + because some X/Open members wrote their implementation before the + ISO C standard was published and introduced the better solution. + We have to provide these definitions for compliance reasons but we + do this nonsense only if really necessary. */ +#if defined __USE_UNIX98 && !defined __USE_GNU +# define __need_iswxxx +# include +#endif + +__END_DECLS + +#endif /* _WCHAR_H defined */ + +#endif /* wchar.h */ diff --git a/conts/posix/libposix/include/posix/wctype.h b/conts/posix/libposix/include/posix/wctype.h new file mode 100644 index 0000000..266ffab --- /dev/null +++ b/conts/posix/libposix/include/posix/wctype.h @@ -0,0 +1,330 @@ +/* Copyright (C) 1996,97,98,99,2000,01,02 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99 Standard: 7.25 + * Wide character classification and mapping utilities + */ + +#ifndef _WCTYPE_H + +#include +#include + +#ifndef __UCLIBC_HAS_WCHAR__ +#error Attempted to include wctype.h when uClibc built without wide char support. +#endif + +#ifndef __need_iswxxx +# define _WCTYPE_H 1 + +/* We try to get wint_t from , but not all GCC versions define it + there. So define it ourselves if it remains undefined. */ +# define __need_wint_t +# include +# ifndef _WINT_T +/* Integral type unchanged by default argument promotions that can + hold any value corresponding to members of the extended character + set, as well as at least one value that does not correspond to any + member of the extended character set. */ +# define _WINT_T +typedef unsigned int wint_t; +# else +# ifdef __USE_ISOC99 +__USING_NAMESPACE_C99(wint_t) +# endif +# endif + +/* Constant expression of type `wint_t' whose value does not correspond + to any member of the extended character set. */ +# ifndef WEOF +# define WEOF (0xffffffffu) +# endif +#endif +#undef __need_iswxxx + + +/* The following part is also used in the header when compiled + in the Unix98 compatibility mode. */ +#ifndef __iswxxx_defined +# define __iswxxx_defined 1 + +__BEGIN_NAMESPACE_C99 +/* Scalar type that can hold values which represent locale-specific + character classifications. */ +/* uClibc note: glibc uses - typedef unsigned long int wctype_t; */ +typedef unsigned int wctype_t; +__END_NAMESPACE_C99 + +# ifndef _ISwbit +# define _ISwbit(bit) (1 << (bit)) + +enum +{ + __ISwupper = 0, /* UPPERCASE. */ + __ISwlower = 1, /* lowercase. */ + __ISwalpha = 2, /* Alphabetic. */ + __ISwdigit = 3, /* Numeric. */ + __ISwxdigit = 4, /* Hexadecimal numeric. */ + __ISwspace = 5, /* Whitespace. */ + __ISwprint = 6, /* Printing. */ + __ISwgraph = 7, /* Graphical. */ + __ISwblank = 8, /* Blank (usually SPC and TAB). */ + __ISwcntrl = 9, /* Control character. */ + __ISwpunct = 10, /* Punctuation. */ + __ISwalnum = 11, /* Alphanumeric. */ + + _ISwupper = _ISwbit (__ISwupper), /* UPPERCASE. */ + _ISwlower = _ISwbit (__ISwlower), /* lowercase. */ + _ISwalpha = _ISwbit (__ISwalpha), /* Alphabetic. */ + _ISwdigit = _ISwbit (__ISwdigit), /* Numeric. */ + _ISwxdigit = _ISwbit (__ISwxdigit), /* Hexadecimal numeric. */ + _ISwspace = _ISwbit (__ISwspace), /* Whitespace. */ + _ISwprint = _ISwbit (__ISwprint), /* Printing. */ + _ISwgraph = _ISwbit (__ISwgraph), /* Graphical. */ + _ISwblank = _ISwbit (__ISwblank), /* Blank (usually SPC and TAB). */ + _ISwcntrl = _ISwbit (__ISwcntrl), /* Control character. */ + _ISwpunct = _ISwbit (__ISwpunct), /* Punctuation. */ + _ISwalnum = _ISwbit (__ISwalnum) /* Alphanumeric. */ +}; +# else +# if defined(__UCLIBC_MJN3_ONLY__) && defined(L_iswctype) +#warning remove _ISwbit already defined check? +#error _ISwbit already defined! +# endif +# endif /* Not _ISwbit */ + + +__BEGIN_DECLS + +__BEGIN_NAMESPACE_C99 +/* + * Wide-character classification functions: 7.15.2.1. + */ + +/* Test for any wide character for which `iswalpha' or `iswdigit' is + true. */ +extern int iswalnum (wint_t __wc) __THROW; + +/* Test for any wide character for which `iswupper' or 'iswlower' is + true, or any wide character that is one of a locale-specific set of + wide-characters for which none of `iswcntrl', `iswdigit', + `iswpunct', or `iswspace' is true. */ +extern int iswalpha (wint_t __wc) __THROW; + +/* Test for any control wide character. */ +extern int iswcntrl (wint_t __wc) __THROW; + +/* Test for any wide character that corresponds to a decimal-digit + character. */ +extern int iswdigit (wint_t __wc) __THROW; + +/* Test for any wide character for which `iswprint' is true and + `iswspace' is false. */ +extern int iswgraph (wint_t __wc) __THROW; + +/* Test for any wide character that corresponds to a lowercase letter + or is one of a locale-specific set of wide characters for which + none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ +extern int iswlower (wint_t __wc) __THROW; + +/* Test for any printing wide character. */ +extern int iswprint (wint_t __wc) __THROW; + +/* Test for any printing wide character that is one of a + locale-specific et of wide characters for which neither `iswspace' + nor `iswalnum' is true. */ +extern int iswpunct (wint_t __wc) __THROW; + +/* Test for any wide character that corresponds to a locale-specific + set of wide characters for which none of `iswalnum', `iswgraph', or + `iswpunct' is true. */ +extern int iswspace (wint_t __wc) __THROW; + +/* Test for any wide character that corresponds to an uppercase letter + or is one of a locale-specific set of wide character for which none + of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ +extern int iswupper (wint_t __wc) __THROW; + +/* Test for any wide character that corresponds to a hexadecimal-digit + character equivalent to that performed be the functions described + in the previous subclause. */ +extern int iswxdigit (wint_t __wc) __THROW; + +/* Test for any wide character that corresponds to a standard blank + wide character or a locale-specific set of wide characters for + which `iswalnum' is false. */ +# ifdef __USE_ISOC99 +extern int iswblank (wint_t __wc) __THROW; +# endif + +/* + * Extensible wide-character classification functions: 7.15.2.2. + */ + +/* Construct value that describes a class of wide characters identified + by the string argument PROPERTY. */ +extern wctype_t wctype (__const char *__property) __THROW; + +/* Determine whether the wide-character WC has the property described by + DESC. */ +extern int iswctype (wint_t __wc, wctype_t __desc) __THROW; +__END_NAMESPACE_C99 + + +/* + * Wide-character case-mapping functions: 7.15.3.1. + */ + +__BEGIN_NAMESPACE_C99 +/* Scalar type that can hold values which represent locale-specific + character mappings. */ +/* uClibc note: glibc uses - typedef __const __int32_t *wctrans_t; */ +typedef unsigned int wctrans_t; +__END_NAMESPACE_C99 +#ifdef __USE_GNU +__USING_NAMESPACE_C99(wctrans_t) +#endif + +__BEGIN_NAMESPACE_C99 +/* Converts an uppercase letter to the corresponding lowercase letter. */ +extern wint_t towlower (wint_t __wc) __THROW; + +/* Converts an lowercase letter to the corresponding uppercase letter. */ +extern wint_t towupper (wint_t __wc) __THROW; +__END_NAMESPACE_C99 + +__END_DECLS + +#endif /* need iswxxx. */ + + +/* The remaining definitions and declarations must not appear in the + header. */ +#ifdef _WCTYPE_H + +/* + * Extensible wide-character mapping functions: 7.15.3.2. + */ + +__BEGIN_DECLS + +__BEGIN_NAMESPACE_C99 +/* Construct value that describes a mapping between wide characters + identified by the string argument PROPERTY. */ +extern wctrans_t wctrans (__const char *__property) __THROW; + +/* Map the wide character WC using the mapping described by DESC. */ +extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW; +__END_NAMESPACE_C99 + +#if defined(__USE_GNU) && defined(__UCLIBC_HAS_XLOCALE__) +/* Declare the interface to extended locale model. */ +# include + +/* Test for any wide character for which `iswalpha' or `iswdigit' is + true. */ +extern int iswalnum_l (wint_t __wc, __locale_t __locale) __THROW; + +/* Test for any wide character for which `iswupper' or 'iswlower' is + true, or any wide character that is one of a locale-specific set of + wide-characters for which none of `iswcntrl', `iswdigit', + `iswpunct', or `iswspace' is true. */ +extern int iswalpha_l (wint_t __wc, __locale_t __locale) __THROW; + +/* Test for any control wide character. */ +extern int iswcntrl_l (wint_t __wc, __locale_t __locale) __THROW; + +/* Test for any wide character that corresponds to a decimal-digit + character. */ +extern int iswdigit_l (wint_t __wc, __locale_t __locale) __THROW; + +/* Test for any wide character for which `iswprint' is true and + `iswspace' is false. */ +extern int iswgraph_l (wint_t __wc, __locale_t __locale) __THROW; + +/* Test for any wide character that corresponds to a lowercase letter + or is one of a locale-specific set of wide characters for which + none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ +extern int iswlower_l (wint_t __wc, __locale_t __locale) __THROW; + +/* Test for any printing wide character. */ +extern int iswprint_l (wint_t __wc, __locale_t __locale) __THROW; + +/* Test for any printing wide character that is one of a + locale-specific et of wide characters for which neither `iswspace' + nor `iswalnum' is true. */ +extern int iswpunct_l (wint_t __wc, __locale_t __locale) __THROW; + +/* Test for any wide character that corresponds to a locale-specific + set of wide characters for which none of `iswalnum', `iswgraph', or + `iswpunct' is true. */ +extern int iswspace_l (wint_t __wc, __locale_t __locale) __THROW; + +/* Test for any wide character that corresponds to an uppercase letter + or is one of a locale-specific set of wide character for which none + of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ +extern int iswupper_l (wint_t __wc, __locale_t __locale) __THROW; + +/* Test for any wide character that corresponds to a hexadecimal-digit + character equivalent to that performed be the functions described + in the previous subclause. */ +extern int iswxdigit_l (wint_t __wc, __locale_t __locale) __THROW; + +/* Test for any wide character that corresponds to a standard blank + wide character or a locale-specific set of wide characters for + which `iswalnum' is false. */ +extern int iswblank_l (wint_t __wc, __locale_t __locale) __THROW; + +/* Construct value that describes a class of wide characters identified + by the string argument PROPERTY. */ +extern wctype_t wctype_l (__const char *__property, __locale_t __locale) + __THROW; + +/* Determine whether the wide-character WC has the property described by + DESC. */ +extern int iswctype_l (wint_t __wc, wctype_t __desc, __locale_t __locale) + __THROW; + + +/* + * Wide-character case-mapping functions. + */ + +/* Converts an uppercase letter to the corresponding lowercase letter. */ +extern wint_t towlower_l (wint_t __wc, __locale_t __locale) __THROW; + +/* Converts an lowercase letter to the corresponding uppercase letter. */ +extern wint_t towupper_l (wint_t __wc, __locale_t __locale) __THROW; + +/* Construct value that describes a mapping between wide characters + identified by the string argument PROPERTY. */ +extern wctrans_t wctrans_l (__const char *__property, __locale_t __locale) + __THROW; + +/* Map the wide character WC using the mapping described by DESC. */ +extern wint_t towctrans_l (wint_t __wc, wctrans_t __desc, + __locale_t __locale) __THROW; + +# endif /* Use GNU. */ + +__END_DECLS + +#endif /* __WCTYPE_H defined. */ + +#endif /* wctype.h */ diff --git a/conts/posix/libposix/include/posix/wordexp.h b/conts/posix/libposix/include/posix/wordexp.h new file mode 100644 index 0000000..1c40e61 --- /dev/null +++ b/conts/posix/libposix/include/posix/wordexp.h @@ -0,0 +1,71 @@ +/* Copyright (C) 1991, 92, 1996-1999, 2001, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _WORDEXP_H +#define _WORDEXP_H 1 + +#include +#define __need_size_t +#include + +__BEGIN_DECLS + +/* Bits set in the FLAGS argument to `wordexp'. */ +enum + { + WRDE_DOOFFS = (1 << 0), /* Insert PWORDEXP->we_offs NULLs. */ + WRDE_APPEND = (1 << 1), /* Append to results of a previous call. */ + WRDE_NOCMD = (1 << 2), /* Don't do command substitution. */ + WRDE_REUSE = (1 << 3), /* Reuse storage in PWORDEXP. */ + WRDE_SHOWERR = (1 << 4), /* Don't redirect stderr to /dev/null. */ + WRDE_UNDEF = (1 << 5), /* Error for expanding undefined variables. */ + __WRDE_FLAGS = (WRDE_DOOFFS | WRDE_APPEND | WRDE_NOCMD | + WRDE_REUSE | WRDE_SHOWERR | WRDE_UNDEF) + }; + +/* Structure describing a word-expansion run. */ +typedef struct + { + size_t we_wordc; /* Count of words matched. */ + char **we_wordv; /* List of expanded words. */ + size_t we_offs; /* Slots to reserve in `we_wordv'. */ + } wordexp_t; + +/* Possible nonzero return values from `wordexp'. */ +enum + { +#ifdef __USE_XOPEN + WRDE_NOSYS = -1, /* Never used since we support `wordexp'. */ +#endif + WRDE_NOSPACE = 1, /* Ran out of memory. */ + WRDE_BADCHAR, /* A metachar appears in the wrong place. */ + WRDE_BADVAL, /* Undefined var reference with WRDE_UNDEF. */ + WRDE_CMDSUB, /* Command substitution with WRDE_NOCMD. */ + WRDE_SYNTAX /* Shell syntax error. */ + }; + +/* Do word expansion of WORDS into PWORDEXP. */ +extern int wordexp (__const char *__restrict __words, + wordexp_t *__restrict __pwordexp, int __flags); + +/* Free the storage allocated by a `wordexp' call. */ +extern void wordfree (wordexp_t *__wordexp) __THROW; + +__END_DECLS + +#endif /* wordexp.h */ diff --git a/conts/posix/libposix/include/posix/xlocale.h b/conts/posix/libposix/include/posix/xlocale.h new file mode 100644 index 0000000..6f726fe --- /dev/null +++ b/conts/posix/libposix/include/posix/xlocale.h @@ -0,0 +1,62 @@ +/* Definition of locale datatype. + Copyright (C) 1997,2000,02 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _XLOCALE_H +#define _XLOCALE_H 1 + +#include + +#ifndef __UCLIBC_HAS_XLOCALE__ +#error Attempted to include xlocale.h when uClibc built without extended locale support. +#endif /* __UCLIBC_HAS_XLOCALE__ */ + +#include +/* #include */ + +#if 0 +/* Structure for reentrant locale using functions. This is an + (almost) opaque type for the user level programs. The file and + this data structure is not standardized. Don't rely on it. It can + go away without warning. */ +typedef struct __locale_struct +{ +#if 0 + /* Note: LC_ALL is not a valid index into this array. */ + struct locale_data *__locales[13]; /* 13 = __LC_LAST. */ +#endif + + /* To increase the speed of this solution we add some special members. */ +/* const unsigned short int *__ctype_b; */ +/* const int *__ctype_tolower; */ +/* const int *__ctype_toupper; */ + const __uint16_t *__ctype_b; + const __ctype_touplow_t *__ctype_tolower; + const __ctype_touplow_t *__ctype_toupper; + + __uclibc_locale_t *__locale_ptr; + +#if 0 + /* Note: LC_ALL is not a valid index into this array. */ + const char *__names[13]; +#endif +} *__locale_t; +#endif + +#endif /* xlocale.h */ diff --git a/conts/posix/libposix/init.c b/conts/posix/libposix/init.c new file mode 100644 index 0000000..d9c0a35 --- /dev/null +++ b/conts/posix/libposix/init.c @@ -0,0 +1,23 @@ +/* + * Main entry point for posix services and applications. + * + * Copyright (C) 2007-2009 Bahadir Balban + */ +#include +#include +#include + +void posix_service_init(void) +{ + /* Non-pager tasks initialise their shared communication page */ + BUG_ON(self_tid() != VFS_TID); + shared_page_init(); +} + +void libposix_init(void) +{ + /* Shall only be run by posix applications */ + BUG_ON(self_tid() == PAGER_TID || self_tid() == VFS_TID); + shared_page_init(); +} + diff --git a/conts/posix/libposix/lseek.c b/conts/posix/libposix/lseek.c new file mode 100644 index 0000000..f72794d --- /dev/null +++ b/conts/posix/libposix/lseek.c @@ -0,0 +1,50 @@ +/* + * l4/posix glue for lseek() + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include + +static inline off_t l4_lseek(int fildes, off_t offset, int whence) +{ + off_t offres; + + write_mr(L4SYS_ARG0, fildes); + write_mr(L4SYS_ARG1, offset); + write_mr(L4SYS_ARG2, whence); + + /* Call pager with shmget() request. Check ipc error. */ + if ((offres = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_LSEEK)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, offres); + return offres; + } + /* Check if syscall itself was successful */ + if ((offres = l4_get_retval()) < 0) { + print_err("%s: OPEN Error: %d.\n", __FUNCTION__, (int)offres); + return offres; + + } + return offres; +} + +off_t lseek(int fildes, off_t offset, int whence) +{ + int ret = l4_lseek(fildes, offset, whence); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + /* else return value */ + return ret; + +} + diff --git a/conts/posix/libposix/mkdir.c b/conts/posix/libposix/mkdir.c new file mode 100644 index 0000000..c25342b --- /dev/null +++ b/conts/posix/libposix/mkdir.c @@ -0,0 +1,57 @@ +/* + * l4/posix glue for mkdir() + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) +#include + +static inline int l4_mkdir(const char *pathname, mode_t mode) +{ + int fd; + + // write_mr(L4SYS_ARG0, (unsigned long)pathname); + copy_to_shpage((void *)pathname, 0, strlen(pathname) + 1); + write_mr(L4SYS_ARG0, (unsigned long)shared_page); + write_mr(L4SYS_ARG1, (u32)mode); + + /* Call pager with shmget() request. Check ipc error. */ + if ((fd = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_MKDIR)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, fd); + return fd; + } + /* Check if syscall itself was successful */ + if ((fd = l4_get_retval()) < 0) { + print_err("%s: MKDIR Error: %d.\n", __FUNCTION__, fd); + return fd; + } + return fd; +} + +int mkdir(const char *pathname, mode_t mode) +{ + int ret; + + /* If error, return positive error code */ + if ((ret = l4_mkdir(pathname, mode)) < 0) { + errno = -ret; + return -1; + } + /* else return value */ + return ret; +} + diff --git a/conts/posix/libposix/mmap.c b/conts/posix/libposix/mmap.c new file mode 100644 index 0000000..9c4bac1 --- /dev/null +++ b/conts/posix/libposix/mmap.c @@ -0,0 +1,136 @@ +/* + * Glue logic between posix mmap/munmap functions + * and their L4 implementation. + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include + +/* FIXME: Implement the same separation that is in read.c write.c etc. such that + * l4_syscall returns negative value and then the actual posix glue sets the errno + * rather than the l4_syscall sets it itself + */ + +struct mmap_descriptor { + void *start; + size_t length; + int prot; + int flags; + int fd; + off_t offset; +}; + +static inline void *l4_mmap(void *start, size_t length, int prot, int flags, int fd, off_t pgoffset) +{ + /* Not enough MRs for all arguments, therefore we fill in a structure */ + struct mmap_descriptor desc = { + .start = start, + .length = length, + .prot = prot, + .flags = flags, + .fd = fd, + .offset = pgoffset, + }; + int ret; + + write_mr(L4SYS_ARG0, (unsigned long)&desc); + + /* Call pager with MMAP request. Check ipc error. */ + if ((ret = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_MMAP)) < 0) { + print_err("%s: IPC Error: %d.\n", __FUNCTION__, ret); + return PTR_ERR(ret); + } + + if (IS_ERR(ret = l4_get_retval())) + print_err("%s: MMAP Error: %d.\n", __FUNCTION__, ret); + + return (void *)ret; +} + +void *mmap2(void *start, size_t length, int prot, int flags, int fd, off_t pgoffset) +{ + void *ret = l4_mmap(start, length, prot, flags, fd, pgoffset); + + if (IS_ERR(ret)) { + errno = -(int)ret; + return MAP_FAILED; + } + return ret; +} + + +void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) +{ + return mmap2(start, length, prot, flags, fd, __pfn(offset)); +} + +int l4_munmap(void *start, size_t length) +{ + int err; + + write_mr(L4SYS_ARG0, (unsigned long)start); + write_mr(L4SYS_ARG1, length); + + /* Call pager with MMAP request. */ + if ((err = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_MUNMAP)) < 0) { + print_err("%s: IPC Error: %d.\n", __FUNCTION__, err); + return err; + } + + /* Check if syscall itself was successful */ + if ((err = l4_get_retval()) < 0) { + print_err("%s: MUNMAP Error: %d.\n", __FUNCTION__, err); + return err; + } + return 0; +} + +int munmap(void *start, size_t length) +{ + int ret = l4_munmap(start, length); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + return 0; +} + +int l4_msync(void *start, size_t length, int flags) +{ + write_mr(L4SYS_ARG0, (unsigned long)start); + write_mr(L4SYS_ARG1, length); + write_mr(L4SYS_ARG2, flags); + + /* Call pager with MMAP request. */ + if ((errno = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_MSYNC)) < 0) { + print_err("%s: IPC Error: %d.\n", __FUNCTION__, errno); + return -1; + } + /* Check if syscall itself was successful */ + if ((errno = l4_get_retval()) < 0) { + print_err("%s: MSYNC Error: %d.\n", __FUNCTION__, errno); + return -1; + } + return 0; +} + +int msync(void *start, size_t length, int flags) +{ + int ret = l4_msync(start, length, flags); + + if (ret < 0) { + errno = -ret; + return -1; + } + return 0; +} + diff --git a/conts/posix/libposix/open.c b/conts/posix/libposix/open.c new file mode 100644 index 0000000..b12fb05 --- /dev/null +++ b/conts/posix/libposix/open.c @@ -0,0 +1,69 @@ +/* + * l4/posix glue for open() + * + * Copyright (C) 2007 Bahadir Balban + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) +#include +#include + +static inline int l4_open(const char *pathname, int flags, mode_t mode) +{ + int fd; + + copy_to_shpage((void *)pathname, 0, strlen(pathname) + 1); + write_mr(L4SYS_ARG0, (unsigned long)shared_page); + write_mr(L4SYS_ARG1, flags); + write_mr(L4SYS_ARG2, (u32)mode); + + /* Call pager with open() request. Check ipc error. */ + if ((fd = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_OPEN)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, fd); + return fd; + } + /* Check if syscall itself was successful */ + if ((fd = l4_get_retval()) < 0) { + print_err("%s: OPEN Error: %d, for path %s\n", + __FUNCTION__, fd, pathname); + return fd; + } + return fd; +} + +int open(const char *pathname, int oflag, ...) +{ + int ret; + mode_t mode = 0; + + if (oflag & O_CREAT) { + va_list arg; + va_start(arg, oflag); + mode = va_arg(arg, mode_t); + va_end(arg); + } + ret = l4_open(pathname, oflag, mode); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + /* else return value */ + return ret; + +} + diff --git a/conts/posix/libposix/read.c b/conts/posix/libposix/read.c new file mode 100644 index 0000000..5dd9c88 --- /dev/null +++ b/conts/posix/libposix/read.c @@ -0,0 +1,103 @@ +/* + * l4/posix glue for read() / sys_readdir() + * + * Copyright (C) 2007 Bahadir Balban + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) +#include +#include + +static inline int l4_readdir(int fd, void *buf, size_t count) +{ + int cnt; + + write_mr(L4SYS_ARG0, fd); + write_mr(L4SYS_ARG1, (unsigned long)shared_page); + write_mr(L4SYS_ARG2, count); + + /* Call pager with readdir() request. Check ipc error. */ + if ((cnt = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_READDIR)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, cnt); + return cnt; + } + /* Check if syscall itself was successful */ + if ((cnt = l4_get_retval()) < 0) { + print_err("%s: READDIR Error: %d.\n", __FUNCTION__, (int)cnt); + return cnt; + + } + + copy_from_shpage(buf, 0, cnt); + return cnt; +} + +static inline int l4_read(int fd, void *buf, size_t count) +{ + int cnt; + + write_mr(L4SYS_ARG0, fd); + write_mr(L4SYS_ARG1, (unsigned long)buf); + write_mr(L4SYS_ARG2, count); + + /* Call pager with read() request. Check ipc error. */ + if ((cnt = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_READ)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, cnt); + return cnt; + } + /* Check if syscall itself was successful */ + if ((cnt = l4_get_retval()) < 0) { + print_err("%s: READ Error: %d.\n", __FUNCTION__, (int)cnt); + return cnt; + + } + return cnt; +} + +ssize_t read(int fd, void *buf, size_t count) +{ + int ret; + + if (!count) + return 0; + + ret = l4_read(fd, buf, count); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + /* else return value */ + return ret; + +} + +ssize_t os_readdir(int fd, void *buf, size_t count) +{ + int ret; + + if (!count) + return 0; + + ret = l4_readdir(fd, buf, count); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + /* else return value */ + return ret; +} + diff --git a/conts/posix/libposix/shm.c b/conts/posix/libposix/shm.c new file mode 100644 index 0000000..6094e74 --- /dev/null +++ b/conts/posix/libposix/shm.c @@ -0,0 +1,120 @@ +/* + * This is the glue logic between posix shared memory functions + * and their L4 implementation. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int l4_shmget(l4id_t key, int size, int shmflg) +{ + int err; + + write_mr(L4SYS_ARG0, key); + write_mr(L4SYS_ARG1, size); + write_mr(L4SYS_ARG2, shmflg); + + /* Call pager with shmget() request. Check ipc error. */ + if ((err = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_SHMGET)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + return err; + } + /* Check if syscall itself was successful */ + if (IS_ERR(err = l4_get_retval())) { + print_err("%s: SHMGET Error: %d.\n", __FUNCTION__, err); + return err; + } + + /* Otherwise err has the positive id number */ + return err; +} + +void *l4_shmat(l4id_t shmid, const void *shmaddr, int shmflg) +{ + int err; + + write_mr(L4SYS_ARG0, shmid); + write_mr(L4SYS_ARG1, (unsigned long)shmaddr); + write_mr(L4SYS_ARG2, shmflg); + + /* Call pager with shmget() request. Check ipc error. */ + if ((err = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_SHMAT)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + return PTR_ERR(err); + } + /* Check if syscall itself was successful */ + if (IS_ERR(err = l4_get_retval())) { + print_err("%s: SHMAT Error: %d.\n", __FUNCTION__, err); + return PTR_ERR(err); + + } + /* Obtain shm base. */ + return (void *)err; +} + +int l4_shmdt(const void *shmaddr) +{ + int err; + + write_mr(L4SYS_ARG0, (unsigned long)shmaddr); + + /* Call pager with shmget() request. Check ipc error. */ + if ((err = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_SHMDT)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + return -1; + } + /* Check if syscall itself was successful */ + if ((err = l4_get_retval()) < 0) { + print_err("%s: SHMDT Error: %d.\n", __FUNCTION__, err); + return -1; + } + return 0; +} + +int shmget(key_t key, size_t size, int shmflg) +{ + int ret = l4_shmget(key, size, shmflg); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + /* else return value */ + return ret; +} + +void *shmat(int shmid, const void *shmaddr, int shmflg) +{ + void *ret = l4_shmat(shmid, shmaddr, shmflg); + + /* If error, return positive error code */ + if (IS_ERR(ret)) { + errno = -((int)ret); + return PTR_ERR(-1); + } + /* else return value */ + return ret; +} + +int shmdt(const void *shmaddr) +{ + int ret = l4_shmdt(shmaddr); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + /* else return value */ + return ret; +} + diff --git a/conts/posix/libposix/shpage.c b/conts/posix/libposix/shpage.c new file mode 100644 index 0000000..cb3997a --- /dev/null +++ b/conts/posix/libposix/shpage.c @@ -0,0 +1,97 @@ +/* + * Initialise posix-related structures. + * + * Copyright (C) 2007-2009 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include INC_GLUE(memlayout.h) +#include +#include +#include +#include +#include +#include + +/* + * Shared page initialisation of posix-like tasks. + * + * POSIX tasks currently use a default shared page for communciation. + * This could have been also done by long ipc calls. + */ + +/* + * Shared page for this task. Used for passing data among ipc + * parties when message registers are not big enough. Every thread + * has right to own one, and it has an address unique to every + * thread. It must be explicitly mapped by both parties of the ipc + * in order to be useful. + */ +void *shared_page; + +/* + * Obtains a unique address for the task's shared page. Note this + * just returns the address. This address is used as an shm key + * to map it via shmget()/shmat() later on. + */ +static void *shared_page_address(void) +{ + void *addr; + int err; + + /* We're asking it for ourself. */ + write_mr(L4SYS_ARG0, self_tid()); + + /* Call pager with utcb address request. Check ipc error. */ + if ((err = l4_sendrecv(PAGER_TID, PAGER_TID, + L4_IPC_TAG_SHPAGE)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + return PTR_ERR(err); + } + + /* Check if syscall itself was successful */ + if (IS_ERR(addr = (void *)l4_get_retval())) { + print_err("%s: Request UTCB Address Error: %d.\n", + __FUNCTION__, (int)addr); + return addr; + } + + return addr; +} + +/* + * Initialises a non-pager task's default shared memory page + * using posix semantics. Used during task initialisation + * and by child tasks after a fork. + */ +int shared_page_init(void) +{ + int shmid; + void *shmaddr; + + /* + * Initialise shared page only if we're not the pager. + * The pager does it differently for itself. + */ + BUG_ON(self_tid() == PAGER_TID); + + /* Obtain our shared page address */ + shared_page = shared_page_address(); + + //print_err("%s: UTCB Read from mm0 as: 0x%x\n", __FUNCTION__, + // (unsigned long)shared_page); + + /* Use it as a key to create a shared memory region */ + BUG_ON((shmid = shmget((key_t)shared_page, + PAGE_SIZE, IPC_CREAT)) < 0); + + /* Attach to the region */ + BUG_ON((shmaddr = shmat(shmid, shared_page, 0)) < 0); + BUG_ON(shmaddr != shared_page); + + return 0; +} + diff --git a/conts/posix/libposix/stat.c b/conts/posix/libposix/stat.c new file mode 100644 index 0000000..34e98cb --- /dev/null +++ b/conts/posix/libposix/stat.c @@ -0,0 +1,124 @@ +/* + * l4/posix glue for open() + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) +#include +#include + +static inline int l4_fstat(int fd, void *buffer) +{ + int err; + + /* Pathname address on utcb page */ + write_mr(L4SYS_ARG0, fd); + write_mr(L4SYS_ARG1, (unsigned long)buffer); + + /* Call pager with open() request. Check ipc error. */ + if ((err = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_FSTAT)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + return err; + } + /* Check if syscall itself was successful */ + if ((err = l4_get_retval()) < 0) { + print_err("%s: FSTAT Error: %d.\n", __FUNCTION__, err); + return err; + } + return err; +} + +int kstat_to_stat(struct kstat *ks, struct stat *s) +{ + s->st_dev = 0; + s->st_ino = ks->vnum; + s->st_mode = ks->mode; + s->st_nlink = ks->links; + s->st_uid = ks->uid; + s->st_gid = ks->gid; + s->st_rdev = 0; + s->st_size = ks->size; + s->st_blksize = ks->blksize; + s->st_blocks = ks->size / ks->blksize; + s->st_atime = ks->atime; + s->st_mtime = ks->mtime; + s->st_ctime = ks->ctime; +} + +static inline int l4_stat(const char *pathname, void *buffer) +{ + int err; + struct kstat ks; + + copy_to_shpage((void *)pathname, 0, strlen(pathname) + 1); + + /* Pathname address on utcb page */ + write_mr(L4SYS_ARG0, (unsigned long)shared_page); + + /* Pass on buffer that should receive stat */ + write_mr(L4SYS_ARG1, (unsigned long)&ks); + + /* Call vfs with stat() request. Check ipc error. */ + if ((err = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_STAT)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + return err; + } + + /* Check if syscall itself was successful */ + if ((err = l4_get_retval()) < 0) { + print_err("%s: STAT Error: %d.\n", __FUNCTION__, err); + return err; + } + + /* Convert c0-style stat structure to posix stat */ + kstat_to_stat(&ks, buffer); + + return err; +} + +int fstat(int fd, struct stat *buffer) +{ + int ret; + + ret = l4_fstat(fd, buffer); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + /* else return value */ + return ret; + +} + +int stat(const char *pathname, struct stat *buffer) +{ + int ret; + + ret = l4_stat(pathname, buffer); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + /* else return value */ + return ret; + +} + diff --git a/conts/posix/libposix/time.c b/conts/posix/libposix/time.c new file mode 100644 index 0000000..0341bd7 --- /dev/null +++ b/conts/posix/libposix/time.c @@ -0,0 +1,18 @@ + +#include +#include +#include +#include + +int gettimeofday(struct timeval *tv, struct timezone *tz) +{ + int ret = l4_time(tv, 0); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + /* else return value */ + return ret; +} diff --git a/conts/posix/libposix/write.c b/conts/posix/libposix/write.c new file mode 100644 index 0000000..60d1cb6 --- /dev/null +++ b/conts/posix/libposix/write.c @@ -0,0 +1,54 @@ +/* + * l4/posix glue for write() + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include + +static inline int l4_write(int fd, const void *buf, size_t count) +{ + int wrcnt; + + write_mr(L4SYS_ARG0, fd); + write_mr(L4SYS_ARG1, (const unsigned long)buf); + write_mr(L4SYS_ARG2, count); + + /* Call pager with write() request. Check ipc error. */ + if ((wrcnt = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_WRITE)) < 0) { + print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, wrcnt); + return wrcnt; + } + /* Check if syscall itself was successful */ + if ((wrcnt = l4_get_retval()) < 0) { + print_err("%s: WRITE Error: %d.\n", __FUNCTION__, (int)wrcnt); + return wrcnt; + + } + return wrcnt; +} + +ssize_t write(int fd, const void *buf, size_t count) +{ + int ret; + + if (!count) + return 0; + + ret = l4_write(fd, buf, count); + + /* If error, return positive error code */ + if (ret < 0) { + errno = -ret; + return -1; + } + /* else return value */ + return ret; +} + diff --git a/conts/posix/mm0/SConscript b/conts/posix/mm0/SConscript new file mode 100644 index 0000000..f7e8790 --- /dev/null +++ b/conts/posix/mm0/SConscript @@ -0,0 +1,26 @@ + +Import('config', 'env', 'contid') + +import os, sys + +arch = config.arch + +def create_symlinks(arch): + arch_path = "include/arch" + arch_path2 ="src/arch" + if os.path.exists(arch_path): + os.system("rm %s" % (arch_path)) + os.system("ln -s %s %s" % ("arch-" + arch, arch_path)) + if os.path.exists(arch_path2): + os.system("rm %s" % (arch_path2)) + os.system("ln -s %s %s" % ("arch-" + arch, arch_path2)) + +src = [Glob('*.c') + Glob('src/*.c') + Glob('src/lib/*.c') + Glob('src/lib/elf/*.c') + Glob('src/arch/*.c')] + +e = env.Clone() + +e.Append(LINKFLAGS = ['-T' + "mm0/include/linker.lds", '-u_start']) +objs = e.Object(src) +mm0 = e.Program('mm0.elf', objs) + +Return('mm0') diff --git a/conts/posix/mm0/SConstruct b/conts/posix/mm0/SConstruct new file mode 100644 index 0000000..75cf22a --- /dev/null +++ b/conts/posix/mm0/SConstruct @@ -0,0 +1,64 @@ +# -*- mode: python; coding: utf-8; -*- +# +# Codezero -- Virtualization microkernel for embedded systems. +# +# Copyright © 2009 B Labs Ltd +# +import os, shelve, sys +from os.path import * + +PROJRELROOT = '../../../' + +sys.path.append(PROJRELROOT) + +from config.projpaths import * +from config.configuration import * + + +config = configuration_retrieve() +arch = config.arch + +LIBL4_RELDIR = 'conts/libl4' +KERNEL_INCLUDE = join(PROJROOT, 'include') +LIBL4_DIR = join(PROJROOT, LIBL4_RELDIR) +LIBL4_INCLUDE = join(LIBL4_DIR, 'include') +LIBL4_LIBPATH = join(BUILDDIR, LIBL4_RELDIR) + +# Locally important paths are here +LIBC_RELDIR = 'conts/libc' +LIBC_DIR = join(PROJROOT, LIBC_RELDIR) +LIBC_LIBPATH = join(BUILDDIR, LIBC_RELDIR) +LIBC_INCLUDE = [join(LIBC_DIR, 'include'), \ + join(LIBC_DIR, 'include/arch' + '/' + arch)] + + +env = Environment(CC = 'arm-none-linux-gnueabi-gcc', + # We don't use -nostdinc because sometimes we need standard headers, + # such as stdarg.h e.g. for variable args, as in printk(). + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', \ + '-std=gnu99', '-Wall', '-Werror'], + LINKFLAGS = ['-nostdlib', '-T' + "include/linker.lds", \ + LIBC_LIBPATH, LIBL4_LIBPATH, LIBMEM_LIBPATH], + ASFLAGS = ['-D__ASSEMBLY__'], + PROGSUFFIX = '.elf', # The suffix to use for final executable + ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path + LIBS = ['gcc', 'libl4', 'libc', 'libmm', 'libmc'], + CPPPATH = ["#include", LIBC_INCLUDE, KERNEL_INCLUDE, LIBL4_INCLUDE, LIBMEM_INCLUDE], + CPPFLAGS = '-include l4/config.h -include l4/macros.h -include l4/types.h -D__KERNEL__') + + + +def create_symlinks(arch): + arch_path = "include/arch" + arch_path2 ="src/arch" + if os.path.exists(arch_path): + os.system("rm %s" % (arch_path)) + os.system("ln -s %s %s" % ("arch-" + arch, arch_path)) + if os.path.exists(arch_path2): + os.system("rm %s" % (arch_path2)) + os.system("ln -s %s %s" % ("arch-" + arch, arch_path2)) + +src = Glob(['*.c', 'src/*.c', 'src/lib/*.c', 'src/lib/elf/*.c', 'src/arch/*.c']) + +objects = [] +mm0_elf = env.Program('mm0.elf', objects) diff --git a/conts/posix/mm0/SConstruct.orig b/conts/posix/mm0/SConstruct.orig new file mode 100644 index 0000000..f6001f0 --- /dev/null +++ b/conts/posix/mm0/SConstruct.orig @@ -0,0 +1,97 @@ +# +# User space application build script +# +# Copyright (C) 2007 Bahadir Balban +# +import os +import sys +import shutil +from string import split +from os.path import join +from glob import glob + +task_name = "mm0" + +# The root directory of the repository where this file resides: +project_root = "../.." +tools_root = join(project_root, "tools") +prev_image = join(project_root, "build/start.axf") +libs_path = join(project_root, "libs") +ld_script = "include/linker.lds" +physical_base_ld_script = "include/physical_base.lds" + +# libc paths: +libc_variant = "userspace" +libc_libpath = join(libs_path, "c/build/%s" % libc_variant) +libc_incpath = join(libc_libpath, "include") +libc_crt0 = join(libs_path, "c/build/crt/sys-userspace/arch-arm/crt0.o") +libc_name = "c-%s" % libc_variant + +# libl4 paths: +libl4_path = "../libl4" +libl4_incpath = join(libl4_path, "include") + +# libposix paths: +libposix_path = "../libposix" +libposix_incpath = join(libposix_path, "include") + +#libmem paths: +libmem_path = "../libmem" +libmem_incpath = "../libmem" + +# kernel paths: +kernel_incpath = join(project_root, "include") + +# Kernel config header. +config_h = join(project_root, "include/l4/config.h") + + +# If crt0 is in its library path, it becomes hard to link with it. +# For instance the linker script must use an absolute path for it. +def copy_crt0(source, target, env): + os.system("cp " + str(source[0]) + " " + str(target[0])) + +def get_physical_base(source, target, env): + os.system(join(tools_root, "pyelf/readelf.py --first-free-page " + \ + prev_image +" >> " + physical_base_ld_script)) + +# The kernel build environment: +env = Environment(CC = 'arm-none-linux-gnueabi-gcc', + # We don't use -nostdinc because sometimes we need standard headers, + # such as stdarg.h e.g. for variable args, as in printk(). + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', '-Werror' ], + LINKFLAGS = ['-nostdlib', '-T' + ld_script, "-L" + libc_libpath, "-L" + libl4_path, \ + "-L" + libposix_path, "-L" + libmem_path], + ASFLAGS = ['-D__ASSEMBLY__'], + PROGSUFFIX = '.axf', # The suffix to use for final executable + ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path + LIBS = [libc_name, 'libl4', 'libmm', 'libmc', 'libkm', 'libposix', \ + 'gcc', libc_name], # libgcc.a - This is required for division routines. + CPPFLAGS = "-D__USERSPACE__", + CPPPATH = ['#include', libl4_incpath, libc_incpath, kernel_incpath, \ + libmem_incpath, libposix_incpath]) + + +def create_symlinks(arch): + arch_path = "include/arch" + arch_path2 ="src/arch" + if os.path.exists(arch_path): + os.system("rm %s" % (arch_path)) + os.system("ln -s %s %s" % ("arch-" + arch, arch_path)) + if os.path.exists(arch_path2): + os.system("rm %s" % (arch_path2)) + os.system("ln -s %s %s" % ("arch-" + arch, arch_path2)) + +arch, subarch, plat = extract_arch_subarch_plat(config_h) + +create_symlinks(arch) # Creates symlinks to architecture specific directories. + +src = [glob("src/*.c"), glob("src/lib/*.c"), glob("src/lib/elf/*.c"), glob("*.c"), glob("src/arch/*.c")] +objs = env.Object(src) +physical_base = env.Command(physical_base_ld_script, prev_image, get_physical_base) +crt0_copied = env.Command("crt0.o", libc_crt0, copy_crt0) + +task = env.Program(task_name, objs + [crt0_copied]) +env.Alias(task_name, task) +env.Depends(task, physical_base) + diff --git a/conts/posix/mm0/TODO b/conts/posix/mm0/TODO new file mode 100644 index 0000000..937235b --- /dev/null +++ b/conts/posix/mm0/TODO @@ -0,0 +1,15 @@ +MM0 TODO List: + +1.) Bootmem needs to be freed. +2.) Virtual memory regions available as capabilities need to be dynamically + allocated to various purposes, i.e. task region, shared memory region, + utcb region, etc. by traversing each region and matching to purposes. +3.) virt_to_phys()/phys_to_virt() uses the fixed offset of INITTASK_OFFSET, this + either needs to be discovered at run-time or specified at config-time. +4.) pager_new_address()/pager_delete_address() needs to use a region inside + pager start/end regions, and virt_to_phys()/phys_to_virt() should not clash + with those regions. +5.) read_file_pages()/write_file_pages() needs to be tested and improved in + terms of syscalls to microkernel. + +(1,3,4) Done. diff --git a/conts/posix/mm0/container.c b/conts/posix/mm0/container.c new file mode 100644 index 0000000..2b7d1f2 --- /dev/null +++ b/conts/posix/mm0/container.c @@ -0,0 +1,28 @@ +/* + * Container entry point for pager + * + * Copyright (C) 2007-2009 Bahadir Bilgehan Balban + */ + +#include +#include +#include + +/* + * Application specific utcb allocation + * for this container. + * + * Copyright (C) 2007-2009 Bahadir Balban + */ + +void main(void); + +void __container_init(void) +{ + /* Generic L4 initialisation */ + __l4_init(); + + /* Entry to main */ + main(); +} + diff --git a/conts/posix/mm0/include/.scons14415 b/conts/posix/mm0/include/.scons14415 new file mode 100644 index 0000000..12bb91e Binary files /dev/null and b/conts/posix/mm0/include/.scons14415 differ diff --git a/conts/posix/mm0/include/arch b/conts/posix/mm0/include/arch new file mode 120000 index 0000000..85405c2 --- /dev/null +++ b/conts/posix/mm0/include/arch @@ -0,0 +1 @@ +arch-arm \ No newline at end of file diff --git a/conts/posix/mm0/include/arch-arm/mm.h b/conts/posix/mm0/include/arch-arm/mm.h new file mode 100644 index 0000000..54fbe66 --- /dev/null +++ b/conts/posix/mm0/include/arch-arm/mm.h @@ -0,0 +1,16 @@ +#ifndef __INITTASK_ARCH_MM_H__ +#define __INITTASK_ARCH_MM_H__ + +#include +#include +#include +#include INC_GLUE(memory.h) +#include + +#define INITTASK_ADDR(x) ((x >= INITTASK_AREA_START) && (x < INITTASK_AREA_END)) + +struct fault_data; +unsigned int vm_prot_flags(pte_t pte); +void set_generic_fault_params(struct fault_data *fault); + +#endif /* __INITTASK_ARCH_MM_H__ */ diff --git a/conts/posix/mm0/include/arch-arm/offsets.h b/conts/posix/mm0/include/arch-arm/offsets.h new file mode 100644 index 0000000..78cdfda --- /dev/null +++ b/conts/posix/mm0/include/arch-arm/offsets.h @@ -0,0 +1,9 @@ +#ifndef __INITTASK_ARCH_OFFSETS_H__ +#define __INITTASK_ARCH_OFFSETS_H__ + +#define INITTASK_AREA_START 0xE0000000 +#define INITTASK_AREA_END 0xF0000000 + +#define INITTASK_OFFSET INITTASK_AREA_START + +#endif diff --git a/conts/posix/mm0/include/boot.h b/conts/posix/mm0/include/boot.h new file mode 100644 index 0000000..62533f7 --- /dev/null +++ b/conts/posix/mm0/include/boot.h @@ -0,0 +1,28 @@ +#ifndef __BOOT_H__ +#define __BOOT_H__ + +#include +#include + +/* Structures to use when sending new task information to vfs */ +struct task_data { + unsigned long tid; + unsigned long shpage_address; +}; + +struct task_data_head { + unsigned long total; + struct task_data tdata[]; +}; + +int boottask_setup_regions(struct vm_file *file, struct tcb *task, + unsigned long task_start, unsigned long task_end); + +int boottask_mmap_regions(struct tcb *task, struct vm_file *file); + +struct tcb *boottask_exec(struct vm_file *f, unsigned long task_region_start, + unsigned long task_region_end, struct task_ids *ids); + +int vfs_send_task_data(struct tcb *vfs); + +#endif /* __BOOT_H__ */ diff --git a/conts/posix/mm0/include/bootdesc.h b/conts/posix/mm0/include/bootdesc.h new file mode 100644 index 0000000..5c39f79 --- /dev/null +++ b/conts/posix/mm0/include/bootdesc.h @@ -0,0 +1,21 @@ +#ifndef __BOOTDESC_H__ +#define __BOOTDESC_H__ + +/* Supervisor task at load time. */ +struct svc_image { + char name[16]; + unsigned int phys_start; + unsigned int phys_end; +} __attribute__((__packed__)); + +/* Supervisor task descriptor at load time */ +struct bootdesc { + int desc_size; + int total_images; + struct svc_image images[]; +} __attribute__((__packed__)); + +struct initdata; +void read_bootdesc(struct initdata *initdata); + +#endif /* __BOOTDESC_H__ */ diff --git a/conts/posix/mm0/include/bootm.h b/conts/posix/mm0/include/bootm.h new file mode 100644 index 0000000..c342b35 --- /dev/null +++ b/conts/posix/mm0/include/bootm.h @@ -0,0 +1,9 @@ +#ifndef __PAGER_BOOTM_H__ +#define __PAGER_BOOTM_H__ + +#define __initdata SECTION(".init.data") + +void *alloc_bootmem(int size, int alignment); + + +#endif /* __PAGER_BOOTM_H__ */ diff --git a/conts/posix/mm0/include/capability.h b/conts/posix/mm0/include/capability.h new file mode 100644 index 0000000..6fe1a59 --- /dev/null +++ b/conts/posix/mm0/include/capability.h @@ -0,0 +1,44 @@ +/* + * Capability-related operations of the pager. + * + * Copyright (C) 2009 Bahadir Balban + */ +#ifndef __MM0_CAPABILITY_H__ +#define __MM0_CAPABILITY_H__ + +#include +#include + +struct cap_list { + int ncaps; + struct link caps; +}; + +struct capability { + struct link list; + + /* Capability identifiers */ + l4id_t capid; /* Unique capability ID */ + l4id_t resid; /* Targeted resource ID */ + l4id_t owner; /* Capability owner ID */ + unsigned int type; /* Capability and target resource type */ + + /* Capability limits/permissions */ + u32 access; /* Permitted operations */ + + /* Limits on the resource */ + unsigned long start; /* Resource start value */ + unsigned long end; /* Resource end value */ + unsigned long size; /* Resource size */ + + unsigned long used; /* Resource used size */ +}; + + +extern struct cap_list capability_list; + +struct initdata; +int read_kernel_capabilities(struct initdata *); +void copy_boot_capabilities(struct initdata *initdata); + +#endif /* __MM0_CAPABILITY_H__ */ diff --git a/conts/posix/mm0/include/clone.h b/conts/posix/mm0/include/clone.h new file mode 100644 index 0000000..c79768a --- /dev/null +++ b/conts/posix/mm0/include/clone.h @@ -0,0 +1,17 @@ +#ifndef __CLONE_H__ +#define __CLONE_H__ + +/* Linux clone() system call flags */ +#define CLONE_VM 0x100 +#define CLONE_FS 0x200 +#define CLONE_FILES 0x400 +#define CLONE_SIGHAND 0x800 +#define CLONE_VFORK 0x4000 +#define CLONE_PARENT 0x8000 +#define CLONE_THREAD 0x10000 +#define CLONE_NEWNS 0x20000 +#define CLONE_STOPPED 0x2000000 + +#endif /* __CLONE_H__ */ + + diff --git a/conts/posix/mm0/include/exec.h b/conts/posix/mm0/include/exec.h new file mode 100644 index 0000000..4ca1381 --- /dev/null +++ b/conts/posix/mm0/include/exec.h @@ -0,0 +1,25 @@ +/* + * Definitions for executables + * + * Copyright (C) 2008 Bahadir Balban + */ +#ifndef __EXEC_H__ +#define __EXEC_H__ + +/* + * This presents extra executable file information that is + * not present in the tcb, in a generic format. + */ +struct exec_file_desc { + unsigned long text_offset; /* File offset of text section */ + unsigned long data_offset; /* File offset of data section */ + unsigned long bss_offset; /* File offset of bss section */ +}; + +struct args_struct { + int argc; + char **argv; + int size; /* Size of strings + string pointers */ +}; + +#endif /* __EXEC_H__ */ diff --git a/conts/posix/mm0/include/exit.h b/conts/posix/mm0/include/exit.h new file mode 100644 index 0000000..9965a06 --- /dev/null +++ b/conts/posix/mm0/include/exit.h @@ -0,0 +1,13 @@ +/* + * Definitions for do_exit() flags + * + * Copyright (C) 2008 Bahadir Balban + */ + +#ifndef __EXIT_H__ +#define __EXIT_H__ + +void do_exit(struct tcb *task, int status); +int execve_recycle_task(struct tcb *new, struct tcb *orig); + +#endif /* __EXIT_H__ */ diff --git a/conts/posix/mm0/include/file.h b/conts/posix/mm0/include/file.h new file mode 100644 index 0000000..f14565f --- /dev/null +++ b/conts/posix/mm0/include/file.h @@ -0,0 +1,38 @@ +#ifndef __MM0_FILE_H__ +#define __MM0_FILE_H__ + +#include +#include +#include +#include + +int vfs_read(unsigned long vnum, unsigned long f_offset, unsigned long npages, + void *pagebuf); +int vfs_write(unsigned long vnum, unsigned long f_offset, unsigned long npages, + void *pagebuf); +int sys_read(struct tcb *sender, int fd, void *buf, int count); +int sys_write(struct tcb *sender, int fd, void *buf, int count); +int sys_lseek(struct tcb *sender, int fd, off_t offset, int whence); +int sys_close(struct tcb *sender, int fd); +int sys_fsync(struct tcb *sender, int fd); +int file_open(struct tcb *opener, int fd); + +int vfs_open_bypath(const char *pathname, unsigned long *vnum, unsigned long *length); + +struct vm_file *do_open2(struct tcb *task, int fd, unsigned long vnum, unsigned long length); +int flush_file_pages(struct vm_file *f); +int read_file_pages(struct vm_file *vmfile, unsigned long pfn_start, + unsigned long pfn_end); + +struct vfs_file_data { + unsigned long vnum; +}; + +#define vm_file_to_vnum(f) \ + (((struct vfs_file_data *)((f)->priv_data))->vnum) +struct vm_file *vfs_file_create(void); + + +extern struct link vm_file_list; + +#endif /* __MM0_FILE_H__ */ diff --git a/conts/posix/mm0/include/globals.h b/conts/posix/mm0/include/globals.h new file mode 100644 index 0000000..50f588d --- /dev/null +++ b/conts/posix/mm0/include/globals.h @@ -0,0 +1,13 @@ +#ifndef __GLOBALS_H__ +#define __GLOBALS_H__ + +struct global_list { + int total; + struct link list; +}; + +extern struct global_list global_vm_files; +extern struct global_list global_vm_objects; +extern struct global_list global_tasks; + +#endif /* __GLOBALS_H__ */ diff --git a/conts/posix/mm0/include/init.h b/conts/posix/mm0/include/init.h new file mode 100644 index 0000000..c436575 --- /dev/null +++ b/conts/posix/mm0/include/init.h @@ -0,0 +1,39 @@ +/* + * Data that comes from the kernel, and other init data. + * + * Copyright (C) 2007 Bahadir Balban + */ +#ifndef __MM_INIT_H__ +#define __MM_INIT_H__ + +#include +#include +#include +#include INC_PLAT(offsets.h) +#include INC_GLUE(memory.h) +#include INC_GLUE(memlayout.h) +#include +#include +#include +#include + +struct initdata { + struct capability *bootcaps; + struct capability *physmem; + struct bootdesc *bootdesc; + struct page_bitmap *page_map; + unsigned long pager_utcb_virt; + unsigned long pager_utcb_phys; + struct link boot_file_list; +}; + +extern struct initdata initdata; + +void init_pager(void); + +/* TODO: Remove this stuff from here. */ +int init_devzero(void); +struct vm_file *get_devzero(void); +int init_boot_files(struct initdata *initdata); + +#endif /* __MM_INIT_H__ */ diff --git a/conts/posix/mm0/include/lib/addr.h b/conts/posix/mm0/include/lib/addr.h new file mode 100644 index 0000000..774a1ce --- /dev/null +++ b/conts/posix/mm0/include/lib/addr.h @@ -0,0 +1,26 @@ +/* + * Address allocation pool + * + * Copyright (C) 2007 Bahadir Balban + */ +#ifndef __ADDR_H__ +#define __ADDR_H__ + +#include + +/* Address pool to allocate from a range of addresses */ +struct address_pool { + struct id_pool *idpool; + unsigned long start; + unsigned long end; +}; + +int address_pool_init_with_idpool(struct address_pool *pool, + struct id_pool *idpool, + unsigned long start, unsigned long end); +int address_pool_init(struct address_pool *pool, unsigned long start, + unsigned long end); +void *address_new(struct address_pool *pool, int npages); +int address_del(struct address_pool *, void *addr, int npages); + +#endif /* __ADDR_H__ */ diff --git a/conts/posix/mm0/include/lib/bit.h b/conts/posix/mm0/include/lib/bit.h new file mode 100644 index 0000000..ab58671 --- /dev/null +++ b/conts/posix/mm0/include/lib/bit.h @@ -0,0 +1,44 @@ +#ifndef __LIB_BIT_H__ +#define __LIB_BIT_H__ + +#include + +unsigned int __clz(unsigned int bitvector); +int find_and_set_first_free_bit(u32 *word, unsigned int lastbit); +int find_and_set_first_free_contig_bits(u32 *word, unsigned int limit, + int nbits); +int check_and_clear_bit(u32 *word, int bit); +int check_and_clear_contig_bits(u32 *word, int first, int nbits); +int check_and_set_bit(u32 *word, int bit); + + +/* Set */ +static inline void setbit(unsigned int *w, unsigned int flags) +{ + *w |= flags; +} + + +/* Clear */ +static inline void clrbit(unsigned int *w, unsigned int flags) +{ + *w &= ~flags; +} + +/* Test */ +static inline int tstbit(unsigned int *w, unsigned int flags) +{ + return *w & flags; +} + +/* Test and clear */ +static inline int tstclr(unsigned int *w, unsigned int flags) +{ + int res = tstbit(w, flags); + + clrbit(w, flags); + + return res; +} + +#endif /* __LIB_BIT_H__ */ diff --git a/conts/posix/mm0/include/lib/elf/elf.h b/conts/posix/mm0/include/lib/elf/elf.h new file mode 100644 index 0000000..d48949c --- /dev/null +++ b/conts/posix/mm0/include/lib/elf/elf.h @@ -0,0 +1,64 @@ +/* + * Definitions for Executable Linking Format + * Based on Portable Formats Specification v1.1 + * + * Copyright (C) 2008 Bahadir Balban + */ + +#ifndef __ELF_H__ +#define __ELF_H__ + +#include + +/* ELF identification indices */ +#define EI_MAG0 0 +#define EI_MAG1 1 +#define EI_MAG2 2 +#define EI_MAG3 3 +#define EI_CLASS 4 +#define EI_DATA 5 +#define EI_VERSION 6 +#define EI_PAD 7 + +/* Size of ELF identification field */ +#define EI_NIDENT 16 + +/* Values for ELF identification fields */ +#define ELFMAG0 0x7f +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' + +/* Values for the ELF Class field */ +#define ELFCLASSNONE 0 +#define ELFCLASS32 1 +#define ELFCLASS64 2 + +/* Values for the ELF Data field */ +#define ELFDATANONE 0 +#define ELFDATA2LSB 1 +#define ELFDATA2MSB 2 + + +struct elf_header { + u8 e_ident[EI_NIDENT]; /* ELF identification */ + u16 e_type; /* Object file type */ + u16 e_machine; /* Machine architecture */ + u32 e_version; /* Object file version */ + u32 e_entry; /* Virtual entry address */ + u32 e_phoff; /* Program header offset */ + u32 e_shoff; /* Section header offset */ + u32 e_flags; /* Processor specific flags */ + u16 e_ehsize; /* ELF header size */ + u16 e_phentsize; /* Program header entry size */ + u16 e_phnum; /* Number of program headers */ + u16 e_shentsize; /* Section header entry size */ + u16 e_shnum; /* Number of section headers */ + u16 e_shstrndx; /* Shtable index for strings */ +} __attribute__((__packed__)); + + +int elf_parse_executable(struct tcb *task, struct vm_file *file, + struct exec_file_desc *efd); + +#endif /* __ELF_H__ */ diff --git a/conts/posix/mm0/include/lib/elf/elfprg.h b/conts/posix/mm0/include/lib/elf/elfprg.h new file mode 100644 index 0000000..2426a09 --- /dev/null +++ b/conts/posix/mm0/include/lib/elf/elfprg.h @@ -0,0 +1,35 @@ +/* + * Definitions for ELF program headers + * Based on Portable Formats Specification v1.1 + * + * Copyright (C) 2008 Bahadir Balban + */ +#ifndef __ELFPRG_H__ +#define __ELFPRG_H__ + +#include + +struct elf_program_header { + u32 p_type; /* Type of segment */ + u32 p_offset; /* Segment file offset */ + u32 p_vaddr; /* Virtual start address */ + u32 p_paddr; /* Physical start address */ + u32 p_filesz; /* Size in stored file */ + u32 p_memsz; /* Size in memory image */ + u32 p_flags; /* Segment attributes */ + u32 p_align; /* Alignment requirement */ +} __attribute__((__packed__)); + +/* Program segment type definitions */ +#define PT_NULL 0 +#define PT_LOAD 1 +#define PT_DYNAMIC 2 +#define PT_INTERP 3 +#define PT_NOTE 4 +#define PT_SHLIB 5 +#define PT_PHDR 6 +#define PT_LOPROC 0x70000000 +#define PT_HIPROC 0x7FFFFFFF + + +#endif /* __ELFPRG_H__ */ diff --git a/conts/posix/mm0/include/lib/elf/elfsect.h b/conts/posix/mm0/include/lib/elf/elfsect.h new file mode 100644 index 0000000..033ba07 --- /dev/null +++ b/conts/posix/mm0/include/lib/elf/elfsect.h @@ -0,0 +1,60 @@ +/* + * Definitions for ELF Sections + * Based on Portable Formats Specification v1.1 + * + * Copyright (C) 2008 Bahadir Balban + */ + +#ifndef __ELFSECT_H__ +#define __ELFSECT_H__ + +#include + +/* Special section indices */ +#define SHN_UNDEF 0 +#define SHN_LORESERVE 0xFF00 +#define SHN_LOPROC 0xFF00 +#define SHN_HIPROC 0xFF1F +#define SHN_ABS 0xFFF1 +#define SHN_COMMON 0xFFF2 +#define SHN_HIRESERVE 0xFFFF + + +struct elf_section_header { + u32 sh_name; /* Index to section header str table for name */ + u32 sh_type; /* Categorises section's semantics */ + u32 sh_flags; /* Flags that define various attributes */ + u32 sh_addr; /* Virtual address for section */ + u32 sh_offset; /* Offset to contents from file beginning */ + u32 sh_size; /* Size of section (note SHT_NOBITS) */ + u32 sh_link; + u32 sh_info; /* Extra section info */ + u32 sh_addralign; /* Section alignment in power of 2 */ + u32 sh_entsize; /* Size of each entry if fixed */ +} __attribute__((__packed__)); + +/* Section type codes */ +#define SHT_NULL 0 /* Inactive */ +#define SHT_PROGBITS 1 /* Program contents */ +#define SHT_SYMTAB 2 /* Symbol table */ +#define SHT_STRTAB 3 /* String table */ +#define SHT_RELA 4 /* Relocation entries */ +#define SHT_HASH 5 /* Symbol hash table */ +#define SHT_DYNAMIC 6 /* Dynamic linking info */ +#define SHT_NOTE 7 /* Optional, additional info */ +#define SHT_NOBITS 8 /* Does not occupy file space */ +#define SHT_REL 9 /* Relocation entries */ +#define SHT_SHLIB 10 /* Reserved */ +#define SHT_DYNSYM 11 /* Symbols for dynamic linking */ +#define SHT_LOPROC 0x70000000 /* Reserved for processors */ +#define SHT_HIPROC 0x7FFFFFFF /* Reserved for processors */ +#define SHT_LOUSER 0x80000000 /* Reserved for user progs */ +#define SHT_HIUSER 0xFFFFFFFF /* Reserved for user progs */ + +/* Section attribute flags */ +#define SHF_WRITE (1 << 0) /* Writeable */ +#define SHF_ALLOC (1 << 1) /* Occupies actual memory */ +#define SHF_EXECINSTR (1 << 2) /* Executable */ +#define SHF_MASCPROC 0xF0000000 /* Reserved for processors */ + +#endif /* __ELFSECT_H__ */ diff --git a/conts/posix/mm0/include/lib/elf/elfsym.h b/conts/posix/mm0/include/lib/elf/elfsym.h new file mode 100644 index 0000000..c3a3353 --- /dev/null +++ b/conts/posix/mm0/include/lib/elf/elfsym.h @@ -0,0 +1,59 @@ +/* + * Definitions for ELF Symbol tables, symbols + * Based on Portable Formats Specification v1.1 + * + * Copyright (C) 2008 Bahadir Balban + */ +#ifndef __ELFSYM_H__ +#define __ELFSYM_H__ + +#include + +struct elf_symbol_entry { + u32 st_name; /* Index into string table */ + u32 st_value; /* Symbol value; address, aboslute etc. */ + u32 st_size; /* Number of bytes contained in object */ + u8 st_info; /* Type and binding attributes */ + u8 st_other; /* Unused, 0 */ + u16 st_shndx; /* Section header index associated with entry */ +} __attribute__((__packed__)); + +/* To manipulate binding and type attributes on st_info field */ +#define ELF32_ST_BIND(i) ((i) >> 4) +#define ELF32_ST_TYPE(i) ((i) & 0xF) +#define ELF32_ST_INFO(b, t) (((b) << 4) + ((t) & 0xF)) + +/* Symbol binding codes */ +#define STB_LOCAL 0 +#define STB_GLOBAL 1 +#define STB_WEAK 2 +#define STB_LOPROC 13 +#define STB_HIPROC 15 + +/* Symbol types */ +#define STT_NOTYPE 0 +#define STT_OBJECT 1 +#define STT_FUNC 2 +#define STT_SECTION 3 +#define STT_FILE 4 +#define STT_LOPROC 13 +#define STT_HIPROC 15 + +/* Relocation structures */ +struct elf_rel { + u32 r_offset; + u32 r_info; +} __attribute__((__packed__)); + +struct elf_rela { + u32 r_offset; + u32 r_info; + s32 r_addend; +} __attribute__((__packed__)); + +/* Macros to manipulate r_info field */ +#define ELF32_R_SYM(i) ((i) >> 8) +#define ELF32_R_TYPE(i) ((u8)(i)) +#define ELF32_R_INFO(s,t) (((s) << 8) + (u8)(t)) + +#endif /* __ELFSYM_H__ */ diff --git a/conts/posix/mm0/include/lib/idpool.h b/conts/posix/mm0/include/lib/idpool.h new file mode 100644 index 0000000..b66424f --- /dev/null +++ b/conts/posix/mm0/include/lib/idpool.h @@ -0,0 +1,21 @@ +#ifndef __MM0_IDPOOL_H__ +#define __MM0_IDPOOL_H__ + +#include +#include + +struct id_pool { + int nwords; + int bitlimit; + u32 bitmap[]; +}; + +struct id_pool *id_pool_new_init(int mapsize); +int id_new(struct id_pool *pool); +int id_del(struct id_pool *pool, int id); +int id_get(struct id_pool *pool, int id); +int id_is_empty(struct id_pool *pool); +int ids_new_contiguous(struct id_pool *pool, int numids); +int ids_del_contiguous(struct id_pool *pool, int first, int numids); + +#endif /* __MM0_IDPOOL_H__ */ diff --git a/conts/posix/mm0/include/lib/malloc.h b/conts/posix/mm0/include/lib/malloc.h new file mode 100644 index 0000000..7def53a --- /dev/null +++ b/conts/posix/mm0/include/lib/malloc.h @@ -0,0 +1,20 @@ +#ifndef __PRIVATE_MALLOC_H__ +#define __PRIVATE_MALLOC_H__ + +#include +#include +#include + +void *kmalloc(size_t size); +void kfree(void *blk); + +static inline void *kzalloc(size_t size) +{ + void *buf = kmalloc(size); + + memset(buf, 0, size); + return buf; +} + + +#endif /*__PRIVATE_MALLOC_H__ */ diff --git a/conts/posix/mm0/include/lib/spinlock.h b/conts/posix/mm0/include/lib/spinlock.h new file mode 100644 index 0000000..7a61930 --- /dev/null +++ b/conts/posix/mm0/include/lib/spinlock.h @@ -0,0 +1,17 @@ +/* + * Fake spinlock for future multi-threaded mm0 + */ +#ifndef __MM0_SPINLOCK_H__ +#define __MM0_SPINLOCK_H__ + + + +struct spinlock { + int lock; +}; + +static inline void spin_lock_init(struct spinlock *s) { } +static inline void spin_lock(struct spinlock *s) { } +static inline void spin_unlock(struct spinlock *s) { } + +#endif /* __MM0_SPINLOCK_H__ */ diff --git a/conts/posix/mm0/include/linker.lds b/conts/posix/mm0/include/linker.lds new file mode 100644 index 0000000..190f2fe --- /dev/null +++ b/conts/posix/mm0/include/linker.lds @@ -0,0 +1,57 @@ +/* + * Simple linker script for userspace or svc tasks. + * + * Copyright (C) 2007 Bahadir Balban + */ + +/* + * The only catch with this linker script is that everything + * is linked starting at virtual_base, and loaded starting + * at physical_base. virtual_base is the predefined region + * of virtual memory for userland applications. physical_base + * is determined at build-time, it is one of the subsequent pages + * that come after the kernel image's load area. + */ +/* INITTASK_AREA_START, see memlayout.h */ +virtual_base = 0xE0000000; +physical_base = 0x8000; + +/* INCLUDE "include/physical_base.lds" */ + +/* physical_base = 0x228000; */ +pager_offset = virtual_base - physical_base; + +ENTRY(_start) + +SECTIONS +{ + . = virtual_base; + _start_text = .; + .text : AT (ADDR(.text) - pager_offset) { *(.text.head) *(.text) } + /* rodata is needed else your strings will link at physical! */ + .rodata : AT (ADDR(.rodata) - pager_offset) { *(.rodata) } + .rodata1 : AT (ADDR(.rodata1) - pager_offset) { *(.rodata1) } + .data : AT (ADDR(.data) - pager_offset) + { + *(.data) + } + .bss : AT (ADDR(.bss) - pager_offset) { *(.bss) } + . = ALIGN(4K); + . += 0x2000; /* BSS doesnt increment link counter??? */ + .stack : AT (ADDR(.stack) - pager_offset) + { + *(.stack) + } + . = ALIGN(4K); + __stack = .; /* This is the preallocated boot stack */ + + /* Below part is to be discarded after boot */ + _start_init = .; + .init : AT (ADDR(.init) - pager_offset) + { + *(.init.data) + *(.init.bootmem) + } + _end_init = .; + _end = .; +} diff --git a/conts/posix/mm0/include/memory.h b/conts/posix/mm0/include/memory.h new file mode 100644 index 0000000..1db0198 --- /dev/null +++ b/conts/posix/mm0/include/memory.h @@ -0,0 +1,32 @@ +/* + * Physical page descriptor + * + * Copyright (C) 2007 Bahadir Balban + */ +#ifndef __MEMORY_H__ +#define __MEMORY_H__ + +#include +#include +#include + +void init_mm_descriptors(struct page_bitmap *page_map, + struct bootdesc *bootdesc, struct membank *membank); +void init_physmem(struct initdata *initdata, struct membank *membank); + +int pager_address_pool_init(void); +void *pager_new_address(int npages); +int pager_delete_address(void *virt_addr, int npages); +void *pager_map_pages(struct vm_file *f, unsigned long page_offset, unsigned long npages); +void pager_unmap_pages(void *addr, unsigned long npages); +void *pager_map_page(struct vm_file *f, unsigned long page_offset); +void pager_unmap_page(void *addr); +void *pager_map_file_range(struct vm_file *f, unsigned long byte_offset, + unsigned long size); +void *pager_validate_map_user_range2(struct tcb *user, void *userptr, + unsigned long size, unsigned int vm_flags); + +void *l4_new_virtual(int npages); +void *l4_del_virtual(void *virt, int npages); + +#endif /* __MEMORY_H__ */ diff --git a/conts/posix/mm0/include/mmap.h b/conts/posix/mm0/include/mmap.h new file mode 100644 index 0000000..af663d1 --- /dev/null +++ b/conts/posix/mm0/include/mmap.h @@ -0,0 +1,35 @@ +/* + * Prototypes for mmap/munmap functions that do the actual work. + * + * Copyright (C) 2007 Bahadir Balban + */ +#ifndef __MM0_MMAP_H__ +#define __MM0_MMAP_H__ + +#include +#include + +/* POSIX-defined mmap flags */ +#define PROT_READ 0x1 +#define PROT_WRITE 0x2 +#define PROT_EXEC 0x4 +#define PROT_NONE 0x0 + +#define MAP_ANONYMOUS 0x20 +#define MAP_FIXED 0x10 +#define MAP_SHARED 0x01 +#define MAP_PRIVATE 0x02 +#define MAP_GROWSDOWN 0x00100 + +struct vm_area *vma_new(unsigned long pfn_start, unsigned long npages, + unsigned int flags, unsigned long file_offset); + +int do_munmap(struct tcb *task, unsigned long vaddr, unsigned long size); + +void *do_mmap(struct vm_file *mapfile, unsigned long f_offset, struct tcb *t, + unsigned long map_address, unsigned int flags, unsigned int pages); + +int mmap_address_validate(struct tcb *t, unsigned long map_address, + unsigned int vm_flags); + +#endif /* __MM0_MMAP_H__ */ diff --git a/conts/posix/mm0/include/physmem.h b/conts/posix/mm0/include/physmem.h new file mode 100644 index 0000000..698be40 --- /dev/null +++ b/conts/posix/mm0/include/physmem.h @@ -0,0 +1,45 @@ +/* + * Physical memory descriptors + * + * Copyright (C) 2007 - 2009 Bahadir Balban + */ +#ifndef __PAGER_PHYSMEM_H__ +#define __PAGER_PHYSMEM_H__ + +/* A compact memory descriptor to determine used/unused pages in the system */ +struct page_bitmap { + unsigned long pfn_start; + unsigned long pfn_end; + unsigned int map[]; +}; + +/* Describes a portion of physical memory. */ +struct memdesc { + unsigned int start; + unsigned int end; + unsigned int free_cur; + unsigned int free_end; + unsigned int numpages; +}; + +struct membank { + unsigned long start; + unsigned long end; + unsigned long free; + struct page *page_array; +}; +extern struct membank membank[]; + +/* Describes bitmap of used/unused state for all physical pages */ +extern struct page_bitmap page_map; +extern struct memdesc physmem; + +/* Sets the global page map as used/unused. Aligns input when needed. */ +int set_page_map(struct page_bitmap *pmap, unsigned long start, + int numpages, int val); + +struct initdata; +void init_physmem_primary(struct initdata *initdata); +void init_physmem_secondary(struct initdata *initdata, struct membank *membank); + +#endif /* __PAGER_PHYSMEM_H__ */ diff --git a/conts/posix/mm0/include/shm.h b/conts/posix/mm0/include/shm.h new file mode 100644 index 0000000..56dcd94 --- /dev/null +++ b/conts/posix/mm0/include/shm.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2008 Bahadir Balban + */ +#ifndef __SHM_H__ +#define __SHM_H__ + +#include +#include +#include +#include +#include +#include +#include +#include + +struct shm_descriptor { + int key; + l4id_t shmid; + void *shm_addr; + unsigned long npages; + struct vm_file *devzero; +}; + +#if 0 +struct shm_descriptor { + int key; /* IPC key supplied by user task */ + l4id_t shmid; /* SHM area id, allocated by mm0 */ + struct link list; /* SHM list, used by mm0 */ + struct vm_file *owner; + void *shm_addr; /* The virtual address for segment. */ + unsigned long size; /* Size of the area in pages */ + unsigned int flags; + int refcnt; +}; +#endif + +#define SHM_AREA_MAX 64 /* Up to 64 shm areas */ + +/* Up to 10 pages per area, and at least 1 byte (implies 1 page) */ +#define SHM_SHMMIN 1 +#define SHM_SHMMAX 10 + +/* Initialises shared memory bookkeeping structures */ +int shm_pool_init(); + +void *shmat_shmget_internal(struct tcb *task, key_t key, void *shmaddr); +struct vm_file *shm_new(key_t key, unsigned long npages); +void *shm_new_address(int npages); + + +/* Below is the special-case per-task default shared memory page prototypes */ + +/* Prefaults shared page after mapping */ +#define SHPAGE_PREFAULT (1 << 0) + +/* Creates new shm segment for default shpage */ +#define SHPAGE_NEW_SHM (1 << 1) + +/* Allocates a virtual address for default shpage */ +#define SHPAGE_NEW_ADDRESS (1 << 2) + +/* IPC to send utcb address information to tasks */ +void *task_send_shpage_address(struct tcb *sender, l4id_t taskid); + +int shpage_map_to_task(struct tcb *owner, struct tcb *mapper, unsigned int flags); +int shpage_unmap_from_task(struct tcb *owner, struct tcb *mapper); + +/* Prefault a *mmaped* default shared page */ +int shpage_prefault(struct tcb *task, unsigned int vmflags); + +#endif /* __SHM_H__ */ diff --git a/conts/posix/mm0/include/syscalls.h b/conts/posix/mm0/include/syscalls.h new file mode 100644 index 0000000..e2610cb --- /dev/null +++ b/conts/posix/mm0/include/syscalls.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2007 Bahadir Balban + * + * MM0 Posix system call prototypes and structure + * definitions for converting data in message registers + * into system call argument format. + */ + +#ifndef __MM0_SYSARGS_H__ +#define __MM0_SYSARGS_H__ + +#include +#include +#include + +/* For reading argument data from a system call */ +struct sys_mmap_args { + void *start; + size_t length; + int prot; + int flags; + int fd; + off_t offset; +}; + +void *sys_mmap(struct tcb *task, struct sys_mmap_args *args); +int sys_munmap(struct tcb *sender, void *vaddr, unsigned long size); +int sys_msync(struct tcb *task, void *start, unsigned long length, int flags); +void *sys_shmat(struct tcb *task, l4id_t shmid, const void *shmadr, int shmflg); +int sys_shmdt(struct tcb *requester, const void *shmaddr); + +int sys_shmget(key_t key, int size, int shmflg); + +int sys_execve(struct tcb *sender, char *pathname, char *argv[], char *envp[]); +int sys_fork(struct tcb *parent); +int sys_clone(struct tcb *parent, void *child_stack, unsigned int clone_flags); +void sys_exit(struct tcb *task, int status); + +#endif /* __MM0_SYSARGS_H__ */ + diff --git a/conts/posix/mm0/include/task.h b/conts/posix/mm0/include/task.h new file mode 100644 index 0000000..5e420c2 --- /dev/null +++ b/conts/posix/mm0/include/task.h @@ -0,0 +1,157 @@ +/* + * Thread control block. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ +#ifndef __TASK_H__ +#define __TASK_H__ + +#include +#include +#include INC_GLUE(memlayout.h) +#include +#include +#include +#include +#include +#include +#include + +#define __TASKNAME__ __PAGERNAME__ + +#define ARGS_MAX DEFAULT_ENV_SIZE +#define PATH_MAX PAGE_SIZE + +#define TASK_FILES_MAX 32 + +/* POSIX minimum is 4Kb */ +#define DEFAULT_ENV_SIZE SZ_4K +#define DEFAULT_STACK_SIZE SZ_32K +#define DEFAULT_SHPAGE_SIZE PAGE_SIZE +#define TASK_SIZE 0x10000000 + +#define TCB_NO_SHARING 0 +#define TCB_SHARED_VM (1 << 0) +#define TCB_SHARED_FILES (1 << 1) +#define TCB_SHARED_FS (1 << 2) +#define TCB_SHARED_TGROUP (1 << 3) +#define TCB_SHARED_PARENT (1 << 4) + +struct vm_file; + +struct file_descriptor { + unsigned long vnum; + unsigned long cursor; + struct vm_file *vmfile; +}; + +struct task_fd_head { + struct file_descriptor fd[TASK_FILES_MAX]; + int tcb_refs; +}; + +struct task_vma_head { + struct link list; + int tcb_refs; +}; + +struct utcb_desc { + struct link list; + unsigned long utcb_base; + struct id_pool *slots; +}; + +struct utcb_head { + struct link list; + int tcb_refs; +}; + + +/* Stores all task information that can be kept in userspace. */ +struct tcb { + /* Task list */ + struct link list; + + /* Fields for parent-child relations */ + struct link child_ref; /* Child ref in parent's list */ + struct link children; /* List of children */ + struct tcb *parent; /* Parent task */ + + /* Task creation flags */ + unsigned int clone_flags; + + /* Name of the task */ + char name[16]; + + /* Task ids */ + int tid; + int spid; + int tgid; + + /* Related task ids */ + unsigned int pagerid; /* Task's pager */ + + /* Task's main address space region, usually USER_AREA_START/END */ + unsigned long start; + unsigned long end; + + /* Page aligned program segment marks, ends exclusive as usual */ + unsigned long entry; + unsigned long text_start; + unsigned long text_end; + unsigned long data_start; + unsigned long data_end; + unsigned long bss_start; + unsigned long bss_end; + unsigned long stack_start; + unsigned long stack_end; + unsigned long heap_start; + unsigned long heap_end; + unsigned long args_start; + unsigned long args_end; + + /* Task's mmappable region */ + unsigned long map_start; + unsigned long map_end; + + /* Default ipc-shared-page information */ + void *shared_page; + + /* Chain of utcb descriptors */ + struct utcb_head *utcb_head; + + /* Unique utcb address of this task */ + unsigned long utcb_address; + + /* Virtual memory areas */ + struct task_vma_head *vm_area_head; + + /* File descriptors for this task */ + struct task_fd_head *files; +}; + +struct tcb_head { + struct link list; + int total; /* Total threads */ +}; + +struct tcb *find_task(int tid); +void global_add_task(struct tcb *task); +void global_remove_task(struct tcb *task); +void task_map_prefault_utcb(struct tcb *mapper, struct tcb *owner); +int task_mmap_segments(struct tcb *task, struct vm_file *file, struct exec_file_desc *efd, + struct args_struct *args, struct args_struct *env); +int task_setup_registers(struct tcb *task, unsigned int pc, + unsigned int sp, l4id_t pager); +struct tcb *tcb_alloc_init(unsigned int flags); +int tcb_destroy(struct tcb *task); +int task_start(struct tcb *task); +int copy_tcb(struct tcb *to, struct tcb *from, unsigned int flags); +int task_release_vmas(struct task_vma_head *vma_head); +int task_prefault_regions(struct tcb *task, struct vm_file *f); +struct tcb *task_create(struct tcb *orig, + struct task_ids *ids, + unsigned int ctrl_flags, + unsigned int alloc_flags); + +#endif /* __TASK_H__ */ diff --git a/conts/posix/mm0/include/test.h b/conts/posix/mm0/include/test.h new file mode 100644 index 0000000..ecfa1f3 --- /dev/null +++ b/conts/posix/mm0/include/test.h @@ -0,0 +1,7 @@ +#ifndef __TEST_H__ +#define __TEST_H__ + + +int mm0_test_global_vm_integrity(void); + +#endif /* __TEST_H__ */ diff --git a/conts/posix/mm0/include/user.h b/conts/posix/mm0/include/user.h new file mode 100644 index 0000000..fc0206b --- /dev/null +++ b/conts/posix/mm0/include/user.h @@ -0,0 +1,12 @@ +#ifndef __USER_H__ +#define __USER_H__ + +#include + +int pager_validate_user_range(struct tcb *user, void *userptr, unsigned long size, + unsigned int vm_flags); +void *pager_validate_map_user_range(struct tcb *user, void *userptr, + unsigned long size, unsigned int vm_flags); +void pager_unmap_user_range(void *mapped_ptr, unsigned long size); + +#endif /* __USER_H__ */ diff --git a/conts/posix/mm0/include/utcb.h b/conts/posix/mm0/include/utcb.h new file mode 100644 index 0000000..02b7d72 --- /dev/null +++ b/conts/posix/mm0/include/utcb.h @@ -0,0 +1,14 @@ +#ifndef __MM0_UTCB_H__ +#define __MM0_UTCB_H__ + +int utcb_pool_init(); + +void *utcb_new_address(int npages); +int utcb_delete_address(void *shm_addr, int npages); +unsigned long utcb_slot(struct utcb_desc *desc); +unsigned long task_new_utcb_desc(struct tcb *task); +int task_setup_utcb(struct tcb *task); +int task_destroy_utcb(struct tcb *task); + + +#endif /* __MM0_UTCB_H__ */ diff --git a/conts/posix/mm0/include/vm_area.h b/conts/posix/mm0/include/vm_area.h new file mode 100644 index 0000000..21cab02 --- /dev/null +++ b/conts/posix/mm0/include/vm_area.h @@ -0,0 +1,267 @@ +/* + * Virtual memory area descriptors. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ +#ifndef __VM_AREA_H__ +#define __VM_AREA_H__ + +#include +#include +#include +#include +#include +#include +#include +#include + +// #define DEBUG_FAULT_HANDLING +#ifdef DEBUG_FAULT_HANDLING +#define dprintf(...) printf(__VA_ARGS__) +#else +#define dprintf(...) +#endif + +/* Protection flags */ +#define VM_NONE (1 << 0) +#define VM_READ (1 << 1) +#define VM_WRITE (1 << 2) +#define VM_EXEC (1 << 3) +#define VM_PROT_MASK (VM_READ | VM_WRITE | VM_EXEC) + +/* Shared copy of a file */ +#define VMA_SHARED (1 << 4) +/* VMA that's not file-backed, always maps devzero as VMA_COW */ +#define VMA_ANONYMOUS (1 << 5) +/* Private copy of a file */ +#define VMA_PRIVATE (1 << 6) +/* For wired pages */ +#define VMA_FIXED (1 << 7) +/* For stack, where mmap returns end address */ +#define VMA_GROWSDOWN (1 << 8) + +/* Set when the page is dirty in cache but not written to disk */ +#define VM_DIRTY (1 << 9) + +/* Defines the type of file. A device file? Regular file? One used at boot? */ +enum VM_FILE_TYPE { + VM_FILE_DEVZERO = 1, + VM_FILE_VFS, + VM_FILE_BOOTFILE, + VM_FILE_SHM, +}; + +/* Defines the type of object. A file? Just a standalone object? */ +#define VM_OBJ_SHADOW (1 << 10) /* Anonymous pages, swap_pager */ +#define VM_OBJ_FILE (1 << 11) /* VFS file and device pages */ + +struct page { + int refcnt; /* Refcount */ + struct spinlock lock; /* Page lock. */ + struct link list; /* For list of a vm_object's in-memory pages */ + struct vm_object *owner;/* The vm_object the page belongs to */ + unsigned long virtual; /* If refs >1, first mapper's virtual address */ + unsigned int flags; /* Flags associated with the page. */ + unsigned long offset; /* The offset page resides in its owner */ +}; +extern struct page *page_array; + +/* + * A suggestion to how a non-page_array (i.e. a device) + * page could tell its physical address. + */ +struct devpage { + struct page page; + unsigned long phys; +}; + +#define page_refcnt(x) ((x)->count + 1) +#define virtual(x) ((x)->virtual) +#define phys_to_page(x) (page_array + __pfn((x) - membank[0].start)) +#define page_to_phys(x) (__pfn_to_addr((((void *)(x)) - \ + (void *)page_array) / \ + sizeof(struct page)) + \ + membank[0].start) + +/* Fault data specific to this task + ptr to kernel's data */ +struct fault_data { + fault_kdata_t *kdata; /* Generic data forged by the kernel */ + unsigned int reason; /* Generic fault reason flags */ + unsigned int address; /* Aborted address */ + unsigned int pte_flags; /* Generic protection flags on pte */ + struct vm_area *vma; /* Inittask-related fault data */ + struct tcb *task; /* Inittask-related fault data */ +}; + +struct vm_pager_ops { + struct page *(*page_in)(struct vm_object *vm_obj, + unsigned long pfn_offset); + int (*page_out)(struct vm_object *vm_obj, + unsigned long pfn_offset); + int (*release_pages)(struct vm_object *vm_obj); +}; + +/* Describes the pager task that handles a vm_area. */ +struct vm_pager { + struct vm_pager_ops ops; /* The ops the pager does on area */ +}; + +/* + * Describes the in-memory representation of a resource. This could + * point at a file or another resource, e.g. a device area, swapper space, + * the anonymous internal state of a process, etc. This covers more than + * just files, e.g. during a fork, captures the state of internal shared + * copy of private pages for a process, which is really not a file. + */ +struct vm_object { + int npages; /* Number of pages in memory */ + int nlinks; /* Number of mapper links that refer */ + int shadows; /* Number of shadows that refer */ + struct link shref; /* Shadow reference from original object */ + struct link shdw_list; /* List of vm objects that shadows this one */ + struct link link_list; /* List of links that refer to this object */ + struct vm_object *orig_obj; /* Original object that this one shadows */ + unsigned int flags; /* Defines the type and flags of the object */ + struct link list; /* List of all vm objects in memory */ + struct vm_pager *pager; /* The pager for this object */ + struct link page_cache;/* List of in-memory pages */ +}; + +/* In memory representation of either a vfs file, a device. */ +struct vm_file { + int openers; + struct link list; + unsigned long length; + unsigned int type; + struct vm_object vm_obj; + void (*destroy_priv_data)(struct vm_file *f); + void *priv_data; /* Device pagers use to access device info */ +}; + +/* To create per-vma vm_object lists */ +struct vm_obj_link { + struct link list; + struct link linkref; + struct vm_object *obj; +}; + +static inline void vm_link_object(struct vm_obj_link *link, struct vm_object *obj) +{ + link->obj = obj; + list_insert(&link->linkref, &obj->link_list); + obj->nlinks++; +} + +static inline struct vm_object *vm_unlink_object(struct vm_obj_link *link) +{ + /* Delete link from object's link list */ + list_remove(&link->linkref); + + /* Reduce object's mapper link count */ + link->obj->nlinks--; + + return link->obj; +} + +#define vm_object_to_file(obj) container_of(obj, struct vm_file, vm_obj) + +/* + * Describes a virtually contiguous chunk of memory region in a task. It covers + * a unique virtual address area within its task, meaning that it does not + * overlap with other regions in the same task. The region could be backed by a + * file or various other resources. + * + * COW: Upon copy-on-write, each copy-on-write instance creates a shadow of the + * original vm object which supersedes the original vm object with its copied + * modified pages. This creates a stack of shadow vm objects, where the top + * object's copy of pages supersede the ones lower in the stack. + */ +struct vm_area { + struct link list; /* Per-task vma list */ + struct link vm_obj_list; /* Head for vm_object list. */ + unsigned long pfn_start; /* Region start virtual pfn */ + unsigned long pfn_end; /* Region end virtual pfn, exclusive */ + unsigned long flags; /* Protection flags. */ + unsigned long file_offset; /* File offset in pfns */ +}; + +/* + * Finds the vma that has the given address. + * TODO: In the future a lot of use cases may need to traverse each vma + * rather than searching the address. E.g. munmap/msync + */ +static inline struct vm_area *find_vma(unsigned long addr, + struct link *vm_area_list) +{ + struct vm_area *vma; + unsigned long pfn = __pfn(addr); + + list_foreach_struct(vma, vm_area_list, list) + if ((pfn >= vma->pfn_start) && (pfn < vma->pfn_end)) + return vma; + return 0; +} + +/* Adds a page to its vm_objects's page cache in order of offset. */ +int insert_page_olist(struct page *this, struct vm_object *vm_obj); + +/* Find a page in page cache via page offset */ +struct page *find_page(struct vm_object *obj, unsigned long pfn); + +/* Pagers */ +extern struct vm_pager file_pager; +extern struct vm_pager bootfile_pager; +extern struct vm_pager devzero_pager; +extern struct vm_pager swap_pager; + +/* vm object and vm file lists */ +extern struct link vm_object_list; + +/* vm object link related functions */ +struct vm_obj_link *vm_objlink_create(void); +struct vm_obj_link *vma_next_link(struct link *link, + struct link *head); + +/* vm file and object initialisation */ +struct vm_object *vm_object_create(void); +struct vm_file *vm_file_create(void); +int vm_file_delete(struct vm_file *f); +int vm_object_delete(struct vm_object *vmo); +void vm_file_put(struct vm_file *f); + +/* Printing objects, files */ +void vm_object_print(struct vm_object *vmo); +void vm_print_objects(struct link *vmo_list); +void vm_print_files(struct link *file_list); + +/* Used for pre-faulting a page from mm0 */ +int prefault_page(struct tcb *task, unsigned long address, + unsigned int vmflags); +struct page *page_init(struct page *page); +struct page *find_page(struct vm_object *vmo, unsigned long page_offset); +void *pager_map_page(struct vm_file *f, unsigned long page_offset); +void pager_unmap_page(void *vaddr); + +/* To get currently mapped page of a virtual address on a task */ +struct page *task_virt_to_page(struct tcb *t, unsigned long virtual); +int validate_task_range(struct tcb *t, unsigned long start, + unsigned long end, unsigned int vmflags); + +/* Changes all shadows and their ptes to read-only */ +int vm_freeze_shadows(struct tcb *task); + +int task_insert_vma(struct vm_area *vma, struct link *vma_list); + +/* Main page fault entry point */ +int page_fault_handler(struct tcb *faulty_task, fault_kdata_t *fkdata); + +int vma_copy_links(struct vm_area *new_vma, struct vm_area *vma); +int vma_drop_merge_delete(struct vm_area *vma, struct vm_obj_link *link); +int vma_drop_merge_delete_all(struct vm_area *vma); + +void global_add_vm_object(struct vm_object *obj); +void global_remove_vm_object(struct vm_object *obj); +void global_add_vm_file(struct vm_file *f); +void global_remove_vm_file(struct vm_file *f); + +#endif /* __VM_AREA_H__ */ diff --git a/conts/posix/mm0/main.c b/conts/posix/mm0/main.c new file mode 100644 index 0000000..1e29ab9 --- /dev/null +++ b/conts/posix/mm0/main.c @@ -0,0 +1,271 @@ +/* + * mm0. Pager for all tasks. + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* Receives all registers and origies back */ +int ipc_test_full_sync(l4id_t senderid) +{ + for (int i = MR_UNUSED_START; i < MR_TOTAL + MR_REST; i++) { + // printf("%s/%s: MR%d: %d\n", __TASKNAME__, __FUNCTION__, + // i, read_mr(i)); + /* Reset it to 0 */ + write_mr(i, 0); + } + + /* Send a full origy */ + l4_send_full(senderid, 0); + return 0; +} + +void handle_requests(void) +{ + /* Generic ipc data */ + u32 mr[MR_UNUSED_TOTAL]; + l4id_t senderid; + struct tcb *sender; + u32 tag; + int ret; + + // printf("%s: Initiating ipc.\n", __TASKNAME__); + if ((ret = l4_receive(L4_ANYTHREAD)) < 0) { + printf("%s: %s: IPC Error: %d. Quitting...\n", __TASKNAME__, + __FUNCTION__, ret); + BUG(); + } + + /* Syslib conventional ipc data which uses first few mrs. */ + tag = l4_get_tag(); + senderid = l4_get_sender(); + + if (!(sender = find_task(senderid))) { + l4_ipc_return(-ESRCH); + return; + } + + /* Read mrs not used by syslib */ + for (int i = 0; i < MR_UNUSED_TOTAL; i++) + mr[i] = read_mr(MR_UNUSED_START + i); + + switch(tag) { + case L4_IPC_TAG_SYNC_FULL: + ret = ipc_test_full_sync(senderid); + return; + case L4_IPC_TAG_SYNC: + mm0_test_global_vm_integrity(); + // printf("%s: Synced with waiting thread.\n", __TASKNAME__); + /* This has no receive phase */ + return; + + case L4_IPC_TAG_PFAULT: + /* Handle page fault. */ + ret = page_fault_handler(sender, (fault_kdata_t *)&mr[0]); + break; + + case L4_IPC_TAG_TASKDATA: + /* Send runnable task information to fs0 */ + ret = vfs_send_task_data(sender); + break; + + case L4_IPC_TAG_SHMGET: { + ret = sys_shmget((key_t)mr[0], (int)mr[1], (int)mr[2]); + break; + } + + case L4_IPC_TAG_SHMAT: { + ret = (int)sys_shmat(sender, (l4id_t)mr[0], (void *)mr[1], (int)mr[2]); + break; + } + + case L4_IPC_TAG_SHMDT: + ret = sys_shmdt(sender, (void *)mr[0]); + break; + + case L4_IPC_TAG_SHPAGE: + ret = (int)task_send_shpage_address(sender, (l4id_t)mr[0]); + break; + + case L4_IPC_TAG_READ: + ret = sys_read(sender, (int)mr[0], (void *)mr[1], (int)mr[2]); + break; + + case L4_IPC_TAG_WRITE: + ret = sys_write(sender, (int)mr[0], (void *)mr[1], (int)mr[2]); + break; + + case L4_IPC_TAG_CLOSE: + ret = sys_close(sender, (int)mr[0]); + break; + + case L4_IPC_TAG_FSYNC: + ret = sys_fsync(sender, (int)mr[0]); + break; + + case L4_IPC_TAG_LSEEK: + ret = sys_lseek(sender, (int)mr[0], (off_t)mr[1], (int)mr[2]); + break; + + case L4_IPC_TAG_MMAP: { + struct sys_mmap_args *args = (struct sys_mmap_args *)mr[0]; + ret = (int)sys_mmap(sender, args); + break; + } + case L4_IPC_TAG_MUNMAP: { + ret = sys_munmap(sender, (void *)mr[0], (unsigned long)mr[1]); + break; + } + case L4_IPC_TAG_MSYNC: { + ret = sys_msync(sender, (void *)mr[0], + (unsigned long)mr[1], (int)mr[2]); + break; + } + case L4_IPC_TAG_FORK: { + ret = sys_fork(sender); + break; + } + case L4_IPC_TAG_CLONE: { + ret = sys_clone(sender, (void *)mr[0], (unsigned int)mr[1]); + break; + } + case L4_IPC_TAG_EXIT: { + /* An exiting task has no receive phase */ + sys_exit(sender, (int)mr[0]); + return; + } + case L4_IPC_TAG_EXECVE: { + ret = sys_execve(sender, (char *)mr[0], + (char **)mr[1], (char **)mr[2]); + if (ret < 0) + break; /* We origy for errors */ + else + return; /* else we're done */ + } + case L4_IPC_TAG_BRK: { +// ret = sys_brk(sender, (void *)mr[0]); +// break; + } + default: + printf("%s: Unrecognised ipc tag (%d) " + "received from (%d). Full mr reading: " + "%u, %u, %u, %u, %u, %u. Ignoring.\n", + __TASKNAME__, tag, senderid, read_mr(0), + read_mr(1), read_mr(2), read_mr(3), read_mr(4), + read_mr(5)); + } + + /* Reply */ + if ((ret = l4_ipc_return(ret)) < 0) { + printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, ret); + BUG(); + } +} + +#if 0 +/* + * Executes the given function in a new thread in the current + * address space but on a brand new stack. + */ +int self_spawn(void) +{ + struct task_ids ids; + struct tcb *self, *self_child; + unsigned long stack, stack_size; + + BUG_ON(!(self = find_task(self_tid()))); + + ids.tid = TASK_ID_INVALID; + ids.spid = self->spid; + ids.tgid = self->tgid; + + /* Create a new L4 thread in current thread's address space. */ + self_child = task_create(self, &ids, THREAD_SAME_SPACE, + TCB_SHARED_VM | TCB_SHARED_FILES); + + if (IS_ERR(self_child = tcb_alloc_init(TCB_SHARED_VM + | TCB_SHARED_FILES))) + BUG(); + + /* + * Create a new utcb. Every pager thread will + * need its own utcb to answer calls. + */ + self_child->utcb = utcb_vaddr_new(); + + /* Map utcb to child */ + task_map_prefault_utcb(self_child, self_child); + + /* + * Set up a child stack by mmapping an anonymous region. + */ + stack_size = self->stack_end - self->stack_start; + if (IS_ERR(stack = do_mmap(0, 0, self, 0, + VM_READ | VM_WRITE | VMA_ANONYMOUS + | VMA_PRIVATE | VMA_GROWSDOWN, + __pfn(stack_size)))) { + printf("%s: Error spawning %s, Error code: %d\n", + __FUNCTION__, __TASKNAME__, (int)stack); + BUG(); + } + + /* Modify stack marker of child tcb */ + self_child->stack_end = stack; + self_child->stack_start = stack - stack_size; + + /* Prefault child stack */ + for (int i = 0; i < __pfn(stack_size); i++) + prefault_page(self_child, + self_child->stack_start + __pfn_to_addr(i), + VM_READ | VM_WRITE); + + /* Copy current stack to child */ + memcpy((void *)self_child->stack_start, + (void *)self->stack_start, stack_size); + + /* TODO: Modify registers ???, it depends on what state is copied in C0 */ + + /* TODO: Notify vfs ??? */ + + task_add_global(self_child); + + if (l4_thread_control(THREAD_CREATE | THREAD_CREATE_SAMESPC, ids) + l4_thread_control(THREAD_RUN, &ids); + + return 0; +} +#endif + +void main(void) +{ + printf("\n%s: Started with thread id %d\n", __TASKNAME__, self_tid()); + + /* Initialise the memory, server tasks, mmap and start them. */ + init_pager(); + + printf("%s: Memory/Process manager initialized. Listening requests.\n", __TASKNAME__); + while (1) { + handle_requests(); + } +} + diff --git a/conts/posix/mm0/src/.scons14756 b/conts/posix/mm0/src/.scons14756 new file mode 100644 index 0000000..930e74d Binary files /dev/null and b/conts/posix/mm0/src/.scons14756 differ diff --git a/conts/posix/mm0/src/arch b/conts/posix/mm0/src/arch new file mode 120000 index 0000000..85405c2 --- /dev/null +++ b/conts/posix/mm0/src/arch @@ -0,0 +1 @@ +arch-arm \ No newline at end of file diff --git a/conts/posix/mm0/src/arch-arm/crt0.S b/conts/posix/mm0/src/arch-arm/crt0.S new file mode 100644 index 0000000..9bcb3a8 --- /dev/null +++ b/conts/posix/mm0/src/arch-arm/crt0.S @@ -0,0 +1,94 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#ifdef __thumb__ +#define bl blx +#endif + + .section .text.head + .code 32 + .global _start; + .align; +_start: + ldr sp, =__stack + bl platform_init + bl __container_init +1: + b 1b + diff --git a/conts/posix/mm0/src/arch-arm/mm.c b/conts/posix/mm0/src/arch-arm/mm.c new file mode 100644 index 0000000..5781fee --- /dev/null +++ b/conts/posix/mm0/src/arch-arm/mm.c @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include + +/* Extracts generic protection flags from architecture-specific pte */ +unsigned int vm_prot_flags(pte_t pte) +{ + unsigned int vm_prot_flags = 0; + unsigned int rw_flags = __MAP_USR_RW_FLAGS & PTE_PROT_MASK; + unsigned int ro_flags = __MAP_USR_RO_FLAGS & PTE_PROT_MASK; + + /* Clear non-protection flags */ + pte &= PTE_PROT_MASK;; + + if (pte == ro_flags) + vm_prot_flags = VM_READ | VM_EXEC; + else if (pte == rw_flags) + vm_prot_flags = VM_READ | VM_WRITE | VM_EXEC; + else + vm_prot_flags = VM_NONE; + + return vm_prot_flags; +} + +#if defined(DEBUG_FAULT_HANDLING) +void arch_print_fault_params(struct fault_data *fault) +{ + printf("%s: Handling %s fault (%s abort) from %d. fault @ 0x%x\n", + __TASKNAME__, (fault->reason & VM_READ) ? "read" : "write", + is_prefetch_abort(fault->kdata->fsr) ? "prefetch" : "data", + fault->task->tid, fault->address); +} +#else +void arch_print_fault_params(struct fault_data *fault) { } +#endif + + +/* + * PTE STATES: + * PTE type field: 00 (Translation fault) + * PTE type field correct, AP bits: None (Read or Write access fault) + * PTE type field correct, AP bits: RO (Write access fault) + */ + +/* Extracts arch-specific fault parameters and puts them into generic format */ +void set_generic_fault_params(struct fault_data *fault) +{ + unsigned int prot_flags = vm_prot_flags(fault->kdata->pte); + + fault->reason = 0; + fault->pte_flags = prot_flags; + + if (is_prefetch_abort(fault->kdata->fsr)) { + fault->reason |= VM_READ; + fault->address = fault->kdata->faulty_pc; + } else { + fault->address = fault->kdata->far; + + /* Always assume read fault first */ + if (prot_flags & VM_NONE) + fault->reason |= VM_READ; + else if (prot_flags & VM_READ) + fault->reason |= VM_WRITE; + else + BUG(); + } + arch_print_fault_params(fault); +} + diff --git a/conts/posix/mm0/src/boot.c b/conts/posix/mm0/src/boot.c new file mode 100644 index 0000000..422376b --- /dev/null +++ b/conts/posix/mm0/src/boot.c @@ -0,0 +1,131 @@ +/* + * Functions used for running initial tasks during boot. + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include + +int boottask_setup_regions(struct vm_file *file, struct tcb *task, + unsigned long task_start, unsigned long task_end) +{ + /* + * Set task's main address space boundaries. Not all tasks + * run in the default user boundaries, e.g. mm0 pager. + */ + task->start = task_start; + task->end = task_end; + + /* Task stack starts right after the environment. */ + task->stack_end = task->end; + task->stack_start = task->stack_end - DEFAULT_STACK_SIZE; + + /* Prepare environment boundaries. */ + task->args_end = task->stack_end; + task->args_start = task->stack_start - DEFAULT_ENV_SIZE; + + /* Currently RO text and RW data are one region. TODO: Fix this */ + task->data_start = task->start; + task->data_end = task->start + page_align_up(file->length); + task->text_start = task->data_start; + task->text_end = task->data_end; + task->entry = task->text_start; + + /* Task's region available for mmap */ + task->map_start = task->data_end; + task->map_end = task->stack_start; + + return 0; +} + +/* + * Used for mmapping boot task regions. These are slightly different + * from a vfs executable file. + */ +int boottask_mmap_regions(struct tcb *task, struct vm_file *file) +{ + void *mapped; + struct vm_file *shm; + + /* + * mmap each task's physical image to task's address space. + * TODO: Map data and text separately when available from bootdesc. + */ + if (IS_ERR(mapped = do_mmap(file, 0, task, task->text_start, + VM_READ | VM_WRITE | VM_EXEC | VMA_PRIVATE, + __pfn(page_align_up(task->text_end) - + task->text_start)))) { + printf("do_mmap: failed with %d.\n", (int)mapped); + return (int)mapped; + } + + /* mmap each task's stack as anonymous memory. */ + if (IS_ERR(mapped = do_mmap(0, 0, task, task->stack_start, + VM_READ | VM_WRITE | + VMA_PRIVATE | VMA_ANONYMOUS, + __pfn(task->stack_end - + task->stack_start)))) { + printf("do_mmap: Mapping stack failed with %d.\n", + (int)mapped); + return (int)mapped; + } + + /* Task's default shared page */ + task->shared_page = shm_new_address(DEFAULT_SHPAGE_SIZE/PAGE_SIZE); + + /* Create a shared memory segment available for shmat() */ + if (IS_ERR(shm = shm_new((key_t)task->shared_page, + __pfn(DEFAULT_SHPAGE_SIZE)))) + return (int)shm; + + task_setup_utcb(task); + + return 0; +} + +/* + * Main entry point for the creation, initialisation and + * execution of a new task. + */ +struct tcb *boottask_exec(struct vm_file *f, unsigned long task_region_start, + unsigned long task_region_end, struct task_ids *ids) +{ + struct tcb *task; + int err; + + if (IS_ERR(task = task_create(0, ids, THREAD_NEW_SPACE, + TCB_NO_SHARING))) + return task; + + if ((err = boottask_setup_regions(f, task, task_region_start, + task_region_end)) < 0) + return PTR_ERR(err); + + if ((err = boottask_mmap_regions(task, f)) < 0) + return PTR_ERR(err); + + if ((err = task_setup_registers(task, 0, 0, 0)) < 0) + return PTR_ERR(err); + + /* Add the task to the global task list */ + global_add_task(task); + + /* Add the file to global vm lists */ + global_add_vm_file(f); + + /* Prefault all its regions */ + if (ids->tid == VFS_TID) + task_prefault_regions(task, f); + + /* Start the task */ + if ((err = task_start(task)) < 0) + return PTR_ERR(err); + + return task; +} + + diff --git a/conts/posix/mm0/src/bootdesc.c b/conts/posix/mm0/src/bootdesc.c new file mode 100644 index 0000000..542f2eb --- /dev/null +++ b/conts/posix/mm0/src/bootdesc.c @@ -0,0 +1,39 @@ +/* + * Reading of bootdesc forged at build time. + * + * Copyright (C) 2007 - 2009 Bahadir Balban + */ + +#include +#include +#include +#include + +extern unsigned long _end[]; +extern unsigned long pager_offset; + +void read_bootdesc(struct initdata *initdata) +{ + int npages; + struct bootdesc *bootdesc; + + /* + * End of the executable image is where bootdesc resides + */ + bootdesc = (struct bootdesc *)_end; + + /* Check if bootdesc is on an unmapped page */ + if (is_page_aligned(bootdesc)) + l4_map_helper(bootdesc - pager_offset, PAGE_SIZE); + + /* Allocate bootdesc sized structure */ + initdata->bootdesc = alloc_bootmem(bootdesc->desc_size, 0); + + /* Copy bootdesc to initdata */ + memcpy(initdata->bootdesc, bootdesc, + bootdesc->desc_size); + + if (npages > 0) + l4_unmap_helper((void *)page_align_up(_end), + PAGE_SIZE * npages); +} diff --git a/conts/posix/mm0/src/bootm.c b/conts/posix/mm0/src/bootm.c new file mode 100644 index 0000000..cf7a602 --- /dev/null +++ b/conts/posix/mm0/src/bootm.c @@ -0,0 +1,62 @@ +/* + * Boot memory allocator + * + * Copyright (C) 2009 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) + +#include + +/* All memory allocated here is discarded after boot */ + +#define BOOTMEM_SIZE SZ_32K + +SECTION(".init.bootmem") char bootmem[BOOTMEM_SIZE]; +SECTION(".stack") char stack[4096]; +// SECTION("init.data") + +extern unsigned long __stack[]; /* Linker defined */ + +static unsigned long cursor = (unsigned long)&bootmem; + +void *alloc_bootmem(int size, int alignment) +{ + void *ptr; + + /* If alignment is required */ + if (alignment) { + /* And cursor is not aligned */ + if (!is_aligned(cursor, alignment)) + /* Align the cursor to alignment */ + cursor = align_up(cursor, alignment); + /* Align to 4 byte by default */ + } else if (size >= 4) { + /* And cursor is not aligned */ + if (!is_aligned(cursor, 4)) + /* Align the cursor to alignment */ + cursor = align_up(cursor, 4); + } + + /* Allocate from cursor */ + ptr = (void *)cursor; + + /* Update cursor */ + cursor += size; + + /* Check if cursor is passed bootmem area */ + if (cursor >= (unsigned long)&bootmem[BOOTMEM_SIZE]) { + printk("Fatal: Insufficient boot memory.\n"); + BUG(); + } + + return ptr; +} + diff --git a/conts/posix/mm0/src/capability.c b/conts/posix/mm0/src/capability.c new file mode 100644 index 0000000..b89acb9 --- /dev/null +++ b/conts/posix/mm0/src/capability.c @@ -0,0 +1,85 @@ +/* + * Pager's capabilities for kernel resources + * + * Copyright (C) 2009 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include /* TODO: Move this to API */ +#include + +struct cap_list capability_list; + +__initdata static struct capability *caparray; +__initdata static int total_caps = 0; + +/* Copy all init-memory allocated capabilities */ +void copy_boot_capabilities(struct initdata *initdata) +{ + struct capability *cap; + + for (int i = 0; i < total_caps; i++) { + cap = kzalloc(sizeof(struct capability)); + + /* This copies kernel-allocated unique cap id as well */ + memcpy(cap, &caparray[i], sizeof(struct capability)); + + /* Initialize capability list */ + link_init(&cap->list); + + /* Add capability to global cap list */ + list_insert(&capability_list.caps, &cap->list); + } +} + +int read_kernel_capabilities(struct initdata *initdata) +{ + int ncaps; + int err; + + /* Read number of capabilities */ + if ((err = l4_capability_control(CAP_CONTROL_NCAPS, 0, &ncaps)) < 0) { + printf("l4_capability_control() reading # of capabilities failed.\n" + "Could not complete CAP_CONTROL_NCAPS request.\n"); + goto error; + } + total_caps = ncaps; + + /* Allocate array of caps from boot memory */ + caparray = alloc_bootmem(sizeof(struct capability) * ncaps, 0); + + /* Read all capabilities */ + if ((err = l4_capability_control(CAP_CONTROL_READ_CAPS, 0, caparray)) < 0) { + printf("l4_capability_control() reading of capabilities failed.\n" + "Could not complete CAP_CONTROL_READ_CAPS request.\n"); + goto error; + } + + /* Set up initdata pointer to important capabilities */ + initdata->bootcaps = caparray; + for (int i = 0; i < ncaps; i++) { + /* + * TODO: There may be multiple physmem caps! + * This really needs to be considered as multiple + * membanks!!! + */ + if ((caparray[i].type & CAP_RTYPE_MASK) + == CAP_RTYPE_PHYSMEM) { + initdata->physmem = &caparray[i]; + return 0; + } + } + printf("%s: Error, pager has no physmem capability defined.\n", + __TASKNAME__); + goto error; + + return 0; + +error: + BUG(); +} + diff --git a/conts/posix/mm0/src/clone.c b/conts/posix/mm0/src/clone.c new file mode 100644 index 0000000..7fa7446 --- /dev/null +++ b/conts/posix/mm0/src/clone.c @@ -0,0 +1,188 @@ +/* + * Forking and cloning threads, processes + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Sends vfs task information about forked child, and its utcb + */ +int vfs_notify_fork(struct tcb *child, struct tcb *parent, unsigned int flags) +{ + int err = 0; + + // printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + + l4_save_ipcregs(); + + /* Write parent and child information */ + write_mr(L4SYS_ARG0, parent->tid); + write_mr(L4SYS_ARG1, child->tid); + write_mr(L4SYS_ARG2, (unsigned int)child->shared_page); + write_mr(L4SYS_ARG3, flags); + + if ((err = l4_sendrecv(VFS_TID, VFS_TID, + L4_IPC_TAG_NOTIFY_FORK)) < 0) { + printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + goto out; + } + + /* Check if syscall was successful */ + if ((err = l4_get_retval()) < 0) { + printf("%s: Pager from VFS read error: %d.\n", + __FUNCTION__, err); + goto out; + } + +out: + l4_restore_ipcregs(); + return err; +} + + +int sys_fork(struct tcb *parent) +{ + int err; + struct tcb *child; + struct exregs_data exregs; + struct task_ids ids; +// = { +// .tid = TASK_ID_INVALID, +// .spid = parent->spid, /* spid to copy from */ +// .tgid = TASK_ID_INVALID, /* FIXME: !!! FIX THIS */ +// }; + + /* Make all shadows in this task read-only */ + vm_freeze_shadows(parent); + + /* + * Create a new L4 thread with parent's page tables + * kernel stack and kernel-side tcb copied + */ + if (IS_ERR(child = task_create(parent, &ids, THREAD_COPY_SPACE, + TCB_NO_SHARING))) + return (int)child; + + /* Set child's fork return value to 0 */ + memset(&exregs, 0, sizeof(exregs)); + exregs_set_mr(&exregs, MR_RETURN, 0); + + /* Set child's new utcb address set by task_create() */ + BUG_ON(!child->utcb_address); + exregs_set_utcb(&exregs, child->utcb_address); + + /* Do the actual exregs call to c0 */ + if ((err = l4_exchange_registers(&exregs, child->tid)) < 0) + BUG(); + + /* Create and prefault a shared page for child and map it to vfs task */ + shpage_map_to_task(child, find_task(VFS_TID), + SHPAGE_NEW_ADDRESS | SHPAGE_NEW_SHM | + SHPAGE_PREFAULT); + + // printf("Mapped 0x%p to vfs as utcb of %d\n", child->utcb, child->tid); + + /* We can now notify vfs about forked process */ + vfs_notify_fork(child, parent, TCB_NO_SHARING); + + /* Add child to global task list */ + global_add_task(child); + + /* Start forked child. */ + l4_thread_control(THREAD_RUN, &ids); + + /* Return child tid to parent */ + return child->tid; +} + +int do_clone(struct tcb *parent, unsigned long child_stack, unsigned int flags) +{ + struct exregs_data exregs; + struct task_ids ids; + struct tcb *child; + int err; + + //ids.tid = TASK_ID_INVALID; + //ids.spid = parent->spid; + + + /* Determine whether the cloned thread is in parent's thread group */ + if (flags & TCB_SHARED_TGROUP) + ids.tgid = parent->tgid; + else + ids.tgid = TASK_ID_INVALID; + + if (IS_ERR(child = task_create(parent, &ids, THREAD_SAME_SPACE, flags))) + return (int)child; + + /* Set up child stack marks with given stack argument */ + child->stack_end = child_stack; + child->stack_start = 0; + + memset(&exregs, 0, sizeof(exregs)); + + /* Set child's stack pointer */ + exregs_set_stack(&exregs, child_stack); + + /* Set child's clone return value to 0 */ + exregs_set_mr(&exregs, MR_RETURN, 0); + BUG_ON(!child->utcb_address); + exregs_set_utcb(&exregs, child->utcb_address); + + /* Do the actual exregs call to c0 */ + if ((err = l4_exchange_registers(&exregs, child->tid)) < 0) + BUG(); + + /* Create and prefault a shared page for child and map it to vfs task */ + shpage_map_to_task(child, find_task(VFS_TID), + SHPAGE_NEW_ADDRESS | SHPAGE_NEW_SHM | + SHPAGE_PREFAULT); + + /* We can now notify vfs about forked process */ + vfs_notify_fork(child, parent, flags); + + /* Add child to global task list */ + global_add_task(child); + + /* Start cloned child. */ + // printf("%s/%s: Starting cloned child.\n", __TASKNAME__, __FUNCTION__); + l4_thread_control(THREAD_RUN, &ids); + + /* Return child tid to parent */ + return child->tid; +} + + +int sys_clone(struct tcb *parent, void *child_stack, unsigned int clone_flags) +{ + unsigned int flags = 0; + + if (!child_stack) + return -EINVAL; + + if (clone_flags & CLONE_VM) + flags |= TCB_SHARED_VM; + if (clone_flags & CLONE_FS) + flags |= TCB_SHARED_FS; + if (clone_flags & CLONE_FILES) + flags |= TCB_SHARED_FILES; + if (clone_flags & CLONE_THREAD) + flags |= TCB_SHARED_TGROUP; + if (clone_flags & CLONE_PARENT) + flags |= TCB_SHARED_PARENT; + + return do_clone(parent, (unsigned long)child_stack, flags); +} + diff --git a/conts/posix/mm0/src/dev.c b/conts/posix/mm0/src/dev.c new file mode 100644 index 0000000..736c76f --- /dev/null +++ b/conts/posix/mm0/src/dev.c @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include + +/* + * This is yet unused, it is more of an anticipation + * of how mmaped devices would be mapped with a pager. + */ +struct mmap_device { + struct link page_list; /* Dyn-allocated page list */ + unsigned long pfn_start; /* Physical pfn start */ + unsigned long pfn_end; /* Physical pfn end */ +}; + +struct page *memdev_page_in(struct vm_object *vm_obj, + unsigned long pfn_offset) +{ + struct vm_file *f = vm_object_to_file(vm_obj); + struct mmap_device *memdev = f->priv_data; + struct page *page; + + /* Check if its within device boundary */ + if (pfn_offset >= memdev->pfn_end - memdev->pfn_start) + return PTR_ERR(-1); + + /* Simply return the page if found */ + list_foreach_struct(page, &memdev->page_list, list) + if (page->offset == pfn_offset) + return page; + + /* Otherwise allocate one of our own for that offset and return it */ + page = kzalloc(sizeof(struct page)); + link_init(&page->list); + spin_lock_init(&page->lock); + page->offset = pfn_offset; + page->owner = vm_obj; + list_insert(&page->list, &memdev->page_list); + + return page; +} + +/* All mmapable devices are handled by this */ +struct vm_pager memdev_pager = { + .ops = { + .page_in = memdev_page_in, + }, +}; + + diff --git a/conts/posix/mm0/src/execve.c b/conts/posix/mm0/src/execve.c new file mode 100644 index 0000000..3b54fc2 --- /dev/null +++ b/conts/posix/mm0/src/execve.c @@ -0,0 +1,366 @@ +/* + * Program execution + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* + * Probes and parses the low-level executable file format and creates a + * generic execution description that can be used to run the task. + */ +int task_setup_from_executable(struct vm_file *vmfile, struct tcb *task, + struct exec_file_desc *efd) +{ + memset(efd, 0, sizeof(*efd)); + + return elf_parse_executable(task, vmfile, efd); +} + +int do_execve(struct tcb *sender, char *filename, struct args_struct *args, + struct args_struct *env) +{ + unsigned long vnum, length; + struct vm_file *vmfile; + struct exec_file_desc efd; + struct tcb *new_task, *tgleader; + int err; + + /* Get file info from vfs */ + if ((err = vfs_open_bypath(filename, &vnum, &length)) < 0) + return err; + + /* Create and get the file structure */ + if (IS_ERR(vmfile = do_open2(0, 0, vnum, length))) + return (int)vmfile; + + /* Create a new tcb */ + if (IS_ERR(new_task = tcb_alloc_init(TCB_NO_SHARING))) { + vm_file_put(vmfile); + return (int)new_task; + } + + /* Fill and validate tcb memory segment markers from executable file */ + if ((err = task_setup_from_executable(vmfile, new_task, &efd)) < 0) { + vm_file_put(vmfile); + kfree(new_task); + return err; + } + + /* + * If sender is a thread in a group, need to find the + * group leader and destroy all threaded children in + * the group. + */ + if (sender->clone_flags & TCB_SHARED_TGROUP) { + struct tcb *thread; + + /* Find the thread group leader of sender */ + BUG_ON(!(tgleader = find_task(sender->tgid))); + + /* Destroy all children threads. */ + list_foreach_struct(thread, &tgleader->children, child_ref) + do_exit(thread, 0); + } else { + /* Otherwise group leader is same as sender */ + tgleader = sender; + } + + /* + * Copy data to be retained from exec'ing task to new one. + * Release all task resources, do everything done in + * exit() except destroying the actual thread. + */ + if ((err = execve_recycle_task(new_task, tgleader)) < 0) { + vm_file_put(vmfile); + kfree(new_task); + return err; + } + + /* Map task's new segment markers as virtual memory regions */ + if ((err = task_mmap_segments(new_task, vmfile, &efd, args, env)) < 0) { + vm_file_put(vmfile); + kfree(new_task); + return err; + } + + /* Set up task registers via exchange_registers() */ + task_setup_registers(new_task, 0, new_task->args_start, new_task->pagerid); + + /* Add new task to global list */ + global_add_task(new_task); + + /* Start the task */ + task_start(new_task); + +#if 0 +TODO: +Dynamic Linking. + + /* See if an interpreter (dynamic linker) is needed */ + + /* Find the interpreter executable file, if needed */ + + /* + * Map all dynamic linker file segments + * (should not clash with original executable + */ + + /* Set up registers to run dynamic linker (exchange_registers()) */ + + /* Run the interpreter */ + + /* + * The interpreter will: + * - Need some initial info (dyn sym tables) at a certain location + * - Find necessary shared library files in userspace + * (will use open/read). + * - Map them into process address space via mmap() + * - Reinitialise references to symbols in the shared libraries + * - Jump to the entry point of main executable. + */ +#endif + return 0; +} + +/* + * Copy from one buffer to another. Stop if maxlength or + * a page boundary is hit. + */ +int strncpy_page(void *to_ptr, void *from_ptr, int maxlength) +{ + int count = 0; + char *to = to_ptr, *from = from_ptr; + + do { + if ((to[count] = from[count]) == '\0') { + count++; + break; + } else + count++; + } while (count < maxlength && !page_boundary(&from[count])); + + if (page_boundary(&from[count])) + return -EFAULT; + if (count == maxlength) + return -E2BIG; + + return count; +} + +/* + * Copy from one buffer to another. Stop if maxlength or + * a page boundary is hit. Breaks if unsigned long sized copy value is 0, + * as opposed to a 0 byte as in string copy. If byte size 0 was used + * a valid pointer with a 0 byte in it would give a false termination. + */ +int bufncpy_page(void *to_ptr, void *from_ptr, int maxlength) +{ + int count = 0; + unsigned long *to = to_ptr, *from = from_ptr; + + do { + if ((to[count] = from[count]) == 0) { + count++; + break; + } else + count++; + } while (count < maxlength && !page_boundary(&from[count])); + + if (page_boundary(&from[count])) + return -EFAULT; + if (count == maxlength) + return -E2BIG; + + return count; +} + +/* + * Copies a variable sized userspace string or array of pointers + * (think &argv[0]), into buffer. If a page boundary is hit, + * unmaps the previous page, validates and maps the new page. + */ +int copy_user_buf(struct tcb *task, void *buf, char *user, int maxlength, + int elem_size) +{ + int count = maxlength; + int copied = 0, ret = 0, total = 0; + void *mapped = 0; + int (*copy_func)(void *, void *, int count); + + /* This bit determines what size copier function to use. */ + if (elem_size == sizeof(char)) + copy_func = strncpy_page; + else if (elem_size == sizeof(unsigned long)) + copy_func = bufncpy_page; + else + return -EINVAL; + + /* Map the first page the user buffer is in */ + if (!(mapped = pager_validate_map_user_range(task, user, + TILL_PAGE_ENDS(user), + VM_READ))) + return -EINVAL; + + while ((ret = copy_func(buf + copied, mapped, count)) < 0) { + if (ret == -E2BIG) + return ret; + else if (ret == -EFAULT) { + /* + * Copied is always in bytes no matter what elem_size is + * because we know we hit a page boundary and we increase + * by the page boundary bytes + */ + pager_unmap_user_range(mapped, TILL_PAGE_ENDS(mapped)); + copied += TILL_PAGE_ENDS(mapped); + count -= TILL_PAGE_ENDS(mapped); + if (!(mapped = + pager_validate_map_user_range(task, user + copied, + TILL_PAGE_ENDS(user + copied), + VM_READ))) + return -EINVAL; + } + } + + /* Note copied is always in bytes */ + total = (copied / elem_size) + ret; + + /* Unmap the final page */ + pager_unmap_user_range(mapped, TILL_PAGE_ENDS(mapped)); + + return total; +} + +/* + * Calls copy_user_buf with char-sized copying. This matters because + * buffer is variable and the terminator must be in char size + */ +static inline int +copy_user_string(struct tcb *task, void *buf, char *user, + int maxlength) +{ + return copy_user_buf(task, buf, user, maxlength, sizeof(char)); +} + +/* + * Calls copy_user_buf with unsigned long sized copying. This matters + * because buffer is variable and the terminator must be in ulong size + */ +static inline int +copy_user_ptrs(struct tcb *task, void *buf, char *user, + int maxlength) +{ + return copy_user_buf(task, buf, user, maxlength, sizeof(unsigned long)); +} + + +int copy_user_args(struct tcb *task, struct args_struct *args, + void *argv_user, int args_max) +{ + char **argv = 0; + void *argsbuf; + char *curbuf; + int argc = 0; + int used; + int count; + + if (!(argsbuf = kzalloc(args_max))) + return -ENOMEM; + + /* + * First, copy the null-terminated array of + * pointers to argument strings. + */ + if ((count = copy_user_ptrs(task, argsbuf, argv_user, args_max)) < 0) + goto out; + + /* On success, we get the number of arg strings + the terminator */ + argc = count - 1; + used = count * sizeof(char *); + argv = argsbuf; + curbuf = argsbuf + used; + + /* Now we copy each argument string into buffer */ + for (int i = 0; i < argc; i++) { + /* Copy string into empty space in buffer */ + if ((count = copy_user_string(task, curbuf, argv[i], + args_max - used)) < 0) + goto out; + + /* Replace pointer to string with copied location */ + argv[i] = curbuf; + + /* Update current empty buffer location */ + curbuf += count; + + /* Increase used buffer count */ + used += count; + } + + /* Set up the args struct */ + args->argc = argc; + args->argv = argv; + args->size = used; + + return 0; + +out: + kfree(argsbuf); + return count; +} + +int sys_execve(struct tcb *sender, char *pathname, char *argv[], char *envp[]) +{ + int ret; + char *path; + struct args_struct args; + struct args_struct env; + + if (!(path = kzalloc(PATH_MAX))) + return -ENOMEM; + + memset(&args, 0, sizeof(args)); + memset(&env, 0, sizeof(env)); + + /* Copy the executable path string */ + if ((ret = copy_user_string(sender, path, pathname, PATH_MAX)) < 0) + return ret; + // printf("%s: Copied pathname: %s\n", __FUNCTION__, path); + + /* Copy the args */ + if (argv && ((ret = copy_user_args(sender, &args, argv, ARGS_MAX)) < 0)) + goto out1; + + /* Copy the env */ + if (envp && ((ret = copy_user_args(sender, &env, envp, + ARGS_MAX - args.size)) < 0)) + goto out2; + + ret = do_execve(sender, path, &args, &env); + + if (env.argv) + kfree(env.argv); +out2: + if (args.argv) + kfree(args.argv); +out1: + kfree(path); + return ret; +} + diff --git a/conts/posix/mm0/src/exit.c b/conts/posix/mm0/src/exit.c new file mode 100644 index 0000000..1f8f17d --- /dev/null +++ b/conts/posix/mm0/src/exit.c @@ -0,0 +1,166 @@ +/* + * exit() + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Sends vfs task information about forked child, and its utcb + */ +int vfs_notify_exit(struct tcb *task, int status) +{ + int err = 0; + + // printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + + l4_save_ipcregs(); + + /* Write parent and child information */ + write_mr(L4SYS_ARG0, task->tid); + write_mr(L4SYS_ARG1, status); + + if ((err = l4_sendrecv(VFS_TID, VFS_TID, + L4_IPC_TAG_NOTIFY_EXIT)) < 0) { + printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + goto out; + } + + /* Check if syscall was successful */ + if ((err = l4_get_retval()) < 0) { + printf("%s: VFS returned ipc error: %d.\n", + __FUNCTION__, err); + goto out; + } + +out: + l4_restore_ipcregs(); + return err; +} + + +/* Closes all file descriptors of a task */ +int task_close_files(struct tcb *task) +{ + int err = 0; + + /* Flush all file descriptors */ + for (int fd = 0; fd < TASK_FILES_MAX; fd++) + if (task->files->fd[fd].vmfile) + if ((err = sys_close(task, fd)) < 0) { + printf("File close error. Tid: %d," + " fd: %d, error: %d\n", + task->tid, fd, err); + break; + } + return err; +} + +/* Prepare old task's environment for new task */ +int execve_recycle_task(struct tcb *new, struct tcb *orig) +{ + int err; + struct task_ids ids = { + .tid = orig->tid, + .spid = orig->spid, + .tgid = orig->tgid, + }; + + /* + * Copy data to new task that is + * to be retained from original + */ + + /* Copy ids */ + new->tid = orig->tid; + new->spid = orig->spid; + new->tgid = orig->tgid; + new->pagerid = orig->pagerid; + + /* Copy shared page */ + new->shared_page = orig->shared_page; + + /* Copy parent relationship */ + BUG_ON(new->parent); + new->parent = orig->parent; + list_insert(&new->child_ref, &orig->parent->children); + + /* Flush all IO on task's files and close fds */ + task_close_files(orig); + + /* Destroy task's utcb slot */ + task_destroy_utcb(orig); + + /* Vfs still knows the thread */ + + /* Keep the shared page on vfs */ + + /* Ask the kernel to recycle the thread */ + if ((err = l4_thread_control(THREAD_RECYCLE, &ids)) < 0) { + printf("%s: Suspending thread %d failed with %d.\n", + __FUNCTION__, orig->tid, err); + return err; + } + + /* Destroy the locally known tcb */ + tcb_destroy(orig); + + return 0; +} + +void do_exit(struct tcb *task, int status) +{ + struct task_ids ids = { + .tid = task->tid, + .spid = task->spid, + .tgid = task->tgid, + }; + + /* Flush all IO on task's files and close fds */ + task_close_files(task); + + /* Destroy task's utcb slot */ + task_destroy_utcb(task); + + /* Tell vfs that task is exiting */ + vfs_notify_exit(task, status); + + /* Remove default shared page shm areas from vfs */ + // printf("Unmapping 0x%p from vfs as shared-page of %d\n", task->shared_page, task->tid); + shpage_unmap_from_task(task, find_task(VFS_TID)); + + /* Free task's local tcb */ + tcb_destroy(task); + + /* Ask the kernel to delete the thread from its records */ + l4_thread_control(THREAD_DESTROY, &ids); + + /* TODO: Wake up any waiters about task's destruction */ +#if 0 + struct tcb *parent = find_task(task->parentid); + if (parent->waiting) { + exregs_set_mr_return(status); + l4_exchange_registers(parent->tid); + l4_thread_control(THREAD_RUN, parent->tid); + } +#endif +} + +void sys_exit(struct tcb *task, int status) +{ + do_exit(task, status); +} + diff --git a/conts/posix/mm0/src/fault.c b/conts/posix/mm0/src/fault.c new file mode 100644 index 0000000..720bcc5 --- /dev/null +++ b/conts/posix/mm0/src/fault.c @@ -0,0 +1,1005 @@ +/* + * Page fault handling. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) +#include INC_SUBARCH(mm.h) +#include +#include +#include +#include +#include +#include +#include +#include + + +/* Given a page and the vma it is in, returns that page's virtual address */ +unsigned long vma_page_to_virtual(struct vm_area *vma, struct page *page) +{ + unsigned long virtual_pfn = vma->pfn_start + page->offset - vma->file_offset; + + /* Page must be contained in vma's pages */ + BUG_ON(vma->file_offset > page->offset); + + return __pfn_to_addr(virtual_pfn); +} + +unsigned long fault_to_file_offset(struct fault_data *fault) +{ + /* Fault's offset in its vma */ + unsigned long vma_off_pfn = __pfn(fault->address) - fault->vma->pfn_start; + + /* Fault's offset in the file */ + unsigned long f_off_pfn = fault->vma->file_offset + vma_off_pfn; + + return f_off_pfn; +} + +/* + * Given a reference to a vm_object link, returns the next link but + * avoids wrapping around back to head. If next is head, returns 0. + * + * vma->link1->link2->link3 + * | | | + * V V V + * vmo1 vmo2 vmo3|vm_file + * + * Example: + * Given a reference to link = vma, head = vma, returns link1. + * Given a reference to link = link3, head = vma, returns 0. + */ +struct vm_obj_link *vma_next_link(struct link *link, + struct link *head) +{ + BUG_ON(list_empty(link)); + if (link->next == head) + return 0; + else + return link_to_struct(link->next, struct vm_obj_link, list); +} + +/* Unlinks orig_link from its vma and deletes it but keeps the object. */ +struct vm_object *vma_drop_link(struct vm_obj_link *link) +{ + struct vm_object *dropped; + + /* Remove object link from vma's list */ + list_remove(&link->list); + + /* Unlink the link from object */ + dropped = vm_unlink_object(link); + + /* Delete the original link */ + kfree(link); + + return dropped; +} + +/* + * Checks if page cache pages of lesser is a subset of those of copier. + * + * FIXME: + * Note this just checks the page cache, so if any objects have pages + * swapped to disk, this function won't work, which is a logic error. + * This should really count the swapped ones as well. + */ +int vm_object_is_subset(struct vm_object *shadow, + struct vm_object *original) +{ + struct page *pc, *pl; + + /* Copier must have equal or more pages to overlap lesser */ + if (shadow->npages < original->npages) + return 0; + + /* + * Do a page by page comparison. Every lesser page + * must be in copier for overlap. + */ + list_foreach_struct(pl, &original->page_cache, list) + if (!(pc = find_page(shadow, pl->offset))) + return 0; + /* + * For all pages of lesser vmo, there seems to be a page + * in the copier vmo. So lesser is a subset of copier + */ + return 1; +} + +static inline int vm_object_is_droppable(struct vm_object *shadow, + struct vm_object *original) +{ + if (shadow->npages == original->npages && + (original->flags & VM_OBJ_SHADOW)) + return 1; + else + return 0; +} + + + +/* + * vma_merge_object() + * + * FIXME: Currently this is an optimisation that needs to go + * away when swapping is available. We have this solely because + * currently a shadow needs to identically mirror the whole + * object underneath, in order to drop it. A file that is 1MB + * long would spend 2MB until dropped. When swapping is available, + * we will go back to identical mirroring instead of merging the + * last shadow, since most unused pages would be swapped out. + */ + +/* + * When one shadow object is redundant, merges it into the shadow in front of it. + * Note it must be determined that it is redundant before calling this function. + * + * vma --> link1 --> link2 --> link3 + * | | | + * v v v + * Front Redundant Next + * Shadow Shadow Object (E.g. shadow or file) + */ +int vma_merge_object(struct vm_object *redundant) +{ + /* The redundant shadow object */ + struct vm_object *front; /* Shadow in front of redundant */ + struct vm_obj_link *last_link; + struct page *p1, *p2, *n; + + /* Check link and shadow count is really 1 */ + BUG_ON(redundant->nlinks != 1); + BUG_ON(redundant->shadows != 1); + + /* Get the last shadower object in front */ + front = link_to_struct(redundant->shdw_list.next, + struct vm_object, shref); + + /* Move all non-intersecting pages to front shadow. */ + list_foreach_removable_struct(p1, n, &redundant->page_cache, list) { + /* Page doesn't exist in front, move it there */ + if (!(p2 = find_page(front, p1->offset))) { + list_remove_init(&p1->list); + spin_lock(&p1->lock); + p1->owner = front; + spin_unlock(&p1->lock); + insert_page_olist(p1, front); + front->npages++; + } + } + + /* Sort out shadow relationships after the merge: */ + + /* Front won't be a shadow of the redundant shadow anymore */ + list_remove_init(&front->shref); + + /* Check that there really was one shadower of redundant left */ + BUG_ON(!list_empty(&redundant->shdw_list)); + + /* Redundant won't be a shadow of its next object */ + list_remove_init(&redundant->shref); + + /* Front is now a shadow of redundant's next object */ + list_insert(&front->shref, &redundant->orig_obj->shdw_list); + front->orig_obj = redundant->orig_obj; + + /* Find last link for the object */ + last_link = link_to_struct(redundant->link_list.next, + struct vm_obj_link, linkref); + + /* Drop the last link to the object */ + vma_drop_link(last_link); + + /* Redundant shadow has no shadows anymore */ + BUG_ON(--redundant->shadows < 0); + + /* Delete the redundant shadow along with all its pages. */ + vm_object_delete(redundant); + + return 0; +} + +struct vm_obj_link *vm_objlink_create(void) +{ + struct vm_obj_link *vmo_link; + + if (!(vmo_link = kzalloc(sizeof(*vmo_link)))) + return PTR_ERR(-ENOMEM); + link_init(&vmo_link->list); + link_init(&vmo_link->linkref); + + return vmo_link; +} + +/* + * Creates a bare vm_object along with its vma link, since + * the shadow will be immediately used in a vma object list. + */ +struct vm_obj_link *vma_create_shadow(void) +{ + struct vm_object *vmo; + struct vm_obj_link *vmo_link; + + if (IS_ERR(vmo_link = vm_objlink_create())) + return 0; + + if (!(vmo = vm_object_create())) { + kfree(vmo_link); + return 0; + } + vmo->flags = VM_OBJ_SHADOW; + + vm_link_object(vmo_link, vmo); + + return vmo_link; +} + +/* Allocates a new page, copies the original onto it and returns. */ +struct page *copy_to_new_page(struct page *orig) +{ + void *new_vaddr, *vaddr, *paddr; + struct page *new; + + BUG_ON(!(paddr = alloc_page(1))); + + new = phys_to_page(paddr); + + /* Map the new and orig page to self */ + new_vaddr = l4_map_helper(paddr, 1); + vaddr = l4_map_helper((void *)page_to_phys(orig), 1); + + /* Copy the page into new page */ + memcpy(new_vaddr, vaddr, PAGE_SIZE); + + /* Unmap both pages from current task. */ + l4_unmap_helper(vaddr, 1); + l4_unmap_helper(new_vaddr, 1); + + return new; +} + + +/* Copy all mapped object link stack from vma to new vma */ +int vma_copy_links(struct vm_area *new_vma, struct vm_area *vma) +{ + struct vm_obj_link *vmo_link, *new_link; + + /* Get the first object on the vma */ + BUG_ON(list_empty(&vma->vm_obj_list)); + vmo_link = link_to_struct(vma->vm_obj_list.next, + struct vm_obj_link, list); + do { + /* Create a new link */ + new_link = vm_objlink_create(); + + /* Link object with new link */ + vm_link_object(new_link, vmo_link->obj); + + /* Add the new link to vma in object order */ + list_insert_tail(&new_link->list, &new_vma->vm_obj_list); + + /* Continue traversing links, doing the same copying */ + } while((vmo_link = vma_next_link(&vmo_link->list, + &vma->vm_obj_list))); + + return 0; +} + +/* + * Determine if an object is deletable. + * + * Shadows are deleted if nlinks = 0, and + * merged if they have nlinks = 1, shadows = 1. + * See below for explanation. + * + * vfs-type vmfiles are deleted if their + * openers = 0, and their nlinks + * (i.e. mappers) = 0. + * + * shm-type vmfiles are deleted if their + * nlinks = 0, since they only have map count. + */ +int vm_object_is_deletable(struct vm_object *obj) +{ + struct vm_file *f; + + //printf("%s: Checking: ", __FUNCTION__); + //vm_object_print(obj); + + if (obj->nlinks != 0) + return 0; + + BUG_ON(obj->shadows != 0); + BUG_ON(!list_empty(&obj->shref)); + + if (obj->flags & VM_OBJ_SHADOW) + return 1; + + f = vm_object_to_file(obj); + + /* Devzero should probably never have 0 refs left */ + if (f->type == VM_FILE_DEVZERO) + return 0; + else if (f->type == VM_FILE_SHM) + return 1; + else if (f->type == VM_FILE_BOOTFILE || + f->type == VM_FILE_VFS) { + if (f->openers == 0) + return 1; + else + return 0; + } + + /* To make gcc happy */ + BUG(); + return 0; +} + +/* + * exit has: !prev, next || !next + * shadow drop has: prev, next + */ + +/* + * Shadow drops: Dropping a link to shadow does not mean the shadow's + * next object has lost a shadow. There may be other links to both. But + * when the shadow has dropped its last link, and is going to be deleted, + * it is then true that the shadow is lost by the next object. + */ +int vma_drop_merge_delete(struct vm_area *vma, struct vm_obj_link *link) +{ + struct vm_obj_link *prev, *next; + struct vm_object *obj; + + /* Get previous and next links, if they exist */ + prev = (link->list.prev == &vma->vm_obj_list) ? 0 : + link_to_struct(link->list.prev, struct vm_obj_link, list); + + next = (link->list.next == &vma->vm_obj_list) ? 0 : + link_to_struct(link->list.next, struct vm_obj_link, list); + + /* Drop the link */ + obj = vma_drop_link(link); + + /* If there is an object in front, this is a shadow drop */ + if (prev) { + BUG_ON(!(prev->obj->flags & VM_OBJ_SHADOW)); + BUG_ON(!(prev->obj->flags & VM_WRITE)); + BUG_ON(--obj->shadows < 0); + // vm_object_print(obj); + + /* Remove prev from current object's shadow list */ + BUG_ON(list_empty(&prev->obj->shref)); + list_remove_init(&prev->obj->shref); + + /* + * We don't allow dropping non-shadow objects yet, + * (see ...is_droppable) so there must be a next. + */ + BUG_ON(!next); + + /* prev is now shadow of next */ + list_insert(&prev->obj->shref, + &next->obj->shdw_list); + prev->obj->orig_obj = next->obj; + + /* + * No referrers left, meaning this object is not + * shadowing its original object anymore. + */ + if (obj->nlinks == 0) { + BUG_ON(obj->orig_obj != next->obj); + list_remove_init(&obj->shref); + } else { + /* + * Dropped object still has referrers, which + * means next has gained a new shadow. + * Here's why: + * + * T1 and T2: T2: drop- + * prev->drop->next \ + * became: T1: prev--- next + * + * Now we have both prev and current object + * in next's shadow list. + */ + next->obj->shadows++; + } + /* It's an exit, we check if there's a shadow loss */ + } else { + if (obj->nlinks == 0) { + /* Is it a shadow delete? Sort out next */ + if (next && obj->flags & VM_OBJ_SHADOW) { + BUG_ON(obj->orig_obj != next->obj); + BUG_ON(--next->obj->shadows < 0); + // vm_object_print(next->obj); + list_remove_init(&obj->shref); + } + } + } + + /* Now deal with the object itself */ + if (vm_object_is_deletable(obj)) { + dprintf("Deleting object:\n"); + // vm_object_print(obj); + vm_object_delete(obj); + } else if ((obj->flags & VM_OBJ_SHADOW) && + obj->nlinks == 1 && obj->shadows == 1) { + dprintf("Merging object:\n"); + // vm_object_print(obj); + vma_merge_object(obj); + } + + mm0_test_global_vm_integrity(); + return 0; +} + +/* + * A scenario that pretty much covers every exit() case. + * + * T = vma on a unique task + * l = link + * Sobj = Shadow object + * Fobj = File object + * + * Every l links to the object on the nearest + * row to it and on the same column. + * + * l l l l l l T + * Sobj Sobj + * + * Sobj Sobj Sobj Fobj + * + * Sobj Sobj Sobj + * l l l l l l l T + * + * l l l l l l l T + * Sobj + * + */ + +/* This version is used when exiting. */ +int vma_drop_merge_delete_all(struct vm_area *vma) +{ + struct vm_obj_link *vmo_link, *n; + + /* Vma cannot be empty */ + BUG_ON(list_empty(&vma->vm_obj_list)); + + /* Traverse and get rid of all links */ + list_foreach_removable_struct(vmo_link, n, &vma->vm_obj_list, list) + vma_drop_merge_delete(vma, vmo_link); + + return 0; +} + +/* TODO: + * - Why not allocate a swap descriptor in vma_create_shadow() rather than + * a bare vm_object? It will be needed. + * - Check refcounting of shadows, their references, page refs, + * reduces increases etc. + * + * This handles copy-on-write semantics in various situations. Returns + * page struct for copy page availabe for mapping. + * + * 1) Copy-on-write of read-only files. (Creates r/w shadows/adds pages) + * 2) Copy-on-write of forked RO shadows (Creates r/w shadows/adds pages) + * 3) Copy-on-write of shm files. (Adds pages to r/w shm file from devzero). + */ +struct page *copy_on_write(struct fault_data *fault) +{ + struct vm_obj_link *vmo_link, *shadow_link; + struct vm_object *shadow; + struct page *page, *new_page; + struct vm_area *vma = fault->vma; + unsigned long file_offset = fault_to_file_offset(fault); + + /* Get the first object, either original file or a shadow */ + if (!(vmo_link = vma_next_link(&vma->vm_obj_list, &vma->vm_obj_list))) { + printf("%s:%s: No vm object in vma!\n", + __TASKNAME__, __FUNCTION__); + BUG(); + } + + /* Is the object read-only? Create a shadow object if so. + * + * NOTE: Whenever the topmost object is read-only, a new shadow + * object must be created. When there are no shadows one is created + * because, its the original vm_object that is not writeable, and + * when there are shadows one is created because a fork had just + * happened, in which case all shadows are rendered read-only. + */ + if (!(vmo_link->obj->flags & VM_WRITE)) { + if (!(shadow_link = vma_create_shadow())) + return PTR_ERR(-ENOMEM); + + /* Initialise the shadow */ + shadow = shadow_link->obj; + shadow->orig_obj = vmo_link->obj; + shadow->flags = VM_OBJ_SHADOW | VM_WRITE; + shadow->pager = &swap_pager; + vmo_link->obj->shadows++; + // vm_object_print(vmo_link->obj); + dprintf("%s: Created a shadow:\n", __TASKNAME__); + // vm_object_print(shadow); + dprintf("%s: Original object:\n", __TASKNAME__); + // vm_object_print(shadow->orig_obj); + + /* + * Add the shadow in front of the original: + * + * vma->link0->link1 + * | | + * v v + * shadow original + */ + list_insert(&shadow_link->list, &vma->vm_obj_list); + + /* Add object to original's shadower list */ + list_insert(&shadow->shref, &shadow->orig_obj->shdw_list); + + /* Add to global object list */ + global_add_vm_object(shadow); + + } else { + /* We ought to copy the missing RW page to top shadow */ + dprintf("No new shadows. Going to add to " + "topmost r/w shadow object\n"); + shadow_link = vmo_link; + + /* + * FIXME: Here we check for the case that a cloned thread is + * doing a duplicate write request on an existing RW shadow + * page. If so, we return the existing writable page in the top + * shadow. We should find a generic way to detect duplicate + * requests and cease IPC at an earlier stage. + */ + page = shadow_link->obj->pager->ops.page_in(shadow_link->obj, + file_offset); + if (!IS_ERR(page)) + return page; + + /* + * We start page search on read-only objects. If the first + * one was writable, go to next which must be read-only. + */ + BUG_ON(!(vmo_link = vma_next_link(&vmo_link->list, + &vma->vm_obj_list))); + BUG_ON(vmo_link->obj->flags & VM_WRITE); + } + + /* Traverse the list of read-only vm objects and search for the page */ + while (IS_ERR(page = vmo_link->obj->pager->ops.page_in(vmo_link->obj, + file_offset))) { + if (!(vmo_link = vma_next_link(&vmo_link->list, + &vma->vm_obj_list))) { + printf("%s:%s: Traversed all shadows and the original " + "file's vm_object, but could not find the " + "faulty page in this vma.\n",__TASKNAME__, + __FUNCTION__); + BUG(); + } + } + + /* + * Copy the page. This traverse and copy is like a page-in operation + * of a pager, except that the page is moving along vm_objects. + */ + new_page = copy_to_new_page(page); + + /* Update page details */ + spin_lock(&new_page->lock); + BUG_ON(!list_empty(&new_page->list)); + new_page->refcnt = 0; + new_page->owner = shadow_link->obj; + new_page->offset = file_offset; + new_page->virtual = 0; + spin_unlock(&page->lock); + + /* Add the page to owner's list of in-memory pages */ + insert_page_olist(new_page, new_page->owner); + new_page->owner->npages++; + + mm0_test_global_vm_integrity(); + + /* Shared faults don't have shadows so we don't look for collapses */ + if (!(vma->flags & VMA_SHARED)) { + + /* + * Finished handling the actual fault, now check for possible + * shadow collapses. Does the shadow completely shadow the one + * underlying it? + */ + if (!(vmo_link = vma_next_link(&shadow_link->list, + &vma->vm_obj_list))) { + /* Copier must have an object under it */ + printf("Copier must have had an object under it!\n"); + BUG(); + } + if (vm_object_is_droppable(shadow_link->obj, vmo_link->obj)) + vma_drop_merge_delete(vma, vmo_link); + } + + return new_page; +} + +/* + * Handles the page fault, all entries here are assumed *legal* + * faults, i.e. do_page_fault() should have already checked + * for illegal accesses. + * + * NOTE: + * Anon/Shared pages: + * First access from first process is COW. All subsequent RW + * accesses (which are attempts of *sharing*) simply map that + * page to faulting processes. + * + * Non-anon/shared pages: + * First access from first process simply writes to the pages + * of that file. All subsequent accesses by other processes + * do so as well. + * + * FIXME: Add VM_DIRTY bit for every page that has write-faulted. + */ + +int __do_page_fault(struct fault_data *fault) +{ + unsigned int reason = fault->reason; + unsigned int vma_flags = fault->vma->flags; + unsigned int pte_flags = fault->pte_flags; + struct vm_area *vma = fault->vma; + struct vm_obj_link *vmo_link; + unsigned long file_offset; + struct page *page; + + /* Handle read */ + if ((reason & VM_READ) && (pte_flags & VM_NONE)) { + file_offset = fault_to_file_offset(fault); + + /* Get the first object, either original file or a shadow */ + if (!(vmo_link = vma_next_link(&vma->vm_obj_list, &vma->vm_obj_list))) { + printf("%s:%s: No vm object in vma!\n", + __TASKNAME__, __FUNCTION__); + BUG(); + } + + /* Traverse the list of read-only vm objects and search for the page */ + while (IS_ERR(page = vmo_link->obj->pager->ops.page_in(vmo_link->obj, + file_offset))) { + if (!(vmo_link = vma_next_link(&vmo_link->list, + &vma->vm_obj_list))) { + printf("%s:%s: Traversed all shadows and the original " + "file's vm_object, but could not find the " + "faulty page in this vma.\n",__TASKNAME__, + __FUNCTION__); + BUG(); + } + } + BUG_ON(!page); + } + + /* Handle write */ + if ((reason & VM_WRITE) && (pte_flags & VM_READ)) { + /* Copy-on-write. All private vmas are always COW */ + if (vma_flags & VMA_PRIVATE) { + BUG_ON(IS_ERR(page = copy_on_write(fault))); + + /* + * This handles shared pages that are both anon and non-anon. + */ + } else if ((vma_flags & VMA_SHARED)) { + file_offset = fault_to_file_offset(fault); + + /* Don't traverse, just take the first object */ + BUG_ON(!(vmo_link = vma_next_link(&vma->vm_obj_list, + &vma->vm_obj_list))); + + /* Get the page from its pager */ + if (IS_ERR(page = vmo_link->obj->pager->ops.page_in(vmo_link->obj, + file_offset))) { + /* + * Writable page does not exist, + * if it is anonymous, it needs to be COW'ed, + * otherwise the file must have paged-in this + * page, so its a bug. + */ + if (vma_flags & VMA_ANONYMOUS) { + BUG_ON(IS_ERR(page = copy_on_write(fault))); + goto out_success; + } else { + printf("%s: Could not obtain faulty " + "page from regular file.\n", + __TASKNAME__); + BUG(); + } + } + + /* + * Page and object are now dirty. Currently it's + * only relevant for file-backed shared objects. + */ + page->flags |= VM_DIRTY; + page->owner->flags |= VM_DIRTY; + } else + BUG(); + } + +out_success: + /* Map the new page to faulty task */ + l4_map((void *)page_to_phys(page), + (void *)page_align(fault->address), 1, + (reason & VM_READ) ? MAP_USR_RO_FLAGS : MAP_USR_RW_FLAGS, + fault->task->tid); + dprintf("%s: Mapped 0x%x as writable to tid %d.\n", __TASKNAME__, + page_align(fault->address), fault->task->tid); + // vm_object_print(page->owner); + + return 0; +} + +/* + * Sets all r/w shadow objects as read-only for the process + * so that as expected after a fork() operation, writes to those + * objects cause copy-on-write events. + */ +int vm_freeze_shadows(struct tcb *task) +{ + unsigned long virtual; + struct vm_area *vma; + struct vm_obj_link *vmo_link; + struct vm_object *vmo; + struct page *p; + + list_foreach_struct(vma, &task->vm_area_head->list, list) { + + /* Shared vmas don't have shadows */ + if (vma->flags & VMA_SHARED) + continue; + + /* Get the first object */ + BUG_ON(list_empty(&vma->vm_obj_list)); + vmo_link = link_to_struct(vma->vm_obj_list.next, + struct vm_obj_link, list); + vmo = vmo_link->obj; + + /* + * Is this a writeable shadow? + * + * The only R/W shadow in a vma object chain + * can be the first one, so we don't check further + * objects if first one is not what we want. + */ + if (!((vmo->flags & VM_OBJ_SHADOW) && + (vmo->flags & VM_WRITE))) + continue; + + /* Make the object read only */ + vmo->flags &= ~VM_WRITE; + vmo->flags |= VM_READ; + + /* + * Make all pages on it read-only + * in the page tables. + */ + list_foreach_struct(p, &vmo->page_cache, list) { + + /* Find virtual address of each page */ + virtual = vma_page_to_virtual(vma, p); + + /* Map the page as read-only */ + l4_map((void *)page_to_phys(p), + (void *)virtual, 1, + MAP_USR_RO_FLAGS, task->tid); + } + } + + return 0; +} + +/* + * Page fault model: + * + * A page is anonymous (e.g. stack) + * - page needs read access: + * action: map the zero page. + * - page needs write access: + * action: allocate ZI page and map that. Swap file owns the page. + * - page is swapped to swap: + * action: read back from swap file into new page. + * + * A page is file-backed but private (e.g. .data section) + * - page needs read access: + * action: read the page from its file. + * - page is swapped out before being private. (i.e. invalidated) + * action: read the page from its file. (original file) + * - page is swapped out after being private. + * action: read the page from its file. (swap file) + * - page needs write access: + * action: allocate new page, declare page as private, change its + * owner to swap file. + * + * A page is file backed but not-private, and read-only. (e.g. .text section) + * - page needs read access: + * action: read in the page from its file. + * - page is swapped out. (i.e. invalidated) + * action: read in the page from its file. + * - page needs write access: + * action: forbidden, kill task? + * + * A page is file backed but not-private, and read/write. (e.g. any data file.) + * - page needs read access: + * action: read in the page from its file. + * - page is flushed back to its original file. (i.e. instead of swap) + * action: read in the page from its file. + * - page needs write access: + * action: read the page in, give write access. + */ +int do_page_fault(struct fault_data *fault) +{ + unsigned int vma_flags = (fault->vma) ? fault->vma->flags : VM_NONE; + unsigned int reason = fault->reason; + + /* vma flags show no access */ + if (vma_flags & VM_NONE) { + printf("Illegal access, tid: %d, address: 0x%x, PC @ 0x%x,\n", + fault->task->tid, fault->address, fault->kdata->faulty_pc); + BUG(); + } + + /* The access reason is not included in the vma's listed flags */ + if (!(reason & vma_flags)) { + printf("Illegal access, tid: %d, address: 0x%x, PC @ 0x%x\n", + fault->task->tid, fault->address, fault->kdata->faulty_pc); + BUG(); + } + + if ((reason & VM_EXEC) && (vma_flags & VM_EXEC)) { + printf("Exec faults unsupported yet.\n"); + BUG(); /* Can't handle this yet. */ + } + + /* Handle legitimate faults */ + return __do_page_fault(fault); +} + +int page_fault_handler(struct tcb *sender, fault_kdata_t *fkdata) +{ + int err; + struct fault_data fault = { + /* Fault data from kernel */ + .kdata = fkdata, + .task = sender, + }; + + /* Extract fault reason, fault address etc. in generic format */ + set_generic_fault_params(&fault); + + /* Get vma info */ + if (!(fault.vma = find_vma(fault.address, + &fault.task->vm_area_head->list))) + printf("Hmm. No vma for faulty region. " + "Bad things will happen.\n"); + + /* Handle the actual fault */ + err = do_page_fault(&fault); + + /* + * Return the ipc and by doing so restart the faulty thread. + * FIXME: We could kill the thread if there was an error??? + * Perhaps via a kill message to kernel? + */ + return err; +} + +/* + * Makes the virtual to page translation for a given user task. + * It traverses the vm_objects and returns the first encountered + * instance of the page. If page is not mapped in the task's address + * space, (not faulted at all), returns error. + */ +struct page *task_virt_to_page(struct tcb *t, unsigned long virtual) +{ + unsigned long vma_offset; + unsigned long file_offset; + struct vm_obj_link *vmo_link; + struct vm_area *vma; + struct page *page; + + /* First find the vma that maps that virtual address */ + if (!(vma = find_vma(virtual, &t->vm_area_head->list))) { + //printf("%s: No VMA found for 0x%x on task: %d\n", + // __FUNCTION__, virtual, t->tid); + return PTR_ERR(-EINVAL); + } + + /* Find the pfn offset of virtual address in this vma */ + BUG_ON(__pfn(virtual) < vma->pfn_start || + __pfn(virtual) > vma->pfn_end); + vma_offset = __pfn(virtual) - vma->pfn_start; + + /* Find the file offset of virtual address in this file */ + file_offset = vma->file_offset + vma_offset; + + /* Get the first object, either original file or a shadow */ + if (!(vmo_link = vma_next_link(&vma->vm_obj_list, &vma->vm_obj_list))) { + printf("%s:%s: No vm object in vma!\n", + __TASKNAME__, __FUNCTION__); + BUG(); + } + + /* Traverse the list of read-only vm objects and search for the page */ + while (IS_ERR(page = vmo_link->obj->pager->ops.page_in(vmo_link->obj, + file_offset))) { + if (!(vmo_link = vma_next_link(&vmo_link->list, + &vma->vm_obj_list))) { + printf("%s:%s: Traversed all shadows and the original " + "file's vm_object, but could not find the " + "page in this vma.\n",__TASKNAME__, + __FUNCTION__); + BUG(); + } + } + + /* Found it */ + // printf("%s: %s: Found page with file_offset: 0x%x\n", + // __TASKNAME__, __FUNCTION__, page->offset); + // vm_object_print(vmo_link->obj); + + return page; +} + +/* + * Prefaults the page with given virtual address, to given task + * with given reasons. Multiple reasons are allowed, they are + * handled separately in order. + */ +int prefault_page(struct tcb *task, unsigned long address, + unsigned int vmflags) +{ + int err; + struct fault_data fault = { + .task = task, + .address = address, + }; + + dprintf("Pre-faulting address 0x%x, on task %d, with flags: 0x%x\n", + address, task->tid, vmflags); + + /* Find the vma */ + if (!(fault.vma = find_vma(fault.address, + &fault.task->vm_area_head->list))) { + err = -EINVAL; + dprintf("%s: Invalid: No vma for given address. %d\n", + __FUNCTION__, err); + return err; + } + + /* Flags may indicate multiple fault reasons. First do the read */ + if (vmflags & VM_READ) { + fault.pte_flags = VM_NONE; + fault.reason = VM_READ; + if ((err = do_page_fault(&fault)) < 0) + return err; + } + /* Now write */ + if (vmflags & VM_WRITE) { + fault.pte_flags = VM_READ; + fault.reason = VM_WRITE; + if ((err = do_page_fault(&fault)) < 0) + return err; + } + /* No exec or any other fault reason allowed. */ + BUG_ON(vmflags & ~(VM_READ | VM_WRITE)); + + return 0; +} + + diff --git a/conts/posix/mm0/src/file.c b/conts/posix/mm0/src/file.c new file mode 100644 index 0000000..5e5b91d --- /dev/null +++ b/conts/posix/mm0/src/file.c @@ -0,0 +1,993 @@ +/* + * File read, write, open and close. + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* Copy from one page's buffer into another page */ +int page_copy(struct page *dst, struct page *src, + unsigned long dst_offset, unsigned long src_offset, + unsigned long size) +{ + void *dstvaddr, *srcvaddr; + + BUG_ON(dst_offset + size > PAGE_SIZE); + BUG_ON(src_offset + size > PAGE_SIZE); + + dstvaddr = l4_map_helper((void *)page_to_phys(dst), 1); + srcvaddr = l4_map_helper((void *)page_to_phys(src), 1); + +#if 0 + printf("%s: Copying from page with offset %d to page with offset %d\n" + "src copy offset: 0x%x, dst copy offset: 0x%x, copy size: %d\n", + __FUNCTION__, src->offset, dst->offset, src_offset, dst_offset, + size); + + printf("%s: Copying string: %s\n", __FUNCTION__, + srcvaddr + src_offset); +#endif + + memcpy(dstvaddr + dst_offset, srcvaddr + src_offset, size); + + l4_unmap_helper(dstvaddr, 1); + l4_unmap_helper(srcvaddr, 1); + + return 0; +} + +int vfs_read(unsigned long vnum, unsigned long file_offset, + unsigned long npages, void *pagebuf) +{ + int err = 0; + + // printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + + l4_save_ipcregs(); + + write_mr(L4SYS_ARG0, vnum); + write_mr(L4SYS_ARG1, file_offset); + write_mr(L4SYS_ARG2, npages); + write_mr(L4SYS_ARG3, (u32)pagebuf); + + if ((err = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_PAGER_READ)) < 0) { + printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + goto out; + } + + /* Check if syscall was successful */ + if ((err = l4_get_retval()) < 0) { + printf("%s: Error: %d.\n", + __FUNCTION__, err); + goto out; + } + +out: + l4_restore_ipcregs(); + return err; +} + +/* + * Different from vfs_open(), which validates an already opened + * file descriptor, this call opens a new vfs file by the pager + * using the given path. The vnum handle and file length is returned + * since the pager uses this information to access file pages. + */ +int vfs_open_bypath(const char *pathname, unsigned long *vnum, unsigned long *length) +{ + int err = 0; + struct tcb *vfs; + + // printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + + if (!(vfs = find_task(VFS_TID))) + return -ESRCH; + + /* + * Copy string to vfs shared page. + * + * FIXME: There's a chance we're overwriting other tasks' + * ipc information that is on the vfs shared page. + */ + strcpy(vfs->shared_page + 0x200, pathname); + + l4_save_ipcregs(); + + write_mr(L4SYS_ARG0, (unsigned long)vfs->shared_page + 0x200); + + if ((err = l4_sendrecv(VFS_TID, VFS_TID, + L4_IPC_TAG_PAGER_OPEN_BYPATH)) < 0) { + printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + goto out; + } + + /* Check if syscall was successful */ + if ((err = l4_get_retval()) < 0) { + printf("%s: VFS open error: %d.\n", + __FUNCTION__, err); + goto out; + } + + /* Read file information */ + *vnum = read_mr(L4SYS_ARG0); + *length = read_mr(L4SYS_ARG1); + +out: + l4_restore_ipcregs(); + return err; +} + +/* + * When a task does a read/write/mmap request on a file, if + * the file descriptor is unknown to the pager, this call + * asks vfs if that file has been opened, and any other + * relevant information. + */ +int vfs_open(l4id_t opener, int fd, unsigned long *vnum, unsigned long *length) +{ + int err = 0; + + l4_save_ipcregs(); + + write_mr(L4SYS_ARG0, opener); + write_mr(L4SYS_ARG1, fd); + + if ((err = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_PAGER_OPEN)) < 0) { + printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + goto out; + } + + /* Check if syscall was successful */ + if ((err = l4_get_retval()) < 0) { + printf("%s: VFS open error: %d.\n", + __FUNCTION__, err); + goto out; + } + + /* Read file information */ + *vnum = read_mr(L4SYS_ARG0); + *length = read_mr(L4SYS_ARG1); + +out: + l4_restore_ipcregs(); + return err; +} + +/* + * Initialise a new file and the descriptor for it from given file data. + * Could be called by an actual task or a pager + */ +struct vm_file *do_open2(struct tcb *task, int fd, unsigned long vnum, unsigned long length) +{ + struct vm_file *vmfile; + + /* Is this an open by a task (as opposed to by the pager)? */ + if (task) { + /* fd slot must be empty */ + BUG_ON(task->files->fd[fd].vnum != 0); + BUG_ON(task->files->fd[fd].cursor != 0); + + /* Assign vnum to given fd on the task */ + task->files->fd[fd].vnum = vnum; + task->files->fd[fd].cursor = 0; + } + + /* Check if that vm_file is already in the list */ + list_foreach_struct(vmfile, &global_vm_files.list, list) { + + /* Check whether it is a vfs file and if so vnums match. */ + if ((vmfile->type & VM_FILE_VFS) && + vm_file_to_vnum(vmfile) == vnum) { + + /* Task opener? */ + if (task) + /* Add a reference to it from the task */ + task->files->fd[fd].vmfile = vmfile; + + vmfile->openers++; + return vmfile; + } + } + + /* Otherwise allocate a new one for this vnode */ + if (IS_ERR(vmfile = vfs_file_create())) + return vmfile; + + /* Initialise and add a reference to it from the task */ + vm_file_to_vnum(vmfile) = vnum; + vmfile->length = length; + vmfile->vm_obj.pager = &file_pager; + + /* Task opener? */ + if (task) + task->files->fd[fd].vmfile = vmfile; + vmfile->openers++; + + /* Add to file list */ + global_add_vm_file(vmfile); + + return vmfile; +} + +/* Initialise a new file and the descriptor for it from given file data */ +int do_open(struct tcb *task, int fd, unsigned long vnum, unsigned long length) +{ + struct vm_file *vmfile; + + /* fd slot must be empty */ + BUG_ON(task->files->fd[fd].vnum != 0); + BUG_ON(task->files->fd[fd].cursor != 0); + + /* Assign vnum to given fd on the task */ + task->files->fd[fd].vnum = vnum; + task->files->fd[fd].cursor = 0; + + /* Check if that vm_file is already in the list */ + list_foreach_struct(vmfile, &global_vm_files.list, list) { + + /* Check whether it is a vfs file and if so vnums match. */ + if ((vmfile->type & VM_FILE_VFS) && + vm_file_to_vnum(vmfile) == vnum) { + + /* Add a reference to it from the task */ + task->files->fd[fd].vmfile = vmfile; + vmfile->openers++; + return 0; + } + } + + /* Otherwise allocate a new one for this vnode */ + if (IS_ERR(vmfile = vfs_file_create())) + return (int)vmfile; + + /* Initialise and add a reference to it from the task */ + vm_file_to_vnum(vmfile) = vnum; + vmfile->length = length; + vmfile->vm_obj.pager = &file_pager; + task->files->fd[fd].vmfile = vmfile; + vmfile->openers++; + + /* Add to file list */ + global_add_vm_file(vmfile); + + return 0; +} + +int file_open(struct tcb *opener, int fd) +{ + int err; + unsigned long vnum; + unsigned long length; + + if (fd < 0 || fd > TASK_FILES_MAX) + return -EINVAL; + + /* Ask vfs if such a file has been recently opened */ + if ((err = vfs_open(opener->tid, fd, &vnum, &length)) < 0) + return err; + + /* Initialise local structures with received file data */ + if ((err = do_open(opener, fd, vnum, length)) < 0) + return err; + + return 0; +} + + +/* + * Inserts the page to vmfile's list in order of page frame offset. + * We use an ordered list instead of a better data structure for now. + */ +int insert_page_olist(struct page *this, struct vm_object *vmo) +{ + struct page *before, *after; + + /* Add if list is empty */ + if (list_empty(&vmo->page_cache)) { + list_insert_tail(&this->list, &vmo->page_cache); + return 0; + } + + /* Else find the right interval */ + list_foreach_struct(before, &vmo->page_cache, list) { + after = link_to_struct(before->list.next, struct page, list); + + /* If there's only one in list */ + if (before->list.next == &vmo->page_cache) { + /* Add as next if greater */ + if (this->offset > before->offset) + list_insert(&this->list, &before->list); + /* Add as previous if smaller */ + else if (this->offset < before->offset) + list_insert_tail(&this->list, &before->list); + else + BUG(); + return 0; + } + + /* If this page is in-between two other, insert it there */ + if (before->offset < this->offset && + after->offset > this->offset) { + list_insert(&this->list, &before->list); + return 0; + } + BUG_ON(this->offset == before->offset); + BUG_ON(this->offset == after->offset); + } + BUG(); +} + +/* + * This reads-in a range of pages from a file and populates the page cache + * just like a page fault, but its not in the page fault path. + */ +int read_file_pages(struct vm_file *vmfile, unsigned long pfn_start, + unsigned long pfn_end) +{ + struct page *page; + + for (int f_offset = pfn_start; f_offset < pfn_end; f_offset++) { + page = vmfile->vm_obj.pager->ops.page_in(&vmfile->vm_obj, + f_offset); + if (IS_ERR(page)) { + printf("%s: %s:Could not read page %d " + "from file with vnum: 0x%lu\n", __TASKNAME__, + __FUNCTION__, f_offset, vm_file_to_vnum(vmfile)); + return (int)page; + } + } + + return 0; +} + +int vfs_write(unsigned long vnum, unsigned long file_offset, + unsigned long npages, void *pagebuf) +{ + int err = 0; + + // printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + l4_save_ipcregs(); + + write_mr(L4SYS_ARG0, vnum); + write_mr(L4SYS_ARG1, file_offset); + write_mr(L4SYS_ARG2, npages); + write_mr(L4SYS_ARG3, (u32)pagebuf); + + if ((err = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_PAGER_WRITE)) < 0) { + printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + goto out; + } + + /* Check if syscall was successful */ + if ((err = l4_get_retval()) < 0) { + printf("%s: Pager to VFS write error: %d.\n", __FUNCTION__, err); + goto out; + } + +out: + l4_restore_ipcregs(); + return err; +} + +int vfs_close(l4id_t sender, int fd) +{ + int err = 0; + + // printf("%s/%s Sending to %d\n", __TASKNAME__, __FUNCTION__, VFS_TID); + l4_save_ipcregs(); + + write_mr(L4SYS_ARG0, sender); + write_mr(L4SYS_ARG1, fd); + + if ((err = l4_sendrecv(VFS_TID, VFS_TID, L4_IPC_TAG_PAGER_CLOSE)) < 0) { + printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + goto out; + } + // printf("%s/%s Received from %d\n", __TASKNAME__, __FUNCTION__, VFS_TID); + + /* Check if syscall was successful */ + if ((err = l4_get_retval()) < 0) { + printf("%s: Pager to VFS write error: %d.\n", __FUNCTION__, err); + goto out; + } + +out: + l4_restore_ipcregs(); + return err; +} + +/* Writes updated file stats back to vfs. (e.g. new file size) */ +int vfs_update_file_stats(struct vm_file *f) +{ + int err = 0; + + // printf("%s/%s\n", __TASKNAME__, __FUNCTION__); + l4_save_ipcregs(); + + write_mr(L4SYS_ARG0, vm_file_to_vnum(f)); + write_mr(L4SYS_ARG1, f->length); + + if ((err = l4_sendrecv(VFS_TID, VFS_TID, + L4_IPC_TAG_PAGER_UPDATE_STATS)) < 0) { + printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err); + goto out; + } + + /* Check if syscall was successful */ + if ((err = l4_get_retval()) < 0) { + printf("%s: Pager to VFS write error: %d.\n", + __FUNCTION__, err); + goto out; + } + +out: + l4_restore_ipcregs(); + return err; +} + +/* Writes pages in cache back to their file */ +int write_file_pages(struct vm_file *f, unsigned long pfn_start, + unsigned long pfn_end) +{ + int err; + + /* We have only thought of vfs files for this */ + BUG_ON(f->type != VM_FILE_VFS); + + /* Need not flush files that haven't been written */ + if (!(f->vm_obj.flags & VM_DIRTY)) + return 0; + + BUG_ON(pfn_end != __pfn(page_align_up(f->length))); + for (int f_offset = pfn_start; f_offset < pfn_end; f_offset++) { + err = f->vm_obj.pager->ops.page_out(&f->vm_obj, f_offset); + if (err < 0) { + printf("%s: %s:Could not write page %d " + "to file with vnum: 0x%lu\n", __TASKNAME__, + __FUNCTION__, f_offset, vm_file_to_vnum(f)); + return err; + } + } + + return 0; +} + +/* Flush all dirty file pages and update file stats */ +int flush_file_pages(struct vm_file *f) +{ + int err; + + if ((err = write_file_pages(f, 0, __pfn(page_align_up(f->length)))) < 0) + return err; + + if ((err = vfs_update_file_stats(f)) < 0) + return err; + + return 0; +} + +/* Given a task and fd, syncs all IO on it */ +int fsync_common(struct tcb *task, int fd) +{ + int err; + + /* Check fd validity */ + if (fd < 0 || fd > TASK_FILES_MAX) + return -EINVAL; + + /* + * If we don't know about the file, even if it was + * opened by the vfs, it is sure that there's no + * pending IO on it. We simply return. + */ + if (!task->files->fd[fd].vmfile) + return 0; + + /* Finish I/O on file */ + if ((err = flush_file_pages(task->files->fd[fd].vmfile)) < 0) + return err; + + return 0; +} + +void vm_file_put(struct vm_file *file) +{ + /* Reduce file's opener count */ + if (!(file->openers--)) + /* No openers left, check any mappers */ + if (!file->vm_obj.nlinks) + /* No links or openers, delete the file */ + vm_file_delete(file); + +} + +/* Closes the file descriptor and notifies vfs */ +int do_close(struct tcb *task, int fd) +{ + int err; + + // printf("%s: Closing fd: %d on task %d\n", __FUNCTION__, + // fd, task->tid); + if ((err = vfs_close(task->tid, fd)) < 0) + return err; + + /* + * If there was no IO on it, we may not know the file, + * we simply return here. Since we notify VFS about the + * close, it can tell us if the fd was open or not. + */ + if (!task->files->fd[fd].vmfile) + return 0; + + /* Reduce file refcount etc. */ + vm_file_put(task->files->fd[fd].vmfile); + + task->files->fd[fd].vnum = 0; + task->files->fd[fd].cursor = 0; + task->files->fd[fd].vmfile = 0; + + return 0; +} + +int sys_close(struct tcb *task, int fd) +{ + int ret; + + /* Sync the file and update stats */ + if ((ret = fsync_common(task, fd)) < 0) + return ret; + + /* Close the file descriptor. */ + return do_close(task, fd); +} + +int sys_fsync(struct tcb *task, int fd) +{ + /* Sync the file and update stats */ + return fsync_common(task, fd); +} + +/* FIXME: Add error handling to this */ +/* Extends a file's size by adding it new pages */ +int new_file_pages(struct vm_file *f, unsigned long start, unsigned long end) +{ + unsigned long npages = end - start; + struct page *page; + void *paddr; + + /* Allocate the memory for new pages */ + if (!(paddr = alloc_page(npages))) + return -ENOMEM; + + /* Process each page */ + for (unsigned long i = 0; i < npages; i++) { + page = phys_to_page(paddr + PAGE_SIZE * i); + page_init(page); + page->refcnt++; + page->owner = &f->vm_obj; + page->offset = start + i; + page->virtual = 0; + + /* Add the page to file's vm object */ + BUG_ON(!list_empty(&page->list)); + insert_page_olist(page, &f->vm_obj); + } + + /* Update vm object */ + f->vm_obj.npages += npages; + + return 0; +} + +/* TODO: + * Re-evaluate. Possibly merge with read_cache_pages. + */ + +/* Writes user data in buffer into pages in cache */ +int write_cache_pages_orig(struct vm_file *vmfile, struct tcb *task, void *buf, + unsigned long pfn_start, unsigned long pfn_end, + unsigned long cursor_offset, int count) +{ + struct page *head, *this; + unsigned long last_pgoff; /* Last copied page's offset */ + unsigned long copy_offset; /* Current copy offset on the buffer */ + int copysize, left; + + /* Find the head of consecutive pages */ + list_foreach_struct(head, &vmfile->vm_obj.page_cache, list) + if (head->offset == pfn_start) + goto copy; + + /* + * Page not found, this is a bug. The writeable page range + * must have been readied by read_file_pages()/new_file_pages(). + */ + BUG(); + +copy: + left = count; + + /* Copy the first page and unmap. */ + copysize = (left < PAGE_SIZE) ? left : PAGE_SIZE; + copy_offset = (unsigned long)buf; + page_copy(head, task_virt_to_page(task, copy_offset), + cursor_offset, copy_offset & PAGE_MASK, copysize); + head->flags |= VM_DIRTY; + head->owner->flags |= VM_DIRTY; + left -= copysize; + last_pgoff = head->offset; + + /* Map the rest, copy and unmap. */ + list_foreach_struct(this, &head->list, list) { + if (left == 0 || this->offset == pfn_end) + break; + + /* Make sure we're advancing on pages consecutively */ + BUG_ON(this->offset != last_pgoff + 1); + + copysize = (left < PAGE_SIZE) ? left : PAGE_SIZE; + copy_offset = (unsigned long)buf + count - left; + + /* Must be page aligned */ + BUG_ON(!is_page_aligned(copy_offset)); + + page_copy(this, task_virt_to_page(task, copy_offset), + 0, 0, copysize); + this->flags |= VM_DIRTY; + left -= copysize; + last_pgoff = this->offset; + } + BUG_ON(left != 0); + + return count - left; +} + +/* + * Writes user data in buffer into pages in cache. If a page is not + * found, it's a bug. The writeable page range must have been readied + * by read_file_pages()/new_file_pages(). + */ +int write_cache_pages(struct vm_file *vmfile, struct tcb *task, void *buf, + unsigned long pfn_start, unsigned long pfn_end, + unsigned long cursor_offset, int count) +{ + struct page *head; + unsigned long last_pgoff; /* Last copied page's offset */ + unsigned long copy_offset; /* Current copy offset on the buffer */ + int copysize, left; + + /* Find the head of consecutive pages */ + list_foreach_struct(head, &vmfile->vm_obj.page_cache, list) { + /* First page */ + if (head->offset == pfn_start) { + left = count; + + /* Copy the first page and unmap. */ + copysize = (left < PAGE_SIZE) ? left : PAGE_SIZE; + copy_offset = (unsigned long)buf; + page_copy(head, task_virt_to_page(task, copy_offset), + cursor_offset, copy_offset & PAGE_MASK, copysize); + head->flags |= VM_DIRTY; + head->owner->flags |= VM_DIRTY; + left -= copysize; + last_pgoff = head->offset; + + /* Rest of the consecutive pages */ + } else if (head->offset > pfn_start && head->offset < pfn_end) { + + /* Make sure we're advancing on pages consecutively */ + BUG_ON(head->offset != last_pgoff + 1); + + copysize = (left < PAGE_SIZE) ? left : PAGE_SIZE; + copy_offset = (unsigned long)buf + count - left; + + /* Must be page aligned */ + BUG_ON(!is_page_aligned(copy_offset)); + + page_copy(head, task_virt_to_page(task, copy_offset), + 0, 0, copysize); + head->flags |= VM_DIRTY; + left -= copysize; + last_pgoff = head->offset; + } else if (head->offset == pfn_end || left == 0) + break; + } + + BUG_ON(left != 0); + + return count - left; +} + +/* + * Reads a page range from an ordered list of pages into buffer. + * + * NOTE: + * This assumes the page range is consecutively available in the cache + * and count bytes are available. To ensure this, read_file_pages must + * be called first and count must be checked. Since it has read-checking + * assumptions, count must be satisfied. + */ +int read_cache_pages(struct vm_file *vmfile, struct tcb *task, void *buf, + unsigned long pfn_start, unsigned long pfn_end, + unsigned long cursor_offset, int count) +{ + struct page *head, *this; + int copysize, left; + unsigned long last_pgoff; /* Last copied page's offset */ + unsigned long copy_offset; /* Current copy offset on the buffer */ + + /* Find the head of consecutive pages */ + list_foreach_struct(head, &vmfile->vm_obj.page_cache, list) + if (head->offset == pfn_start) + goto copy; + + /* Page not found, nothing read */ + return 0; + +copy: + left = count; + + /* Copy the first page and unmap. */ + copysize = (left < PAGE_SIZE) ? left : PAGE_SIZE; + copy_offset = (unsigned long)buf; + page_copy(task_virt_to_page(task, copy_offset), head, + PAGE_MASK & copy_offset, cursor_offset, copysize); + left -= copysize; + last_pgoff = head->offset; + + /* Map the rest, copy and unmap. */ + list_foreach_struct(this, &head->list, list) { + if (left == 0 || this->offset == pfn_end) + break; + + /* Make sure we're advancing on pages consecutively */ + BUG_ON(this->offset != last_pgoff + 1); + + /* Get copying size and start offset */ + copysize = (left < PAGE_SIZE) ? left : PAGE_SIZE; + copy_offset = (unsigned long)buf + count - left; + + /* MUST be page aligned */ + BUG_ON(!is_page_aligned(copy_offset)); + + page_copy(task_virt_to_page(task, copy_offset), + this, 0, 0, copysize); + left -= copysize; + last_pgoff = this->offset; + } + BUG_ON(left != 0); + + return count - left; +} + +int sys_read(struct tcb *task, int fd, void *buf, int count) +{ + unsigned long pfn_start, pfn_end; + unsigned long cursor, byte_offset; + struct vm_file *vmfile; + int ret = 0; + + /* Check fd validity */ + if (!task->files->fd[fd].vmfile) + if ((ret = file_open(task, fd)) < 0) + return ret; + + + /* Check count validity */ + if (count < 0) + return -EINVAL; + else if (!count) + return 0; + + /* Check user buffer validity. */ + if ((ret = pager_validate_user_range(task, buf, + (unsigned long)count, + VM_READ)) < 0) + return -EFAULT; + + vmfile = task->files->fd[fd].vmfile; + cursor = task->files->fd[fd].cursor; + + /* If cursor is beyond file end, simply return 0 */ + if (cursor >= vmfile->length) + return 0; + + /* Start and end pages expected to be read by user */ + pfn_start = __pfn(cursor); + pfn_end = __pfn(page_align_up(cursor + count)); + + /* But we can read up to maximum file size */ + pfn_end = __pfn(page_align_up(vmfile->length)) < pfn_end ? + __pfn(page_align_up(vmfile->length)) : pfn_end; + + /* If trying to read more than end of file, reduce it to max possible */ + if (cursor + count > vmfile->length) + count = vmfile->length - cursor; + + /* Read the page range into the cache from file */ + if ((ret = read_file_pages(vmfile, pfn_start, pfn_end)) < 0) + return ret; + + /* The offset of cursor on first page */ + byte_offset = PAGE_MASK & cursor; + + /* Read it into the user buffer from the cache */ + if ((count = read_cache_pages(vmfile, task, buf, pfn_start, pfn_end, + byte_offset, count)) < 0) + return count; + + /* Update cursor on success */ + task->files->fd[fd].cursor += count; + + return count; +} + +/* FIXME: + * + * Error: + * We find the page buffer is in, and then copy from the *start* of the page + * rather than buffer's offset in that page. - I think this is fixed. + */ +int sys_write(struct tcb *task, int fd, void *buf, int count) +{ + unsigned long pfn_wstart, pfn_wend; /* Write start/end */ + unsigned long pfn_fstart, pfn_fend; /* File start/end */ + unsigned long pfn_nstart, pfn_nend; /* New pages start/end */ + unsigned long cursor, byte_offset; + struct vm_file *vmfile; + int ret = 0; + + /* Check fd validity */ + if (!task->files->fd[fd].vmfile) + if ((ret = file_open(task, fd)) < 0) + return ret; + + /* Check count validity */ + if (count < 0) + return -EINVAL; + else if (!count) + return 0; + + + /* Check user buffer validity. */ + if ((ret = pager_validate_user_range(task, buf, + (unsigned long)count, + VM_WRITE | VM_READ)) < 0) + return -EINVAL; + + vmfile = task->files->fd[fd].vmfile; + cursor = task->files->fd[fd].cursor; + + /* See what pages user wants to write */ + pfn_wstart = __pfn(cursor); + pfn_wend = __pfn(page_align_up(cursor + count)); + + /* Get file start and end pages */ + pfn_fstart = 0; + pfn_fend = __pfn(page_align_up(vmfile->length)); + + /* + * Find the intersection to determine which pages are + * already part of the file, and which ones are new. + */ + if (pfn_wstart < pfn_fend) { + pfn_fstart = pfn_wstart; + + /* + * Shorten the end if end page is + * less than file size + */ + if (pfn_wend < pfn_fend) { + pfn_fend = pfn_wend; + + /* This also means no new pages in file */ + pfn_nstart = 0; + pfn_nend = 0; + } else { + + /* The new pages start from file end, + * and end by write end. */ + pfn_nstart = pfn_fend; + pfn_nend = pfn_wend; + } + + } else { + /* No intersection, its all new pages */ + pfn_fstart = 0; + pfn_fend = 0; + pfn_nstart = pfn_wstart; + pfn_nend = pfn_wend; + } + + /* + * Read in the portion that's already part of the file. + */ + if ((ret = read_file_pages(vmfile, pfn_fstart, pfn_fend)) < 0) + return ret; + + /* Create new pages for the part that's new in the file */ + if ((ret = new_file_pages(vmfile, pfn_nstart, pfn_nend)) < 0) + return ret; + + /* + * At this point be it new or existing file pages, all pages + * to be written are expected to be in the page cache. Write. + */ + byte_offset = PAGE_MASK & cursor; + if ((ret = write_cache_pages(vmfile, task, buf, pfn_wstart, + pfn_wend, byte_offset, count)) < 0) + return ret; + + /* + * Update the file size, and cursor. vfs will be notified + * of this change when the file is flushed (e.g. via fflush() + * or close()) + */ + if (task->files->fd[fd].cursor + count > vmfile->length) + vmfile->length = task->files->fd[fd].cursor + count; + + task->files->fd[fd].cursor += count; + + return count; +} + +/* FIXME: Check for invalid cursor values. Check for total, sometimes negative. */ +int sys_lseek(struct tcb *task, int fd, off_t offset, int whence) +{ + int retval = 0; + unsigned long long total, cursor; + + /* Check fd validity */ + if (!task->files->fd[fd].vmfile) + if ((retval = file_open(task, fd)) < 0) + return retval; + + /* Offset validity */ + if (offset < 0) + return -EINVAL; + + switch (whence) { + case SEEK_SET: + retval = task->files->fd[fd].cursor = offset; + break; + case SEEK_CUR: + cursor = (unsigned long long)task->files->fd[fd].cursor; + if (cursor + offset > 0xFFFFFFFF) + retval = -EINVAL; + else + retval = task->files->fd[fd].cursor += offset; + break; + case SEEK_END: + cursor = (unsigned long long)task->files->fd[fd].cursor; + total = (unsigned long long)task->files->fd[fd].vmfile->length; + if (cursor + total > 0xFFFFFFFF) + retval = -EINVAL; + else { + retval = task->files->fd[fd].cursor = + task->files->fd[fd].vmfile->length + offset; + } + default: + retval = -EINVAL; + break; + } + + return retval; +} + diff --git a/conts/posix/mm0/src/init.c b/conts/posix/mm0/src/init.c new file mode 100644 index 0000000..5816a4a --- /dev/null +++ b/conts/posix/mm0/src/init.c @@ -0,0 +1,288 @@ +/* + * Initialise the system. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* A separate list than the generic file list that keeps just the boot files */ +LINK_DECLARE(boot_file_list); + +/* Kernel data acquired during initialisation */ +__initdata struct initdata initdata; + +void print_bootdesc(struct bootdesc *bd) +{ + for (int i = 0; i < bd->total_images; i++) { + printf("Task Image: %d\n", i); + printf("Name: %s\n", bd->images[i].name); + printf("Start: 0x%x\n", bd->images[i].phys_start); + printf("End: 0x%x\n", bd->images[i].phys_end); + } +} + +void print_pfn_range(int pfn, int size) +{ + unsigned int addr = pfn << PAGE_BITS; + unsigned int end = (pfn + size) << PAGE_BITS; + printf("Used: 0x%x - 0x%x\n", addr, end); +} + +#if 0 +void print_page_map(struct page_bitmap *map) +{ + unsigned int start_pfn = 0; + unsigned int total_used = 0; + int numpages = 0; + + // printf("Page map: 0x%x-0x%x\n", map->pfn_start << PAGE_BITS, map->pfn_end << PAGE_BITS); + for (int i = 0; i < (PHYSMEM_TOTAL_PAGES >> 5); i++) { + for (int x = 0; x < WORD_BITS; x++) { + if (map->map[i] & (1 << x)) { /* A used page found? */ + if (!start_pfn) /* First such page found? */ + start_pfn = (WORD_BITS * i) + x; + total_used++; + numpages++; /* Increase number of pages */ + } else { /* Either used pages ended or were never found */ + if (start_pfn) { /* We had a used page */ + /* Finished end of used range. + * Print and reset. */ + //print_pfn_range(start_pfn, numpages); + start_pfn = 0; + numpages = 0; + } + } + } + } + printf("%s: Pagemap: Total of %d used physical pages. %d Kbytes used.\n", __TASKNAME__, total_used, total_used << 2); +} +#endif + +/* + * A specialised function for setting up the task environment of mm0. + * Essentially all the memory regions are set up but a new task isn't + * created, registers aren't assigned, and thread not started, since + * these are all already done by the kernel. But we do need a memory + * environment for mm0, hence this function. + */ +int mm0_task_init(struct vm_file *f, unsigned long task_start, + unsigned long task_end, struct task_ids *ids) +{ + int err; + struct tcb *task; + + /* + * The thread itself is already known by the kernel, so we just + * allocate a local task structure. + */ + BUG_ON(IS_ERR(task = tcb_alloc_init(TCB_NO_SHARING))); + + task->tid = ids->tid; + task->spid = ids->spid; + task->tgid = ids->tgid; + + if ((err = boottask_setup_regions(f, task, + task_start, task_end)) < 0) + return err; + + if ((err = boottask_mmap_regions(task, f)) < 0) + return err; + + /* Set pager as child and parent of itself */ + list_insert(&task->child_ref, &task->children); + task->parent = task; + + /* + * The first UTCB address is already assigned by the + * microkernel for this pager. Ensure that we also get + * the same from our internal utcb bookkeeping. + */ + BUG_ON(task->utcb_address != UTCB_AREA_START); + + /* Pager must prefault its utcb */ + prefault_page(task, task->utcb_address, + VM_READ | VM_WRITE); + + /* Add the task to the global task list */ + global_add_task(task); + + /* Add the file to global vm lists */ + global_add_vm_file(f); + + return 0; +} + +struct vm_file *initdata_next_bootfile(struct initdata *initdata) +{ + struct vm_file *file, *n; + list_foreach_removable_struct(file, n, + &initdata->boot_file_list, + list) { + list_remove_init(&file->list); + return file; + } + return 0; +} + +/* + * Reads boot files from init data, determines their task ids if they + * match with particular servers, and starts the tasks. + */ +int start_boot_tasks(struct initdata *initdata) +{ + struct vm_file *file = 0, *fs0_file = 0, *mm0_file = 0, *n; + struct tcb *fs0_task; + struct svc_image *img; + struct task_ids ids; + struct link other_files; + int total = 0; + + link_init(&other_files); + + /* Separate out special server tasks and regular files */ + do { + file = initdata_next_bootfile(initdata); + + if (file) { + BUG_ON(file->type != VM_FILE_BOOTFILE); + img = file->priv_data; + if (!strcmp(img->name, __PAGERNAME__)) + mm0_file = file; + else if (!strcmp(img->name, __VFSNAME__)) + fs0_file = file; + else + list_insert(&file->list, &other_files); + } else + break; + } while (1); + + /* MM0 needs partial initialisation since it's already running. */ + // printf("%s: Initialising mm0 tcb.\n", __TASKNAME__); + ids.tid = PAGER_TID; + ids.spid = PAGER_TID; + ids.tgid = PAGER_TID; + + if (mm0_task_init(mm0_file, INITTASK_AREA_START, + INITTASK_AREA_END, &ids) < 0) + BUG(); + total++; + + /* Initialise vfs with its predefined id */ + ids.tid = VFS_TID; + ids.spid = VFS_TID; + ids.tgid = VFS_TID; + + // printf("%s: Initialising fs0\n",__TASKNAME__); + BUG_ON((IS_ERR(fs0_task = boottask_exec(fs0_file, USER_AREA_START, + USER_AREA_END, &ids)))); + total++; + + /* Initialise other tasks */ + list_foreach_removable_struct(file, n, &other_files, list) { + ids.tid = TASK_ID_INVALID; + ids.spid = TASK_ID_INVALID; + ids.tgid = TASK_ID_INVALID; + list_remove_init(&file->list); + BUG_ON(IS_ERR(boottask_exec(file, USER_AREA_START, + USER_AREA_END, &ids))); + total++; + } + + if (!total) { + printf("%s: Could not start any tasks.\n", + __TASKNAME__); + BUG(); + } + + return 0; +} + +extern unsigned long _start_init[]; +extern unsigned long _end_init[]; + +/* + * Copy all necessary data from initmem to real memory, + * release initdata and any init memory used + */ +void copy_release_initdata(struct initdata *initdata) +{ + /* + * Copy boot capabilities to a list of + * real capabilities + */ + copy_boot_capabilities(initdata); + + /* Free and unmap init memory: + * + * FIXME: We can and do safely unmap the boot + * memory here, but because we don't utilize it yet, + * it remains as if it is a used block + */ + + l4_unmap(_start_init, + __pfn(page_align_up(_end_init - _start_init)), + self_tid()); +} + + +void init_mm(struct initdata *initdata) +{ + /* Initialise the page and bank descriptors */ + init_physmem_primary(initdata); + + init_physmem_secondary(initdata, membank); + + /* Initialise the page allocator on first bank. */ + init_page_allocator(membank[0].free, membank[0].end); + + /* Initialise the zero page */ + init_devzero(); + + /* Initialise in-memory boot files */ + init_boot_files(initdata); + + if (shm_pool_init() < 0) { + printf("SHM initialisation failed.\n"); + BUG(); + } + + if (utcb_pool_init() < 0) { + printf("SHM initialisation failed.\n"); + BUG(); + } +} + + +void init_pager(void) +{ + pager_address_pool_init(); + + read_kernel_capabilities(&initdata); + + read_bootdesc(&initdata); + + init_mm(&initdata); + + start_boot_tasks(&initdata); + + copy_release_initdata(&initdata); + + mm0_test_global_vm_integrity(); +} + diff --git a/conts/posix/mm0/src/lib/addr.c b/conts/posix/mm0/src/lib/addr.c new file mode 100644 index 0000000..d7c7733 --- /dev/null +++ b/conts/posix/mm0/src/lib/addr.c @@ -0,0 +1,59 @@ +/* + * This module allocates an unused address range from + * a given memory region defined as the pool range. + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include INC_GLUE(memory.h) +#include +#include + +/* + * Initializes an address pool, but uses an already + * allocated id pool for it. + */ +int address_pool_init_with_idpool(struct address_pool *pool, + struct id_pool *idpool, + unsigned long start, unsigned long end) +{ + pool->idpool = idpool; + pool->start = start; + pool->end = end; + + return 0; +} + +int address_pool_init(struct address_pool *pool, unsigned long start, unsigned long end) +{ + if ((pool->idpool = id_pool_new_init(__pfn(end - start))) < 0) + return (int)pool->idpool; + pool->start = start; + pool->end = end; + return 0; +} + +void *address_new(struct address_pool *pool, int npages) +{ + unsigned int pfn; + + if ((int)(pfn = ids_new_contiguous(pool->idpool, npages)) < 0) + return 0; + + return (void *)__pfn_to_addr(pfn) + pool->start; +} + +int address_del(struct address_pool *pool, void *addr, int npages) +{ + unsigned long pfn = __pfn(page_align(addr) - pool->start); + + if (ids_del_contiguous(pool->idpool, pfn, npages) < 0) { + printf("%s: Invalid address range returned to " + "virtual address pool.\n", __FUNCTION__); + return -1; + } + return 0; +} + diff --git a/conts/posix/mm0/src/lib/bit.c b/conts/posix/mm0/src/lib/bit.c new file mode 100644 index 0000000..84750e3 --- /dev/null +++ b/conts/posix/mm0/src/lib/bit.c @@ -0,0 +1,111 @@ +/* + * Bit manipulation functions. + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include INC_GLUE(memory.h) + +/* Emulation of ARM's CLZ (count leading zeroes) instruction */ +unsigned int __clz(unsigned int bitvector) +{ + unsigned int x = 0; + while((!(bitvector & ((unsigned)1 << 31))) && (x < 32)) { + bitvector <<= 1; + x++; + } + return x; +} + +int find_and_set_first_free_bit(u32 *word, unsigned int limit) +{ + int success = 0; + int i; + + for(i = 0; i < limit; i++) { + /* Find first unset bit */ + if (!(word[BITWISE_GETWORD(i)] & BITWISE_GETBIT(i))) { + /* Set it */ + word[BITWISE_GETWORD(i)] |= BITWISE_GETBIT(i); + success = 1; + break; + } + } + /* Return bit just set */ + if (success) + return i; + else + return -1; +} + +int find_and_set_first_free_contig_bits(u32 *word, unsigned int limit, + int nbits) +{ + int i = 0, first = 0, last = 0, found = 0; + + /* Can't allocate more than the limit */ + if (nbits > limit) + return -1; + + /* This is a state machine that checks n contiguous free bits. */ + /* FIXME: It should be <= instead of <. Fix & test in a single patch */ + while (i + nbits < limit) { + first = i; + last = i; + while (!(word[BITWISE_GETWORD(last)] & BITWISE_GETBIT(last))) { + last++; + i++; + if (last == first + nbits) { + found = 1; + break; + } + } + if (found) + break; + i++; + } + + /* If found, set the bits */ + if (found) { + for (int x = first; x < first + nbits; x++) + word[BITWISE_GETWORD(x)] |= BITWISE_GETBIT(x); + return first; + } else + return -1; +} + +int check_and_clear_bit(u32 *word, int bit) +{ + /* Check that bit was set */ + if (word[BITWISE_GETWORD(bit)] & BITWISE_GETBIT(bit)) { + word[BITWISE_GETWORD(bit)] &= ~BITWISE_GETBIT(bit); + return 0; + } else { + printf("Trying to clear already clear bit\n"); + return -1; + } +} + +int check_and_set_bit(u32 *word, int bit) +{ + /* Check that bit was clear */ + if (!(word[BITWISE_GETWORD(bit)] & BITWISE_GETBIT(bit))) { + word[BITWISE_GETWORD(bit)] |= BITWISE_GETBIT(bit); + return 0; + } else { + //printf("Trying to set already set bit\n"); + return -1; + } +} + +int check_and_clear_contig_bits(u32 *word, int first, int nbits) +{ + for (int i = first; i < first + nbits; i++) + if (check_and_clear_bit(word, i) < 0) + return -1; + return 0; +} + diff --git a/conts/posix/mm0/src/lib/elf/elf.c b/conts/posix/mm0/src/lib/elf/elf.c new file mode 100644 index 0000000..3f6a62f --- /dev/null +++ b/conts/posix/mm0/src/lib/elf/elf.c @@ -0,0 +1,177 @@ +/* + * ELF manipulation routines + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include + + +int elf_probe(struct elf_header *header) +{ + /* Test that it is a 32-bit little-endian ELF file */ + if (header->e_ident[EI_MAG0] == ELFMAG0 && + header->e_ident[EI_MAG1] == ELFMAG1 && + header->e_ident[EI_MAG2] == ELFMAG2 && + header->e_ident[EI_MAG3] == ELFMAG3 && + header->e_ident[EI_CLASS] == ELFCLASS32 && + header->e_ident[EI_DATA] == ELFDATA2LSB) + return 0; + else + return -1; +} + +/* + * Sets or expands a segment region if it has the given type and flags + * For expansion we assume any new section must come consecutively + * after the existing segment, otherwise we ignore it for simplicity. + */ +int elf_test_expand_segment(struct elf_section_header *section, + unsigned int sec_type, unsigned int sec_flags, + unsigned int sec_flmask, unsigned long *start, + unsigned long *end, unsigned long *offset) +{ + if (section->sh_type == sec_type && + (section->sh_flags & sec_flmask) == sec_flags) { + /* Set new section */ + if (!*start) { + BUG_ON(*offset || *end); + *offset = section->sh_offset; + *start = section->sh_addr; + *end = section->sh_addr + section->sh_size; + /* Expand existing section from the end */ + } else if (*end == section->sh_addr) + *end = section->sh_addr + section->sh_size; + } + + return 0; +} + +/* + * Sift through sections and copy their marks to tcb and efd + * if they are recognised and loadable sections. Test the + * assigned segment marks and return an error if they're invalid. + */ +int elf_mark_segments(struct elf_section_header *sect_header, int nsections, + struct tcb *task, struct exec_file_desc *efd) +{ + for (int i = 0; i < nsections; i++) { + struct elf_section_header *section = §_header[i]; + + /* Text + read-only data segments */ + elf_test_expand_segment(section, SHT_PROGBITS, + SHF_ALLOC, SHF_ALLOC | SHF_WRITE, + &task->text_start, &task->text_end, + &efd->text_offset); + + /* Data segment */ + elf_test_expand_segment(section, SHT_PROGBITS, SHF_ALLOC | + SHF_WRITE, SHF_ALLOC | SHF_WRITE, + &task->data_start, &task->data_end, + &efd->data_offset); + + /* Bss segment */ + elf_test_expand_segment(section, SHT_NOBITS, SHF_ALLOC | + SHF_WRITE, SHF_ALLOC | SHF_WRITE, + &task->bss_start, &task->bss_end, + &efd->bss_offset); + } + + /* Test anomalies with the mappings */ + + /* No text */ + if (!task->text_start) { + printf("%s: Error: Could not find a text " + "segment in ELF file.\n", __FUNCTION__); + return -ENOEXEC; + } + + /* Warn if no data or bss but it's not an error */ + if (!task->data_start || !task->bss_start) { + printf("%s: NOTE: Could not find a data and/or " + "bss segment in ELF file.\n", __FUNCTION__); + } + + /* Data and text are on the same page and not on a page boundary */ + if (!((is_page_aligned(task->data_start) && + task->data_start == task->text_end) || + (page_align(task->data_start) > page_align(task->text_end)))) + if ((task->data_start - task->text_end) < PAGE_SIZE && + !is_page_aligned(task->text_end)) { + printf("%s: Error: Distance between data and text" + " sections are less than page size (%d bytes)\n", + __FUNCTION__, PAGE_SIZE); + return -ENOEXEC; + } + + return 0; +} + +/* + * Loading an ELF file: + * + * This first probes and detects that the given file is a valid elf file. + * Then it looks at the program header table to find the first (probably + * only) segment that has type LOAD. Then it looks at the section header + * table, to find out about every loadable section that is part of this + * aforementioned loadable program segment. Each section is marked in the + * efd and tcb structures for further memory mappings. + */ +int elf_parse_executable(struct tcb *task, struct vm_file *file, + struct exec_file_desc *efd) +{ + struct elf_header elf_header, *elf_headerp = pager_map_page(file, 0); + struct elf_program_header *prg_header_start, *prg_header_load; + struct elf_section_header *sect_header; + unsigned long sect_offset, sect_size; + unsigned long prg_offset, prg_size; + int err = 0; + + /* Test that it is a valid elf file */ + if ((err = elf_probe(elf_headerp)) < 0) + return err; + + /* Copy the elf header and unmap first page */ + memcpy(&elf_header, elf_headerp, sizeof(elf_header)); + pager_unmap_page(elf_headerp); + + /* Find the markers for section and program header tables */ + sect_offset = elf_header.e_shoff; + sect_size = elf_header.e_shentsize * elf_header.e_shnum; + + prg_offset = elf_header.e_phoff; + prg_size = elf_header.e_phentsize * elf_header.e_phnum; + + /* Get the program header table */ + prg_header_start = (struct elf_program_header *) + pager_map_file_range(file, prg_offset, prg_size); + + /* Get the first loadable segment. We currently just stare at it */ + for (int i = 0; i < elf_header.e_phnum; i++) { + if (prg_header_start[i].p_type == PT_LOAD) { + prg_header_load = &prg_header_start[i]; + break; + } + } + + /* Get the section header table */ + sect_header = (struct elf_section_header *) + pager_map_file_range(file, sect_offset, sect_size); + + /* Copy segment marks from ELF file to task + efd. Return errors */ + err = elf_mark_segments(sect_header, elf_header.e_shnum, task, efd); + + /* Unmap program header table */ + pager_unmap_pages(prg_header_start, __pfn(page_align_up(prg_size))); + + /* Unmap section header table */ + pager_unmap_pages(sect_header, __pfn(page_align_up(sect_size))); + + return err; +} + diff --git a/conts/posix/mm0/src/lib/idpool.c b/conts/posix/mm0/src/lib/idpool.c new file mode 100644 index 0000000..9d1f3df --- /dev/null +++ b/conts/posix/mm0/src/lib/idpool.c @@ -0,0 +1,88 @@ +/* + * Used for thread and space ids. + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include INC_GLUE(memory.h) +#include +#include + +struct id_pool *id_pool_new_init(int totalbits) +{ + int nwords = BITWISE_GETWORD(totalbits) + 1; + struct id_pool *new = kzalloc((nwords * SZ_WORD) + + sizeof(struct id_pool)); + if (!new) + return PTR_ERR(-ENOMEM); + + new->nwords = nwords; + new->bitlimit = totalbits; + + return new; +} + +/* Search for a free slot up to the limit given */ +int id_new(struct id_pool *pool) +{ + return find_and_set_first_free_bit(pool->bitmap, pool->bitlimit); +} + +/* This finds n contiguous free ids, allocates and returns the first one */ +int ids_new_contiguous(struct id_pool *pool, int numids) +{ + int id = find_and_set_first_free_contig_bits(pool->bitmap, + pool->bitlimit, + numids); + if (id < 0) + printf("%s: Warning! New id alloc failed\n", __FUNCTION__); + return id; +} + +/* This deletes a list of contiguous ids given the first one and number of ids */ +int ids_del_contiguous(struct id_pool *pool, int first, int numids) +{ + int ret; + + if (pool->nwords * WORD_BITS < first + numids) + return -1; + if ((ret = check_and_clear_contig_bits(pool->bitmap, first, numids))) + printf("%s: Error: Invalid argument range.\n", __FUNCTION__); + return ret; +} + +int id_del(struct id_pool *pool, int id) +{ + int ret; + + if (pool->nwords * WORD_BITS < id) + return -1; + + if ((ret = check_and_clear_bit(pool->bitmap, id) < 0)) + printf("%s: Error: Could not delete id.\n", __FUNCTION__); + return ret; +} + +/* Return a specific id, if available */ +int id_get(struct id_pool *pool, int id) +{ + int ret; + + ret = check_and_set_bit(pool->bitmap, id); + + if (ret < 0) + return ret; + else + return id; +} + +int id_is_empty(struct id_pool *pool) +{ + for (int i = 0; i < pool->nwords; i++) + if (pool->bitmap[i]) + return 0; + return 1; +} + diff --git a/conts/posix/mm0/src/lib/malloc.c b/conts/posix/mm0/src/lib/malloc.c new file mode 100644 index 0000000..13b36ef --- /dev/null +++ b/conts/posix/mm0/src/lib/malloc.c @@ -0,0 +1,413 @@ +/***************************************************************************** +Simple malloc +Chris Giese http://www.execpc.com/~geezer +Release date: Oct 30, 2002 +This code is public domain (no copyright). +You can do whatever you want with it. + +Features: +- First-fit +- free() coalesces adjacent free blocks +- Uses variable-sized heap, enlarged with kbrk()/sbrk() function +- Does not use mmap() +- Can be easily modified to use fixed-size heap +- Works with 16- or 32-bit compilers + +Build this program with either of the two main() functions, then run it. +Messages that indicate a software error will contain three asterisks (***). +*****************************************************************************/ +#include /* memcpy(), memset() */ +#include /* printf() */ +#include +#define _32BIT 1 + +/* use small (32K) heap for 16-bit compilers, +large (500K) heap for 32-bit compilers */ +#if defined(_32BIT) +#define HEAP_SIZE 500000uL +#else +#define HEAP_SIZE 32768u +#endif + +#define MALLOC_MAGIC 0x6D92 /* must be < 0x8000 */ + +typedef struct _malloc /* Turbo C DJGPP */ +{ + size_t size; /* 2 bytes 4 bytes */ + struct _malloc *next; /* 2 bytes 4 bytes */ + unsigned magic : 15; /* 2 bytes total 4 bytes total */ + unsigned used : 1; +} malloc_t; /* total 6 bytes 12 bytes */ + +static char *g_heap_bot, *g_kbrk, *g_heap_top; +/***************************************************************************** +*****************************************************************************/ +void dump_heap(void) +{ + unsigned blks_used = 0, blks_free = 0; + size_t bytes_used = 0, bytes_free = 0; + malloc_t *m; + int total; + + printf("===============================================\n"); + for(m = (malloc_t *)g_heap_bot; m != NULL; m = m->next) + { + printf("blk %5p: %6u bytes %s\n", m, + m->size, m->used ? "used" : "free"); + if(m->used) + { + blks_used++; + bytes_used += m->size; + } + else + { + blks_free++; + bytes_free += m->size; + } + } + printf("blks: %6u used, %6u free, %6u total\n", blks_used, + blks_free, blks_used + blks_free); + printf("bytes: %6u used, %6u free, %6u total\n", bytes_used, + bytes_free, bytes_used + bytes_free); + printf("g_heap_bot=0x%p, g_kbrk=0x%p, g_heap_top=0x%p\n", + g_heap_bot, g_kbrk, g_heap_top); + total = (bytes_used + bytes_free) + + (blks_used + blks_free) * sizeof(malloc_t); + if(total != g_kbrk - g_heap_bot) + printf("*** some heap memory is not accounted for\n"); + printf("===============================================\n"); +} +/***************************************************************************** +POSIX sbrk() looks like this + void *sbrk(int incr); +Mine is a bit different so I can signal the calling function +if more memory than desired was allocated (e.g. in a system with paging) +If your kbrk()/sbrk() always allocates the amount of memory you ask for, +this code can be easily changed. + + int brk( void *sbrk( void *kbrk( +function void *adr); int delta); int *delta); +---------------------- ------------ ------------ ------------- +POSIX? yes yes NO +return value if error -1 -1 NULL +get break value . sbrk(0) int x=0; kbrk(&x); +set break value to X brk(X) sbrk(X - sbrk(0)) int x=X, y=0; kbrk(&x) - kbrk(&y); +enlarge heap by N bytes . sbrk(+N) int x=N; kbrk(&x); +shrink heap by N bytes . sbrk(-N) int x=-N; kbrk(&x); +can you tell if you're + given more memory + than you wanted? no no yes +*****************************************************************************/ +static void *kbrk(int *delta) +{ + static char heap[HEAP_SIZE]; +/**/ + char *new_brk, *old_brk; + +/* heap doesn't exist yet */ + if(g_heap_bot == NULL) + { + g_heap_bot = g_kbrk = heap; + g_heap_top = g_heap_bot + HEAP_SIZE; + } + new_brk = g_kbrk + (*delta); +/* too low: return NULL */ + if(new_brk < g_heap_bot) + return NULL; +/* too high: return NULL */ + if(new_brk >= g_heap_top) + return NULL; +/* success: adjust brk value... */ + old_brk = g_kbrk; + g_kbrk = new_brk; +/* ...return actual delta... (for this sbrk(), they are the same) + (*delta) = (*delta); */ +/* ...return old brk value */ + return old_brk; +} +/***************************************************************************** +kmalloc() and kfree() use g_heap_bot, but not g_kbrk nor g_heap_top +*****************************************************************************/ +void *kmalloc(size_t size) +{ + unsigned total_size; + malloc_t *m, *n; + int delta; + + if(size == 0) + return NULL; + total_size = size + sizeof(malloc_t); +/* search heap for free block (FIRST FIT) */ + m = (malloc_t *)g_heap_bot; +/* g_heap_bot == 0 == NULL if heap does not yet exist */ + if(m != NULL) + { + if(m->magic != MALLOC_MAGIC) +// panic("kernel heap is corrupt in kmalloc()"); + { + printf("*** kernel heap is corrupt in kmalloc()\n"); + return NULL; + } + for(; m->next != NULL; m = m->next) + { + if(m->used) + continue; +/* size == m->size is a perfect fit */ + if(size == m->size) + m->used = 1; + else + { +/* otherwise, we need an extra sizeof(malloc_t) bytes for the header +of a second, free block */ + if(total_size > m->size) + continue; +/* create a new, smaller free block after this one */ + n = (malloc_t *)((char *)m + total_size); + n->size = m->size - total_size; + n->next = m->next; + n->magic = MALLOC_MAGIC; + n->used = 0; +/* reduce the size of this block and mark it used */ + m->size = size; + m->next = n; + m->used = 1; + } + return (char *)m + sizeof(malloc_t); + } + } +/* use kbrk() to enlarge (or create!) heap */ + delta = total_size; + n = kbrk(&delta); +/* uh-oh */ + if(n == NULL) + return NULL; + if(m != NULL) + m->next = n; + n->size = size; + n->magic = MALLOC_MAGIC; + n->used = 1; +/* did kbrk() return the exact amount of memory we wanted? +cast to make "gcc -Wall -W ..." shut the hell up */ + if((int)total_size == delta) + n->next = NULL; + else + { +/* it returned more than we wanted (it will never return less): +create a new, free block */ + m = (malloc_t *)((char *)n + total_size); + m->size = delta - total_size - sizeof(malloc_t); + m->next = NULL; + m->magic = MALLOC_MAGIC; + m->used = 0; + + n->next = m; + } + return (char *)n + sizeof(malloc_t); +} + +/***************************************************************************** +*****************************************************************************/ +void kfree(void *blk) +{ + malloc_t *m, *n; + +/* get address of header */ + m = (malloc_t *)((char *)blk - sizeof(malloc_t)); + if(m->magic != MALLOC_MAGIC) +// panic("attempt to kfree() block at 0x%p " +// "with bad magic value", blk); + { + printf("*** attempt to kfree() block at 0x%p " + "with bad magic value\n", blk); + BUG(); + return; + } +/* find this block in the heap */ + n = (malloc_t *)g_heap_bot; + if(n->magic != MALLOC_MAGIC) +// panic("kernel heap is corrupt in kfree()"); + { + printf("*** kernel heap is corrupt in kfree()\n"); + return; + } + for(; n != NULL; n = n->next) + { + if(n == m) + break; + } +/* not found? bad pointer or no heap or something else? */ + if(n == NULL) +// panic("attempt to kfree() block at 0x%p " +// "that is not in the heap", blk); + { + printf("*** attempt to kfree() block at 0x%p " + "that is not in the heap\n", blk); + return; + } +/* free the block */ + m->used = 0; +/* BB: Addition: put 0xFF to block memory so we know if we use freed memory */ + memset(blk, 0xFF, m->size); + +/* coalesce adjacent free blocks +Hard to spell, hard to do */ + for(m = (malloc_t *)g_heap_bot; m != NULL; m = m->next) + { + while(!m->used && m->next != NULL && !m->next->used) + { +/* resize this block */ + m->size += sizeof(malloc_t) + m->next->size; +/* merge with next block */ + m->next = m->next->next; + } + } +} +/***************************************************************************** +*****************************************************************************/ +void *krealloc(void *blk, size_t size) +{ + void *new_blk; + malloc_t *m; + +/* size == 0: free block */ + if(size == 0) + { + if(blk != NULL) + kfree(blk); + new_blk = NULL; + } + else + { +/* allocate new block */ + new_blk = kmalloc(size); +/* if allocation OK, and if old block exists, copy old block to new */ + if(new_blk != NULL && blk != NULL) + { + m = (malloc_t *)((char *)blk - sizeof(malloc_t)); + if(m->magic != MALLOC_MAGIC) +// panic("attempt to krealloc() block at " +// "0x%p with bad magic value", blk); + { + printf("*** attempt to krealloc() block at " + "0x%p with bad magic value\n", blk); + return NULL; + } +/* copy minimum of old and new block sizes */ + if(size > m->size) + size = m->size; + memcpy(new_blk, blk, size); +/* free the old block */ + kfree(blk); + } + } + return new_blk; +} +/***************************************************************************** +*****************************************************************************/ + +#if 0 + +#include /* rand() */ + + +#define SLOTS 17 + +int main(void) +{ + unsigned lifetime[SLOTS]; + void *blk[SLOTS]; + int i, j, k; + + dump_heap(); + memset(lifetime, 0, sizeof(lifetime)); + memset(blk, 0, sizeof(blk)); + for(i = 0; i < 1000; i++) + { + printf("Pass %6u\n", i); + for(j = 0; j < SLOTS; j++) + { +/* age the block */ + if(lifetime[j] != 0) + { + (lifetime[j])--; + continue; + } +/* too old; free it */ + if(blk[j] != NULL) + { + kfree(blk[j]); + blk[j] = NULL; + } +/* alloc new block of random size +Note that size_t==unsigned, but kmalloc() uses integer math, +so block size must be positive integer */ +#if defined(_32BIT) + k = rand() % 40960 + 1; +#else + k = rand() % 4096 + 1; +#endif + blk[j] = kmalloc(k); + if(blk[j] == NULL) + printf("failed to alloc %u bytes\n", k); + else +/* give it a random lifetime 0-20 */ + lifetime[j] = rand() % 21; + } + } +/* let's see what we've wrought */ + printf("\n\n"); + dump_heap(); +/* free everything */ + for(j = 0; j < SLOTS; j++) + { + if(blk[j] != NULL) + { + kfree(blk[j]); + blk[j] = NULL; + } + (lifetime[j]) = 0; + } +/* after all that, we should have a single, unused block */ + dump_heap(); + return 0; +} +/***************************************************************************** +*****************************************************************************/ + +int main(void) +{ + void *b1, *b2, *b3; + + dump_heap(); + + b1 = kmalloc(42); + dump_heap(); + + b2 = kmalloc(23); + dump_heap(); + + b3 = kmalloc(7); + dump_heap(); + + b2 = krealloc(b2, 24); + dump_heap(); + + kfree(b1); + dump_heap(); + + b1 = kmalloc(5); + dump_heap(); + + kfree(b2); + dump_heap(); + + kfree(b3); + dump_heap(); + + kfree(b1); + dump_heap(); + + return 0; +} +#endif + diff --git a/conts/posix/mm0/src/memory.c b/conts/posix/mm0/src/memory.c new file mode 100644 index 0000000..bd1c0bf --- /dev/null +++ b/conts/posix/mm0/src/memory.c @@ -0,0 +1,203 @@ +/* + * Initialise the memory structures. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) +#include INC_SUBARCH(mm.h) +#include +#include +#include + + +struct address_pool pager_vaddr_pool; + +/* FIXME: + * ID pool id allocation size (i.e. bitlimit/nwords parameters) + * must be in sync with address pool allocation range. Here, since + * the id pool needs to be determined at compile time, the two + * parameters don't match yet. + */ + +/* Bitmap size to represent an address pool of 256 MB. */ +#define ADDRESS_POOL_256MB 2048 + +/* Same as a regular id pool except that its bitmap size is fixed */ +static struct pager_virtual_address_id_pool { + int nwords; + int bitlimit; + u32 bitmap[ADDRESS_POOL_256MB]; +} pager_virtual_address_id_pool = { + .nwords = ADDRESS_POOL_256MB, + .bitlimit = ADDRESS_POOL_256MB * 32, +}; + +/* End of pager image */ +extern unsigned char _end[]; + +/* For supplying contiguous virtual addresses to pager */ +int pager_address_pool_init(void) +{ + /* + * Initialise id pool for pager virtual address + * allocation. This spans from end of pager image + * until the end of the virtual address range + * allocated for the pager + */ + address_pool_init_with_idpool(&pager_vaddr_pool, + (struct id_pool *) + &pager_virtual_address_id_pool, + page_align_up((unsigned long)_end + PAGE_SIZE), + (unsigned long)0xF0000000); + return 0; +} + +void *l4_new_virtual(int npages) +{ + return pager_new_address(npages); +} + +void *l4_del_virtual(void *virt, int npages) +{ + pager_delete_address(virt, npages); + return 0; +} + +/* Maps a page from a vm_file to the pager's address space */ +void *pager_map_page(struct vm_file *f, unsigned long page_offset) +{ + int err; + struct page *p; + + if ((err = read_file_pages(f, page_offset, page_offset + 1)) < 0) + return PTR_ERR(err); + + if ((p = find_page(&f->vm_obj, page_offset))) + return (void *)l4_map_helper((void *)page_to_phys(p), 1); + else + return 0; +} + +/* Unmaps a page's virtual address from the pager's address space */ +void pager_unmap_page(void *addr) +{ + l4_unmap_helper(addr, 1); +} + +void *pager_new_address(int npages) +{ + return address_new(&pager_vaddr_pool, npages); +} + +int pager_delete_address(void *virt_addr, int npages) +{ + return address_del(&pager_vaddr_pool, virt_addr, npages); +} + +/* Maps a page from a vm_file to the pager's address space */ +void *pager_map_pages(struct vm_file *f, unsigned long page_offset, unsigned long npages) +{ + int err; + struct page *p; + void *addr_start, *addr; + + /* Get the pages */ + if ((err = read_file_pages(f, page_offset, page_offset + npages)) < 0) + return PTR_ERR(err); + + /* Get the address range */ + if (!(addr_start = pager_new_address(npages))) + return PTR_ERR(-ENOMEM); + addr = addr_start; + + /* Map pages contiguously one by one */ + for (unsigned long pfn = page_offset; pfn < page_offset + npages; pfn++) { + BUG_ON(!(p = find_page(&f->vm_obj, pfn))) + l4_map((void *)page_to_phys(p), addr, 1, MAP_USR_RW_FLAGS, self_tid()); + addr += PAGE_SIZE; + } + + return addr_start; +} + +/* Unmaps a page's virtual address from the pager's address space */ +void pager_unmap_pages(void *addr, unsigned long npages) +{ + /* Align to page if unaligned */ + if (!is_page_aligned(addr)) + addr = (void *)page_align(addr); + + /* Unmap so many pages */ + l4_unmap_helper(addr, npages); +} + +/* + * Maps multiple pages on a contiguous virtual address range, + * returns pointer to byte offset in the file. + */ +void *pager_map_file_range(struct vm_file *f, unsigned long byte_offset, + unsigned long size) +{ + unsigned long mapsize = (byte_offset & PAGE_MASK) + size; + + void *page = pager_map_pages(f, __pfn(byte_offset), __pfn(page_align_up(mapsize))); + + return (void *)((unsigned long)page | (PAGE_MASK & byte_offset)); +} + +void *pager_validate_map_user_range2(struct tcb *user, void *userptr, + unsigned long size, unsigned int vm_flags) +{ + unsigned long start = page_align(userptr); + unsigned long end = page_align_up(userptr + size); + unsigned long npages = __pfn(end - start); + void *virt, *virt_start; + void *mapped = 0; + + /* Validate that user task owns this address range */ + if (pager_validate_user_range(user, userptr, size, vm_flags) < 0) + return 0; + + /* Get the address range */ + if (!(virt_start = pager_new_address(npages))) + return PTR_ERR(-ENOMEM); + virt = virt_start; + + /* Map every page contiguously in the allocated virtual address range */ + for (unsigned long addr = start; addr < end; addr += PAGE_SIZE) { + struct page *p = task_virt_to_page(user, addr); + + if (IS_ERR(p)) { + /* Unmap pages mapped so far */ + l4_unmap_helper(virt_start, __pfn(addr - start)); + + /* Delete virtual address range */ + pager_delete_address(virt_start, npages); + + return p; + } + + l4_map((void *)page_to_phys(task_virt_to_page(user, addr)), + virt, 1, MAP_USR_RW_FLAGS, self_tid()); + virt += PAGE_SIZE; + } + + /* Set the mapped pointer to offset of user pointer given */ + mapped = virt_start; + mapped = (void *)(((unsigned long)mapped) | + ((unsigned long)(PAGE_MASK & + (unsigned long)userptr))); + + /* Return the mapped pointer */ + return mapped; +} + + diff --git a/conts/posix/mm0/src/mmap.c b/conts/posix/mm0/src/mmap.c new file mode 100644 index 0000000..857385c --- /dev/null +++ b/conts/posix/mm0/src/mmap.c @@ -0,0 +1,424 @@ +/* + * mmap/munmap and friends. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ +#include +#include +#include +#include INC_API(errno.h) +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct vm_area *vma_new(unsigned long pfn_start, unsigned long npages, + unsigned int flags, unsigned long file_offset) +{ + struct vm_area *vma; + + /* Allocate new area */ + if (!(vma = kzalloc(sizeof(struct vm_area)))) + return 0; + + link_init(&vma->list); + link_init(&vma->vm_obj_list); + + vma->pfn_start = pfn_start; + vma->pfn_end = pfn_start + npages; + vma->flags = flags; + vma->file_offset = file_offset; + + return vma; +} + +/* + * Inserts a new vma to the ordered vm area list. + * + * The new vma is assumed to have been correctly set up not to intersect + * with any other existing vma. + */ +int task_insert_vma(struct vm_area *this, struct link *vma_list) +{ + struct vm_area *before, *after; + + /* Add if list is empty */ + if (list_empty(vma_list)) { + list_insert_tail(&this->list, vma_list); + return 0; + } + + /* Else find the right interval */ + list_foreach_struct(before, vma_list, list) { + after = link_to_struct(before->list.next, struct vm_area, list); + + /* If there's only one in list */ + if (before->list.next == vma_list) { + + /* Eliminate the possibility of intersection */ + BUG_ON(set_intersection(this->pfn_start, this->pfn_end, + before->pfn_start, + before->pfn_end)); + + /* Add as next if greater */ + if (this->pfn_start > before->pfn_start) + list_insert(&this->list, &before->list); + /* Add as previous if smaller */ + else if (this->pfn_start < before->pfn_start) + list_insert_tail(&this->list, &before->list); + else + BUG(); + + return 0; + } + + /* If this page is in-between two other, insert it there */ + if (before->pfn_start < this->pfn_start && + after->pfn_start > this->pfn_start) { + + /* Eliminate possibility of intersection */ + BUG_ON(set_intersection(this->pfn_start, this->pfn_end, + before->pfn_start, + before->pfn_end)); + BUG_ON(set_intersection(this->pfn_start, this->pfn_end, + after->pfn_start, + after->pfn_end)); + list_insert(&this->list, &before->list); + + return 0; + } + } + BUG(); +} + +/* + * Search an empty space in the task's mmapable address region. + * + * This does a less than O(n) algorithm by starting the estimated region + * and vma comparison from the beginning, once a vma is not intersected + * that means it is an available slot. However if vma's and estimated + * region does not go head-to-head for comparison, individual intersection + * checks would be meaningless since any other vma could be intersecting. + * Therefore head-to-head comparison is essential here. + */ +unsigned long find_unmapped_area(unsigned long npages, struct tcb *task) +{ + unsigned long pfn_start = __pfn(task->start); + unsigned long pfn_end = pfn_start + npages; + struct vm_area *vma; + + if (npages > __pfn(task->end - task->start)) + return 0; + + /* If no vmas, first map slot is available. */ + if (list_empty(&task->vm_area_head->list)) + return task->start; + + /* First vma to check our range against */ + vma = link_to_struct(task->vm_area_head->list.next, struct vm_area, list); + + /* Start searching from task's end of data to start of stack */ + while (pfn_end <= __pfn(task->end)) { + + /* If intersection, skip the vma and fast-forward to next */ + if (set_intersection(pfn_start, pfn_end, + vma->pfn_start, vma->pfn_end)) { + + /* Update interval to next available space */ + pfn_start = vma->pfn_end; + pfn_end = pfn_start + npages; + + /* + * Decision point, no more vmas left to check. + * Are we out of task map area? + */ + if (vma->list.next == &task->vm_area_head->list) { + if (pfn_end > __pfn(task->end)) + break; /* Yes, fail */ + else /* No, success */ + return __pfn_to_addr(pfn_start); + } + + /* Otherwise get next vma entry */ + vma = link_to_struct(vma->list.next, + struct vm_area, list); + continue; + } + BUG_ON(pfn_start + npages > __pfn(task->end)); + return __pfn_to_addr(pfn_start); + } + + return 0; +} + +/* Validate an address that is a possible candidate for an mmap() region */ +int mmap_address_validate(struct tcb *task, unsigned long map_address, + unsigned int vm_flags) +{ + if (map_address == 0) + return 0; + + /* Private mappings can only go in task address space */ + if (vm_flags & VMA_PRIVATE) { + if ((map_address >= task->start && + map_address < task->end) || + (map_address >= UTCB_AREA_START && + map_address < UTCB_AREA_END)) { + return 1; + } else + return 0; + /* + * Shared mappings can go in task, utcb, and shared + * memory address space, + */ + } else if (vm_flags & VMA_SHARED) { + if ((map_address >= task->start && + map_address < task->end) || + (map_address >= SHM_AREA_START && + map_address < SHM_AREA_END)) + return 1; + else + return 0; + } else + BUG(); +} + +/* + * Returns a suitably mmap'able address. It allocates + * differently for shared and private areas. + */ +unsigned long mmap_new_address(struct tcb *task, unsigned int flags, + unsigned int npages) +{ + if (flags & VMA_SHARED) + return (unsigned long)shm_new_address(npages); + else + return find_unmapped_area(npages, task); +} + +/* + * Side note: + * Why in do_mmap() shm files have devzero mapped behind separately but + * anonymous files map devzero directly? Because private anonymous files get + * shadow objects in front when written to. Shm files are not private, so they + * stay where they are and just grow. Other processes can reach and map them. + */ + +/* + * Maps the given file with given flags at the given page offset to the given + * task's address space at the specified virtual memory address and length. + * + * The actual paging in/out of the file from/into memory pages is handled by + * the file's pager upon page faults. + */ +void *do_mmap(struct vm_file *mapfile, unsigned long file_offset, + struct tcb *task, unsigned long map_address, + unsigned int flags, unsigned int npages) +{ + struct vm_obj_link *vmo_link, *vmo_link2; + unsigned long file_npages; + struct vm_area *new; + int err; + + /* Set up devzero if none given */ + if (!mapfile) { + if (flags & VMA_ANONYMOUS) { + BUG_ON(!(mapfile = get_devzero())); + file_offset = 0; + } else + return PTR_ERR(-EINVAL); + } + + /* Get total file pages, check if mapping is within file size */ + file_npages = __pfn(page_align_up(mapfile->length)); + if (npages > file_npages - file_offset) { + printf("%s: Trying to map %d pages from page %lu, " + "but file length is %lu\n", __FUNCTION__, + npages, file_offset, file_npages); + return PTR_ERR(-EINVAL); + } + + /* Check invalid page size */ + if (npages == 0) { + printf("Trying to map %d pages.\n", npages); + return PTR_ERR(-EINVAL); + } + if (npages > __pfn(TASK_SIZE)) { + printf("Trying to map too many pages: %d\n", npages); + return PTR_ERR(-ENOMEM); + } + + /* Check invalid map address */ + if (!mmap_address_validate(task, map_address, flags)) { + if (flags & VMA_FIXED) + return PTR_ERR(-EINVAL); + else if (!(map_address = mmap_new_address(task, flags, npages))) + return PTR_ERR(-ENOMEM); + } + + /* Unmap any existing vmas that overlap with the new mapping */ + if ((err = do_munmap(task, map_address, npages)) < 0) + return PTR_ERR(err); + + /* For valid regions that aren't allocated by us, create the vma. */ + if (!(new = vma_new(__pfn(map_address), npages, flags, + __pfn(file_offset)))) + return PTR_ERR(-ENOMEM); + + /* Attach the file as the first vm object of this vma */ + if (!(vmo_link = vm_objlink_create())) { + kfree(new); + return PTR_ERR(-ENOMEM); + } + + /* Attach link to object */ + vm_link_object(vmo_link, &mapfile->vm_obj); + + /* Add link to vma list */ + list_insert_tail(&vmo_link->list, &new->vm_obj_list); + + /* + * If the file is a shm file, also map devzero behind it. i.e. + * vma -> vm_link -> vm_link + * | | + * v v + * shm_file devzero + * + * So that faults go through shm file and then devzero, as in + * the shadow object copy_on_write setup in fault.c + */ + if (mapfile->type == VM_FILE_SHM) { + struct vm_file *dzero = get_devzero(); + + /* Attach the file as the first vm object of this vma */ + if (!(vmo_link2 = vm_objlink_create())) { + kfree(new); + kfree(vmo_link); + return PTR_ERR(-ENOMEM); + } + vm_link_object(vmo_link2, &dzero->vm_obj); + list_insert_tail(&vmo_link2->list, &new->vm_obj_list); + } + + /* Finished initialising the vma, add it to task */ + dprintf("%s: Mapping 0x%x - 0x%x\n", __FUNCTION__, + map_address, map_address + __pfn_to_addr(npages)); + task_insert_vma(new, &task->vm_area_head->list); + + /* + * If area is going to be used going downwards, (i.e. as a stack) + * we return the *end* of the area as the start address. + */ + if (flags & VMA_GROWSDOWN) + map_address += __pfn_to_addr(npages); + + return (void *)map_address; +} + +/* mmap system call implementation */ +void *__sys_mmap(struct tcb *task, void *start, size_t length, int prot, + int flags, int fd, unsigned long file_offset) +{ + unsigned int vmflags = 0; + struct vm_file *file = 0; + int err; + + /* Check file validity */ + if (!(flags & MAP_ANONYMOUS)) + if (!task->files->fd[fd].vmfile) + if ((err = file_open(task, fd)) < 0) + return PTR_ERR(err); + + /* Check file offset is page aligned */ + if (!is_page_aligned(file_offset)) + return PTR_ERR(-EINVAL); + + /* TODO: + * Check that @start does not already have a mapping. + * Check that pfn + npages range is within the file range. + * Check that posix flags passed match those defined in vm_area.h + */ + if (flags & MAP_ANONYMOUS) { + file = 0; + vmflags |= VMA_ANONYMOUS; + } else { + file = task->files->fd[fd].vmfile; + } + + if (flags & MAP_FIXED) + vmflags |= VMA_FIXED; + + if (flags & MAP_PRIVATE) + /* This means COW, if writeable. */ + vmflags |= VMA_PRIVATE; + else /* This also means COW, if writeable and anonymous */ + vmflags |= VMA_SHARED; + + if (flags & MAP_GROWSDOWN) + vmflags |= VMA_GROWSDOWN; + + if (prot & PROT_READ) + vmflags |= VM_READ; + if (prot & PROT_WRITE) + vmflags |= VM_WRITE; + if (prot & PROT_EXEC) + vmflags |= VM_EXEC; + + /* + * Currently MAP_SHARED && MAP_ANONYMOUS mappings use the + * shm interface to create virtual shared memory files and + * do_mmap is internally called through this interface. + * + * FIXME: A common method of creating virtual shm files + * should be used by both sys_mmap and sys_shmget. With the + * current method, a task that guesses the shmid of an + * anonymous shared mmap can attach to it via shmat. + */ + if ((flags & MAP_ANONYMOUS) && + (flags & MAP_SHARED)) { + /* Create a new shared memory virtual file */ + l4id_t shmid = sys_shmget(IPC_PRIVATE, + page_align_up(length), + 0); + + /* Find and mmap the file via do_shmat() */ + return sys_shmat(task, shmid, 0, 0); + } + + return do_mmap(file, file_offset, task, (unsigned long)start, + vmflags, __pfn(page_align_up(length))); +} + +void *sys_mmap(struct tcb *task, struct sys_mmap_args *args) +{ + + struct sys_mmap_args *mapped_args; + void *ret; + + if (!(mapped_args = pager_validate_map_user_range(task, args, + sizeof(*args), + VM_READ | VM_WRITE))) + return PTR_ERR(-EINVAL); + + ret = __sys_mmap(task, mapped_args->start, mapped_args->length, + mapped_args->prot, mapped_args->flags, mapped_args->fd, + mapped_args->offset); + + pager_unmap_user_range(mapped_args, sizeof(*args)); + + return ret; +} + +/* Sets the end of data segment for sender */ +int sys_brk(struct tcb *sender, void *ds_end) +{ + return 0; +} + diff --git a/conts/posix/mm0/src/munmap.c b/conts/posix/mm0/src/munmap.c new file mode 100644 index 0000000..fef7c6c --- /dev/null +++ b/conts/posix/mm0/src/munmap.c @@ -0,0 +1,261 @@ +/* + * munmap() for unmapping a portion of an address space. + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include + +/* This splits a vma, splitter region must be in the *middle* of original vma */ +int vma_split(struct vm_area *vma, struct tcb *task, + const unsigned long pfn_start, const unsigned long pfn_end) +{ + struct vm_area *new; + unsigned long unmap_start = pfn_start, unmap_end = pfn_end; + + /* Allocate an uninitialised vma first */ + if (!(new = vma_new(0, 0, 0, 0))) + return -ENOMEM; + + /* + * Some sanity checks to show that splitter range does end up + * producing two smaller vmas. + */ + BUG_ON(vma->pfn_start >= pfn_start || vma->pfn_end <= pfn_end); + + /* Update new and original vmas */ + new->pfn_end = vma->pfn_end; + new->pfn_start = pfn_end; + new->file_offset = vma->file_offset + new->pfn_start - vma->pfn_start; + vma->pfn_end = pfn_start; + new->flags = vma->flags; + + /* + * Copy the object links of original vma to new vma. A split like this + * increases the map count of mapped object(s) since now 2 vmas on the + * same task maps the same object(s). + */ + vma_copy_links(new, vma); + + /* Add new one next to original vma */ + list_insert_tail(&new->list, &vma->list); + + /* Unmap the removed portion */ + BUG_ON(l4_unmap((void *)__pfn_to_addr(unmap_start), + unmap_end - unmap_start, task->tid) < 0); + + return 0; +} + +/* This shrinks the vma from *one* end only, either start or end */ +int vma_shrink(struct vm_area *vma, struct tcb *task, + const unsigned long pfn_start, const unsigned long pfn_end) +{ + unsigned long diff, unmap_start, unmap_end; + int err; + + /* Shrink from the end */ + if (vma->pfn_start < pfn_start) { + BUG_ON(pfn_start >= vma->pfn_end); + unmap_start = pfn_start; + unmap_end = vma->pfn_end; + vma->pfn_end = pfn_start; + + /* Shrink from the beginning */ + } else if (vma->pfn_end > pfn_end) { + BUG_ON(pfn_end <= vma->pfn_start); + unmap_start = vma->pfn_start; + unmap_end = pfn_end; + diff = pfn_end - vma->pfn_start; + vma->file_offset += diff; + vma->pfn_start = pfn_end; + } else + BUG(); + + /* Unmap the shrinked portion */ + BUG_ON((err = l4_unmap((void *)__pfn_to_addr(unmap_start), + unmap_end - unmap_start, task->tid)) < 0); + + return 0; +} + +/* Destroys a single vma from a task and unmaps its range from task space */ +int vma_destroy_single(struct tcb *task, struct vm_area *vma) +{ + int ret; + + /* Release all object links */ + if ((ret = vma_drop_merge_delete_all(vma)) < 0) + return ret; + + /* + * Unmap the whole vma address range. Note that this + * may return -1 if the area was already faulted, which + * means the area was unmapped before being touched. + */ + l4_unmap((void *)__pfn_to_addr(vma->pfn_start), + vma->pfn_end - vma->pfn_start, task->tid); + + /* Unlink and delete vma */ + list_remove(&vma->list); + kfree(vma); + + return 0; +} + +/* + * Unmaps the given region from a vma. Depending on the region and vma range, + * this may result in either shrinking, splitting or destruction of the vma. + */ +int vma_unmap(struct vm_area *vma, struct tcb *task, + const unsigned long pfn_start, const unsigned long pfn_end) +{ + // printf("Unmapping vma. Tid: %d, 0x%x-0x%x\n",task->tid, __pfn_to_addr(pfn_start), __pfn_to_addr(pfn_end)); + + /* Split needed? */ + if (vma->pfn_start < pfn_start && vma->pfn_end > pfn_end) + return vma_split(vma, task, pfn_start, pfn_end); + /* Shrink needed? */ + else if (((vma->pfn_start >= pfn_start) && (vma->pfn_end > pfn_end)) + || ((vma->pfn_start < pfn_start) && (vma->pfn_end <= pfn_end))) + return vma_shrink(vma, task, pfn_start, pfn_end); + /* Destroy needed? */ + else if ((vma->pfn_start >= pfn_start) && (vma->pfn_end <= pfn_end)) + return vma_destroy_single(task, vma); + else + BUG(); + + return 0; +} + +/* Checks vma and vm_object type and flushes its pages accordingly */ +int vma_flush_pages(struct vm_area *vma) +{ + struct vm_object *vmo; + struct vm_obj_link *vmo_link; + int err; + + /* Read-only vmas need not flush objects */ + if (!(vma->flags & VM_WRITE)) + return 0; + + /* + * We just check the first object under the vma, since there + * could only be a single VM_SHARED file-backed object in the chain. + */ + BUG_ON(list_empty(&vma->list)); + vmo_link = link_to_struct(vma->vm_obj_list.next, struct vm_obj_link, list); + vmo = vmo_link->obj; + + /* Only dirty objects would need flushing */ + if (!(vmo->flags & VM_DIRTY)) + return 0; + + /* Only vfs file objects are flushed */ + if (vmo->flags & VM_OBJ_FILE && + vmo->flags & VMA_SHARED && + !(vmo->flags & VMA_ANONYMOUS)) { + + /* Only vfs files ought to match above criteria */ + BUG_ON(vm_object_to_file(vmo)->type != VM_FILE_VFS); + + /* Flush the pages */ + if ((err = flush_file_pages(vm_object_to_file(vmo))) < 0) + return err; + } + + return 0; +} + +/* + * Unmaps the given virtual address range from the task, the region + * may span into zero or more vmas, and may involve shrinking, splitting + * and destruction of multiple vmas. + * + * NOTE: Shared object addresses are returned back to their pools when + * such objects are deleted, and not via this function. + */ +int do_munmap(struct tcb *task, unsigned long vaddr, unsigned long npages) +{ + const unsigned long munmap_start = __pfn(vaddr); + const unsigned long munmap_end = munmap_start + npages; + struct vm_area *vma, *n; + int err; + + list_foreach_removable_struct(vma, n, &task->vm_area_head->list, list) { + /* Check for intersection */ + if (set_intersection(munmap_start, munmap_end, + vma->pfn_start, vma->pfn_end)) { + /* + * Flush pages if vma is writable, + * dirty and file-backed. + */ + if ((err = vma_flush_pages(vma)) < 0) + return err; + + /* Unmap the vma accordingly. This may delete the vma */ + if ((err = vma_unmap(vma, task, munmap_start, + munmap_end)) < 0) + return err; + } + } + + return 0; +} + +int sys_munmap(struct tcb *task, void *start, unsigned long length) +{ + /* Must be aligned on a page boundary */ + if (!is_page_aligned(start)) + return -EINVAL; + + return do_munmap(task, (unsigned long)start, + __pfn(page_align_up(length))); +} + + +/* Syncs mapped area. Currently just synchronously */ +int do_msync(struct tcb *task, void *vaddr, unsigned long npages, int flags) +{ + const unsigned long msync_start = __pfn(vaddr); + const unsigned long msync_end = msync_start + npages; + struct vm_area *vma; + unsigned long addr = (unsigned long)vaddr; + int err; + + /* Find a vma that overlaps with this address range */ + while ((vma = find_vma(addr, &task->vm_area_head->list))) { + + /* Flush pages if vma is writable, dirty and file-backed. */ + if ((err = vma_flush_pages(vma)) < 0) + return err; + + /* Update address to next vma */ + addr = __pfn_to_addr(vma->pfn_end); + + /* Are we still good to go? */ + if (addr >= msync_end) + break; + } + + return 0; +} + +int sys_msync(struct tcb *task, void *start, unsigned long length, int flags) +{ + /* Must be aligned on a page boundary */ + if (!is_page_aligned(start)) + return -EINVAL; + + /* + * TODO: We need to pass sync'ed and non-sync'ed file flushes to vfs + * and support synced and non-synced io. + */ + return do_msync(task, start, __pfn(page_align_up(length)), flags); +} + diff --git a/conts/posix/mm0/src/pagers.c b/conts/posix/mm0/src/pagers.c new file mode 100644 index 0000000..fd46d59 --- /dev/null +++ b/conts/posix/mm0/src/pagers.c @@ -0,0 +1,391 @@ +/* + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct page *page_init(struct page *page) +{ + /* Reset page */ + memset(page, 0, sizeof(*page)); + page->refcnt = -1; + spin_lock_init(&page->lock); + link_init(&page->list); + + return page; + +} +struct page *find_page(struct vm_object *obj, unsigned long pfn) +{ + struct page *p; + + list_foreach_struct(p, &obj->page_cache, list) + if (p->offset == pfn) + return p; + + return 0; +} + +/* + * Deletes all pages in a page cache, assumes pages are from the + * page allocator, and page structs are from the page_array, which + * is the default situation. + */ +int default_release_pages(struct vm_object *vm_obj) +{ + struct page *p, *n; + + list_foreach_removable_struct(p, n, &vm_obj->page_cache, list) { + list_remove_init(&p->list); + BUG_ON(p->refcnt); + + /* Reinitialise the page */ + page_init(p); + + /* Return page back to allocator */ + free_page((void *)page_to_phys(p)); + + /* Reduce object page count */ + BUG_ON(--vm_obj->npages < 0); + } + return 0; +} + + +int file_page_out(struct vm_object *vm_obj, unsigned long page_offset) +{ + struct vm_file *f = vm_object_to_file(vm_obj); + struct page *page; + void *vaddr, *paddr; + int err; + + /* Check first if the file has such a page at all */ + if (__pfn(page_align_up(f->length) <= page_offset)) { + printf("%s: %s: Trying to look up page %lu, but file length " + "is %lu bytes.\n", __TASKNAME__, __FUNCTION__, + page_offset, f->length); + BUG(); + } + + /* If the page is not in the page cache, simply return. */ + if (!(page = find_page(vm_obj, page_offset))) + return 0; + + /* If the page is not dirty, simply return */ + if (!(page->flags & VM_DIRTY)) + return 0; + + paddr = (void *)page_to_phys(page); + vaddr = l4_new_virtual(1); + + /* Map the page to vfs task */ + l4_map(paddr, vaddr, 1, MAP_USR_RW_FLAGS, VFS_TID); + + // printf("%s/%s: Writing to vnode %d, at pgoff 0x%x, %d pages, buf at 0x%x\n", + // __TASKNAME__, __FUNCTION__, vm_file_to_vnum(f), page_offset, 1, vaddr); + + /* Syscall to vfs to write page back to file. */ + if ((err = vfs_write(vm_file_to_vnum(f), page_offset, 1, vaddr)) < 0) + goto out_err; + + /* Unmap it from vfs */ + l4_unmap(vaddr, 1, VFS_TID); + l4_del_virtual(vaddr, 1); + + /* Clear dirty flag */ + page->flags &= ~VM_DIRTY; + + return 0; + +out_err: + l4_unmap(vaddr, 1, VFS_TID); + l4_del_virtual(vaddr, 1); + + return err; +} + +struct page *file_page_in(struct vm_object *vm_obj, unsigned long page_offset) +{ + struct vm_file *f = vm_object_to_file(vm_obj); + struct page *page; + void *vaddr, *paddr; + int err; + + /* Check first if the file has such a page at all */ + if (__pfn(page_align_up(f->length) <= page_offset)) { + printf("%s: %s: Trying to look up page %lu, but file length " + "is %lu bytes.\n", __TASKNAME__, __FUNCTION__, + page_offset, f->length); + BUG(); + } + + /* Call vfs only if the page is not resident in page cache. */ + if (!(page = find_page(vm_obj, page_offset))) { + /* Allocate a new page */ + paddr = alloc_page(1); + vaddr = l4_new_virtual(1); + page = phys_to_page(paddr); + + /* Map the page to vfs task */ + l4_map(paddr, vaddr, 1, MAP_USR_RW_FLAGS, VFS_TID); + + /* Syscall to vfs to read into the page. */ + if ((err = vfs_read(vm_file_to_vnum(f), page_offset, + 1, vaddr)) < 0) + goto out_err; + + /* Unmap it from vfs */ + l4_unmap(vaddr, 1, VFS_TID); + l4_del_virtual(vaddr, 1); + + /* Update vm object details */ + vm_obj->npages++; + + /* Update page details */ + page_init(page); + page->refcnt++; + page->owner = vm_obj; + page->offset = page_offset; + page->virtual = 0; + + /* Add the page to owner's list of in-memory pages */ + BUG_ON(!list_empty(&page->list)); + insert_page_olist(page, vm_obj); + } + + return page; + +out_err: + l4_unmap(vaddr, 1, VFS_TID); + l4_del_virtual(vaddr, 1); + free_page(paddr); + return PTR_ERR(err); +} + +/* + * All non-mmapable char devices are handled by this. + * VFS calls those devices to read their pages + */ +struct vm_pager file_pager = { + .ops = { + .page_in = file_page_in, + .page_out = file_page_out, + .release_pages = default_release_pages, + }, +}; + + +/* A proposal for shadow vma container, could be part of vm_file->priv_data */ +struct vm_swap_node { + struct vm_file *swap_file; + struct task_ids task_ids; + struct address_pool *pool; +}; + +/* + * This should save swap_node/page information either in the pte or in a global + * list of swap descriptors, and then write the page into the possibly one and + * only swap file. + */ +struct page *swap_page_in(struct vm_object *vm_obj, unsigned long file_offset) +{ + struct page *p; + + /* No swapping yet, so the page is either here or not here. */ + if (!(p = find_page(vm_obj, file_offset))) + return PTR_ERR(-EINVAL); + else + return p; +} + +struct vm_pager swap_pager = { + .ops = { + .page_in = swap_page_in, + .release_pages = default_release_pages, + }, +}; + +/* + * Just releases the page structures since the actual pages are + * already in memory as read-only. + */ +int bootfile_release_pages(struct vm_object *vm_obj) +{ + struct page *p, *n; + + list_foreach_removable_struct(p, n, &vm_obj->page_cache, list) { + list_remove(&p->list); + BUG_ON(p->refcnt); + + /* Reinitialise the page */ + page_init(p); + + /* + * We don't free the page because it doesn't + * come from the page allocator + */ + // free_page((void *)page_to_phys(p)); + + + /* Reduce object page count */ + BUG_ON(--vm_obj->npages < 0); + } + return 0; +} + +/* Returns the page with given offset in this vm_object */ +struct page *bootfile_page_in(struct vm_object *vm_obj, + unsigned long offset) +{ + struct vm_file *boot_file = vm_object_to_file(vm_obj); + struct svc_image *img = boot_file->priv_data; + struct page *page; + + /* Check first if the file has such a page at all */ + if (__pfn(page_align_up(boot_file->length) <= offset)) { + printf("%s: %s: Trying to look up page %lu, but file length " + "is %lu bytes.\n", __TASKNAME__, __FUNCTION__, + offset, boot_file->length); + BUG(); + } + + /* The page is not resident in page cache. */ + if (!(page = find_page(vm_obj, offset))) { + page = phys_to_page(img->phys_start + __pfn_to_addr(offset)); + + /* Update page */ + page_init(page); + page->refcnt++; + page->owner = vm_obj; + page->offset = offset; + + /* Update object */ + vm_obj->npages++; + + /* Add the page to owner's list of in-memory pages */ + BUG_ON(!list_empty(&page->list)); + insert_page_olist(page, vm_obj); + } + + return page; +} + +struct vm_pager bootfile_pager = { + .ops = { + .page_in = bootfile_page_in, + .release_pages = bootfile_release_pages, + }, +}; + +void bootfile_destroy_priv_data(struct vm_file *bootfile) +{ + +} + +/* From bare boot images, create mappable device files */ +int init_boot_files(struct initdata *initdata) +{ + struct bootdesc *bd = initdata->bootdesc; + struct vm_file *boot_file; + struct svc_image *img; + + link_init(&initdata->boot_file_list); + + for (int i = 0; i < bd->total_images; i++) { + img = &bd->images[i]; + boot_file = vm_file_create(); + + /* Allocate private data */ + boot_file->priv_data = kzalloc(sizeof(*img)); + memcpy(boot_file->priv_data, img, sizeof(*img)); + + boot_file->length = img->phys_end - img->phys_start; + boot_file->type = VM_FILE_BOOTFILE; + boot_file->destroy_priv_data = + bootfile_destroy_priv_data; + + /* Initialise the vm object */ + boot_file->vm_obj.flags = VM_OBJ_FILE; + boot_file->vm_obj.pager = &bootfile_pager; + + /* Add the file to initdata's bootfile list */ + list_insert_tail(&boot_file->list, &initdata->boot_file_list); + } + + return 0; +} + +/* Returns the page with given offset in this vm_object */ +struct page *devzero_page_in(struct vm_object *vm_obj, + unsigned long page_offset) +{ + struct vm_file *devzero = vm_object_to_file(vm_obj); + struct page *zpage = devzero->priv_data; + + BUG_ON(!(devzero->type & VM_FILE_DEVZERO)); + + /* Update zero page struct. */ + spin_lock(&zpage->lock); + BUG_ON(zpage->refcnt < 0); + zpage->refcnt++; + spin_unlock(&zpage->lock); + + return zpage; +} + +struct vm_pager devzero_pager = { + .ops = { + .page_in = devzero_page_in, + }, +}; + +struct vm_file *get_devzero(void) +{ + struct vm_file *f; + + list_foreach_struct(f, &global_vm_files.list, list) + if (f->type == VM_FILE_DEVZERO) + return f; + return 0; +} + +int init_devzero(void) +{ + void *zphys, *zvirt; + struct page *zpage; + struct vm_file *devzero; + + /* Allocate and initialise the zero page */ + zphys = alloc_page(1); + zpage = phys_to_page(zphys); + zvirt = l4_map_helper(zphys, 1); + memset(zvirt, 0, PAGE_SIZE); + l4_unmap_helper(zvirt, 1); + + /* Allocate and initialise devzero file */ + devzero = vm_file_create(); + devzero->type = VM_FILE_DEVZERO; + devzero->priv_data = zpage; + devzero->length = page_align(~0UL); /* So we dont wraparound to 0! */ + devzero->vm_obj.npages = __pfn(devzero->length); + devzero->vm_obj.pager = &devzero_pager; + devzero->vm_obj.flags = VM_OBJ_FILE; + + /* Initialise zpage */ + zpage->refcnt++; + zpage->owner = &devzero->vm_obj; + + global_add_vm_file(devzero); + return 0; +} + diff --git a/conts/posix/mm0/src/physmem.c b/conts/posix/mm0/src/physmem.c new file mode 100644 index 0000000..88714de --- /dev/null +++ b/conts/posix/mm0/src/physmem.c @@ -0,0 +1,175 @@ +/* + * Global physical memory descriptions. + * + * Copyright (C) 2007 - 2009 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) + +#include +#include +#include +#include +#include + +struct memdesc physmem; /* Initial, primitive memory descriptor */ +struct membank membank[1]; /* The memory bank */ +struct page *page_array; /* The physical page array based on mem bank */ + + +static void init_page_map(struct page_bitmap *pmap, unsigned long pfn_start, unsigned long pfn_end) +{ + pmap->pfn_start = pfn_start; + pmap->pfn_end = pfn_end; + set_page_map(pmap, pfn_start, pfn_end - pfn_start, 0); +} + +/* + * Marks pages in the global page_map as used or unused. + * + * @start = start page address to set, inclusive. + * @numpages = number of pages to set. + */ +int set_page_map(struct page_bitmap *page_map, unsigned long pfn_start, + int numpages, int val) +{ + unsigned long pfn_end = pfn_start + numpages; + unsigned long pfn_err = 0; + + if (page_map->pfn_start > pfn_start || page_map->pfn_end < pfn_start) { + pfn_err = pfn_start; + goto error; + } + if (page_map->pfn_end < pfn_end || page_map->pfn_start > pfn_end) { + pfn_err = pfn_end; + goto error; + } + + if (val) + for (int i = pfn_start; i < pfn_end; i++) + page_map->map[BITWISE_GETWORD(i)] |= BITWISE_GETBIT(i); + else + for (int i = pfn_start; i < pfn_end; i++) + page_map->map[BITWISE_GETWORD(i)] &= ~BITWISE_GETBIT(i); + return 0; +error: + BUG_MSG("Given page area is out of system page_map range: 0x%lx\n", + pfn_err << PAGE_BITS); + return -1; +} + +/* Allocates page descriptors and initialises them using page_map information */ +void init_physmem_secondary(struct initdata *initdata, struct membank *membank) +{ + struct page_bitmap *pmap = initdata->page_map; + int npages = pmap->pfn_end - pmap->pfn_start; + + /* Allocation marks for the struct page array; npages, start, end */ + int pg_npages, pg_spfn, pg_epfn; + unsigned long ffree_addr; + + /* + * Means the page array won't map one to one to pfns. That's ok, + * but we dont allow it for now. + */ + // BUG_ON(pmap->pfn_start); + + membank[0].start = __pfn_to_addr(pmap->pfn_start); + membank[0].end = __pfn_to_addr(pmap->pfn_end); + + /* First find the first free page after last used page */ + for (int i = 0; i < npages; i++) + if ((pmap->map[BITWISE_GETWORD(i)] & BITWISE_GETBIT(i))) + membank[0].free = (i + 1) * PAGE_SIZE; + BUG_ON(membank[0].free >= membank[0].end); + + /* + * One struct page for every physical page. Calculate how many pages + * needed for page structs, start and end pfn marks. + */ + pg_npages = __pfn(page_align_up((sizeof(struct page) * npages))); + + /* These are relative pfn offsets to the start of the memory bank */ + + /* FIXME: + * 1.) These values were only right when membank started from pfn 0. + * 2.) Use set_page_map to set page map below instead of manually. + */ + pg_spfn = __pfn(membank[0].free); + pg_epfn = pg_spfn + pg_npages; + + /* Use free pages from the bank as the space for struct page array */ + membank[0].page_array = l4_map_helper((void *)membank[0].free, + pg_npages); + /* Update free memory left */ + membank[0].free += pg_npages * PAGE_SIZE; + + /* Update page bitmap for the pages used for the page array */ + for (int i = pg_spfn; i < pg_epfn; i++) + pmap->map[BITWISE_GETWORD(i)] |= BITWISE_GETBIT(i); + + /* Initialise the page array */ + for (int i = 0; i < npages; i++) { + link_init(&membank[0].page_array[i].list); + + /* Set use counts for pages the kernel has already used up */ + if (!(pmap->map[BITWISE_GETWORD(i)] & BITWISE_GETBIT(i))) + membank[0].page_array[i].refcnt = -1; + else /* Last page used +1 is free */ + ffree_addr = (i + 1) * PAGE_SIZE; + } + + /* First free address must come up the same for both */ + BUG_ON(ffree_addr != membank[0].free); + + /* Set global page array to this bank's array */ + page_array = membank[0].page_array; + + /* Test that page/phys macros work */ + BUG_ON(phys_to_page(page_to_phys(&page_array[5])) != &page_array[5]) +} + + +/* Fills in the physmem structure with free physical memory information */ +void init_physmem_primary(struct initdata *initdata) +{ + unsigned long pfn_start, pfn_end, pfn_images_end = 0; + struct bootdesc *bootdesc = initdata->bootdesc; + + /* Allocate page map structure */ + initdata->page_map = alloc_bootmem(sizeof(struct page_bitmap) + + ((initdata->physmem->end - + initdata->physmem->start) + >> 5) + 1, 0); + + /* Initialise page map from physmem capability */ + init_page_map(initdata->page_map, + initdata->physmem->start, + initdata->physmem->end); + + /* Mark pager and other boot task areas as used */ + for (int i = 0; i < bootdesc->total_images; i++) { + pfn_start = + __pfn(page_align_up(bootdesc->images[i].phys_start)); + pfn_end = __pfn(page_align_up(bootdesc->images[i].phys_end)); + if (pfn_end > pfn_images_end) + pfn_images_end = pfn_end; + set_page_map(initdata->page_map, pfn_start, + pfn_end - pfn_start, 1); + } + + physmem.start = initdata->physmem->start; + physmem.end = initdata->physmem->end; + + physmem.free_cur = pfn_images_end; + physmem.free_end = physmem.end; + physmem.numpages = __pfn(physmem.end - physmem.start); +} + diff --git a/conts/posix/mm0/src/shm.c b/conts/posix/mm0/src/shm.c new file mode 100644 index 0000000..38fcf64 --- /dev/null +++ b/conts/posix/mm0/src/shm.c @@ -0,0 +1,381 @@ +/* + * Copyright (C) 2007, 2008 Bahadir Balban + * + * Posix shared memory implementation + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memlayout.h) +#include +#include +#include + +#define shm_file_to_desc(shm_file) \ + ((struct shm_descriptor *)shm_file->priv_data) + +/* Unique shared memory ids */ +static struct id_pool *shm_ids; + +/* Globally disjoint shm virtual address pool */ +static struct address_pool shm_vaddr_pool; + +void *shm_new_address(int npages) +{ + return address_new(&shm_vaddr_pool, npages); +} + +int shm_delete_address(void *shm_addr, int npages) +{ + return address_del(&shm_vaddr_pool, shm_addr, npages); +} + +int shm_pool_init() +{ + int err; + + /* Initialise shm id pool */ + if(IS_ERR(shm_ids = id_pool_new_init(SHM_AREA_MAX))) { + printf("SHM id pool initialisation failed.\n"); + return (int)shm_ids; + } + + /* Initialise the global shm virtual address pool */ + if ((err = address_pool_init(&shm_vaddr_pool, + SHM_AREA_START, SHM_AREA_END)) < 0) { + printf("SHM Address pool initialisation failed.\n"); + return err; + } + return 0; +} + +/* + * Attaches to given shm segment mapped at shm_addr if the shm descriptor + * does not already have a base address assigned. If neither shm_addr nor + * the descriptor has an address, allocates one from the shm address pool. + */ +static void *do_shmat(struct vm_file *shm_file, void *shm_addr, int shmflg, + struct tcb *task) +{ + struct shm_descriptor *shm = shm_file_to_desc(shm_file); + unsigned int vmflags; + void *mapped; + + if (!task) { + printf("%s:%s: Cannot find caller task with tid %d\n", + __TASKNAME__, __FUNCTION__, task->tid); + BUG(); + } + + if ((unsigned long)shm_addr & PAGE_MASK) { + if (shmflg & SHM_RND) + shm_addr = (void *)page_align(shm_addr); + else + return PTR_ERR(-EINVAL); + } + + /* Set mmap flags for segment */ + vmflags = VM_READ | VMA_SHARED | VMA_ANONYMOUS; + vmflags |= (shmflg & SHM_RDONLY) ? 0 : VM_WRITE; + + /* + * Currently all tasks use the same address for each unique segment. + * If address is already assigned, the supplied address must match + * the original address. We don't look for object map count because + * utcb addresses are assigned before being mapped. NOTE: We may do + * all this in a specific shm_mmap() call in do_mmap() in the future. + */ + if (shm_file_to_desc(shm_file)->shm_addr) { + if (shm_addr && (shm->shm_addr != shm_addr)) + return PTR_ERR(-EINVAL); + } + + /* + * mmap the area to the process as shared. Page fault + * handler would handle allocating and paging-in the + * shared pages. + */ + if (IS_ERR(mapped = do_mmap(shm_file, 0, task, + (unsigned long)shm_addr, + vmflags, shm->npages))) { + printf("do_mmap: Mapping shm area failed with %d.\n", + (int)mapped); + return PTR_ERR(mapped); + } + + /* Assign new shm address if not assigned */ + if (!shm->shm_addr) + shm->shm_addr = mapped; + else + BUG_ON(shm->shm_addr != mapped); + + return shm->shm_addr; +} + +void *sys_shmat(struct tcb *task, l4id_t shmid, void *shmaddr, int shmflg) +{ + struct vm_file *shm_file, *n; + + list_foreach_removable_struct(shm_file, n, &global_vm_files.list, list) { + if (shm_file->type == VM_FILE_SHM && + shm_file_to_desc(shm_file)->shmid == shmid) + return do_shmat(shm_file, shmaddr, + shmflg, task); + } + + return PTR_ERR(-EINVAL); +} + +int do_shmdt(struct tcb *task, struct vm_file *shm) +{ + int err; + + if ((err = do_munmap(task, + (unsigned long)shm_file_to_desc(shm)->shm_addr, + shm_file_to_desc(shm)->npages)) < 0) + return err; + + return 0; +} + +int sys_shmdt(struct tcb *task, const void *shmaddr) +{ + struct vm_file *shm_file, *n; + + list_foreach_removable_struct(shm_file, n, &global_vm_files.list, list) + if (shm_file->type == VM_FILE_SHM && + shm_file_to_desc(shm_file)->shm_addr == shmaddr) + return do_shmdt(task, shm_file); + + return -EINVAL; +} + +/* + * This finds out what address pool the shm area came from and + * returns the address back to that pool. There are 2 pools, + * one for utcbs and one for regular shm segments. + */ +void shm_destroy_priv_data(struct vm_file *shm_file) +{ + struct shm_descriptor *shm_desc = shm_file_to_desc(shm_file); + + /* Release the shared memory address */ + BUG_ON(shm_delete_address(shm_desc->shm_addr, + shm_file->vm_obj.npages) < 0); + + /* Release the shared memory id */ + BUG_ON(id_del(shm_ids, shm_desc->shmid) < 0); + + /* Now delete the private data itself */ + kfree(shm_file->priv_data); +} + +/* Creates an shm area and glues its details with shm pager and devzero */ +struct vm_file *shm_new(key_t key, unsigned long npages) +{ + struct shm_descriptor *shm_desc; + struct vm_file *shm_file; + + BUG_ON(!npages); + + /* Allocate file and shm structures */ + if (IS_ERR(shm_file = vm_file_create())) + return PTR_ERR(shm_file); + + if (!(shm_desc = kzalloc(sizeof(struct shm_descriptor)))) { + kfree(shm_file); + return PTR_ERR(-ENOMEM); + } + + /* Initialise the shm descriptor */ + if (IS_ERR(shm_desc->shmid = id_new(shm_ids))) { + kfree(shm_file); + kfree(shm_desc); + return PTR_ERR(shm_desc->shmid); + } + shm_desc->key = (int)key; + shm_desc->npages = npages; + + /* Initialise the file */ + shm_file->length = __pfn_to_addr(npages); + shm_file->type = VM_FILE_SHM; + shm_file->priv_data = shm_desc; + shm_file->destroy_priv_data = shm_destroy_priv_data; + + /* Initialise the vm object */ + shm_file->vm_obj.pager = &swap_pager; + shm_file->vm_obj.flags = VM_OBJ_FILE | VM_WRITE; + + /* Add to shm file and global object list */ + global_add_vm_file(shm_file); + + return shm_file; +} + +/* + * Fast internal path to do shmget/shmat() together for mm0's + * convenience. Works for existing areas. + */ +void *shmat_shmget_internal(struct tcb *task, key_t key, void *shmaddr) +{ + struct vm_file *shm_file; + struct shm_descriptor *shm_desc; + + list_foreach_struct(shm_file, &global_vm_files.list, list) { + if(shm_file->type == VM_FILE_SHM) { + shm_desc = shm_file_to_desc(shm_file); + /* Found the key, shmat that area */ + if (shm_desc->key == key) + return do_shmat(shm_file, shmaddr, + 0, task); + } + } + + return PTR_ERR(-EEXIST); +} + +/* + * FIXME: Make sure hostile tasks don't subvert other tasks' shared pages + * by early-registring their shared page address here. + */ +int sys_shmget(key_t key, int size, int shmflg) +{ + unsigned long npages = __pfn(page_align_up(size)); + struct shm_descriptor *shm_desc; + struct vm_file *shm; + + /* First check argument validity */ + if (npages > SHM_SHMMAX || npages < SHM_SHMMIN) + return -EINVAL; + + /* + * IPC_PRIVATE means create a no-key shm area, i.e. private to this + * process so that it would only share it with its forked children. + */ + if (key == IPC_PRIVATE) { + key = -1; /* Our meaning of no key */ + if (!(shm = shm_new(key, npages))) + return -ENOSPC; + else + return shm_file_to_desc(shm)->shmid; + } + + list_foreach_struct(shm, &global_vm_files.list, list) { + if (shm->type != VM_FILE_SHM) + continue; + + shm_desc = shm_file_to_desc(shm); + + if (shm_desc->key == key) { + /* + * Exclusive means a create request + * on an existing key should fail. + */ + if ((shmflg & IPC_CREAT) && (shmflg & IPC_EXCL)) + return -EEXIST; + else + /* Found it but do we have a size problem? */ + if (shm_desc->npages < npages) + return -EINVAL; + else /* Return shmid of the existing key */ + return shm_desc->shmid; + } + } + + /* Key doesn't exist and create is set, so we create */ + if (shmflg & IPC_CREAT) + if (!(shm = shm_new(key, npages))) + return -ENOSPC; + else + return shm_file_to_desc(shm)->shmid; + else /* Key doesn't exist, yet create isn't set, its an -ENOENT */ + return -ENOENT; +} + + + +/* + * Currently, a default shm page is allocated to every thread in the system + * for efficient ipc communication. This part below provides the allocation + * and mapping of this page using shmat/get/dt call semantics. + */ + +/* + * Sends shpage address information to requester. The requester then uses + * this address as a shm key and maps it via shmget/shmat. + */ +void *task_send_shpage_address(struct tcb *sender, l4id_t taskid) +{ + struct tcb *task = find_task(taskid); + + /* Is the task asking for its own utcb address */ + if (sender->tid == taskid) { + /* It hasn't got one allocated. */ + BUG_ON(!task->shared_page); + + /* Return it to requester */ + return task->shared_page; + + /* A task is asking for someone else's utcb */ + } else { + /* Only vfs is allowed to do so yet, because its a server */ + if (sender->tid == VFS_TID) { + /* + * Return shpage address to requester. Note if there's + * none allocated so far, requester gets 0. We don't + * allocate one here. + */ + return task->shared_page; + } + } + return 0; +} + +int shpage_map_to_task(struct tcb *owner, struct tcb *mapper, unsigned int flags) +{ + struct vm_file *default_shm; + + /* Allocate a new shared page address */ + if (flags & SHPAGE_NEW_ADDRESS) + owner->shared_page = + shm_new_address(DEFAULT_SHPAGE_SIZE/PAGE_SIZE); + else if (!owner->shared_page) + BUG(); + + /* Create a new shared memory segment */ + if (flags & SHPAGE_NEW_SHM) + if (IS_ERR(default_shm = shm_new((key_t)owner->shared_page, + __pfn(DEFAULT_SHPAGE_SIZE)))) + return (int)default_shm; + + /* Map the shared page to mapper */ + if (IS_ERR(shmat_shmget_internal(mapper, (key_t)owner->shared_page, + owner->shared_page))) + BUG(); + + /* Prefault the owner's shared page to mapper's address space */ + if (flags & SHPAGE_PREFAULT) + for (int i = 0; i < __pfn(DEFAULT_SHPAGE_SIZE); i++) + prefault_page(mapper, (unsigned long)owner->shared_page + + __pfn_to_addr(i), VM_READ | VM_WRITE); + return 0; +} + +int shpage_unmap_from_task(struct tcb *owner, struct tcb *mapper) +{ + return sys_shmdt(mapper, owner->shared_page); +} diff --git a/conts/posix/mm0/src/task.c b/conts/posix/mm0/src/task.c new file mode 100644 index 0000000..00c1b15 --- /dev/null +++ b/conts/posix/mm0/src/task.c @@ -0,0 +1,707 @@ +/* + * Task management. + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include INC_GLUE(memory.h) + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct global_list global_tasks = { + .list = { &global_tasks.list, &global_tasks.list }, + .total = 0, +}; + +void print_tasks(void) +{ + struct tcb *task; + printf("Tasks:\n========\n"); + list_foreach_struct(task, &global_tasks.list, list) { + printf("Task tid: %d, spid: %d\n", task->tid, task->spid); + } +} + +void global_add_task(struct tcb *task) +{ + BUG_ON(!list_empty(&task->list)); + list_insert_tail(&task->list, &global_tasks.list); + global_tasks.total++; +} + +void global_remove_task(struct tcb *task) +{ + BUG_ON(list_empty(&task->list)); + list_remove_init(&task->list); + BUG_ON(--global_tasks.total < 0); +} + +struct tcb *find_task(int tid) +{ + struct tcb *t; + + list_foreach_struct(t, &global_tasks.list, list) + if (t->tid == tid) + return t; + return 0; +} + +struct tcb *tcb_alloc_init(unsigned int flags) +{ + struct tcb *task; + + if (!(task = kzalloc(sizeof(struct tcb)))) + return PTR_ERR(-ENOMEM); + + /* Allocate new vma head if its not shared */ + if (!(flags & TCB_SHARED_VM)) { + if (!(task->vm_area_head = + kzalloc(sizeof(*task->vm_area_head)))) { + kfree(task); + return PTR_ERR(-ENOMEM); + } + task->vm_area_head->tcb_refs = 1; + link_init(&task->vm_area_head->list); + + /* Also allocate a utcb head for new address space */ + if (!(task->utcb_head = + kzalloc(sizeof(*task->utcb_head)))) { + kfree(task->vm_area_head); + kfree(task); + return PTR_ERR(-ENOMEM); + } + task->utcb_head->tcb_refs = 1; + link_init(&task->utcb_head->list); + } + + /* Allocate file structures if not shared */ + if (!(flags & TCB_SHARED_FILES)) { + if (!(task->files = + kzalloc(sizeof(*task->files)))) { + kfree(task->vm_area_head); + kfree(task->utcb_head); + kfree(task); + return PTR_ERR(-ENOMEM); + } + task->files->tcb_refs = 1; + } + + /* Ids will be acquired from the kernel */ + task->tid = TASK_ID_INVALID; + task->spid = TASK_ID_INVALID; + task->tgid = TASK_ID_INVALID; + + /* Initialise list structure */ + link_init(&task->list); + link_init(&task->child_ref); + link_init(&task->children); + + return task; +} + +/* + * Free vmas, fd structure and utcb address. + * Make sure to sync all IO beforehand + */ +int task_free_resources(struct tcb *task) +{ + /* + * Threads may share file descriptor structure + * if no users left, free it. + */ + if (!(--task->files->tcb_refs)) + kfree(task->files); + + /* + * Threads may share the virtual space. + * if no users of the vma struct left, + * free it along with all its vma links. + */ + if (!(--task->vm_area_head->tcb_refs)) { + /* Free all vmas */ + task_release_vmas(task->vm_area_head); + + /* Free the head */ + kfree(task->vm_area_head); + } + + /* + * Threads may share utcb chain + */ + if (!(--task->utcb_head->tcb_refs)) { + /* UTCBs must have been deleted explicitly */ + BUG_ON(!list_empty(&task->utcb_head->list)); + + /* Free the head */ + kfree(task->utcb_head); + } + + return 0; +} + +int tcb_destroy(struct tcb *task) +{ + struct tcb *child, *n; + + global_remove_task(task); + + /* Free all resources of the task */ + task_free_resources(task); + + /* + * All children of the current task becomes children + * of the parent of this task. + */ + list_foreach_removable_struct(child, n, &task->children, + child_ref) { + list_remove_init(&child->child_ref); + list_insert_tail(&child->child_ref, + &task->parent->children); + child->parent = task->parent; + } + /* The task is not a child of its parent */ + list_remove_init(&task->child_ref); + + /* Now task deletion make sure task is in no list */ + BUG_ON(!list_empty(&task->list)); + BUG_ON(!list_empty(&task->child_ref)); + BUG_ON(!list_empty(&task->children)); + kfree(task); + + return 0; +} + +/* + * Copy all vmas from the given task and populate each with + * links to every object that the original vma is linked to. + * Note, that we don't copy vm objects but just the links to + * them, because vm objects are not per-process data. + */ +int task_copy_vmas(struct tcb *to, struct tcb *from) +{ + struct vm_area *vma, *new_vma; + + list_foreach_struct(vma, &from->vm_area_head->list, list) { + + /* Create a new vma */ + new_vma = vma_new(vma->pfn_start, vma->pfn_end - vma->pfn_start, + vma->flags, vma->file_offset); + + /* Copy all object links */ + vma_copy_links(new_vma, vma); + + /* All link copying is finished, now add the new vma to task */ + task_insert_vma(new_vma, &to->vm_area_head->list); + } + + return 0; +} + +/* + * Traverse all vmas, release all links to vm_objects. + * Used when a task or thread group with a shared vm is exiting. + */ +int task_release_vmas(struct task_vma_head *vma_head) +{ + struct vm_area *vma, *n; + + list_foreach_removable_struct(vma, n, &vma_head->list, list) { + /* Release all links */ + vma_drop_merge_delete_all(vma); + + /* Delete the vma from task's vma list */ + list_remove(&vma->list); + + /* Free the vma */ + kfree(vma); + } + return 0; +} + +int copy_tcb(struct tcb *to, struct tcb *from, unsigned int flags) +{ + /* Copy program segment boundary information */ + to->start = from->start; + to->end = from->end; + to->text_start = from->text_start; + to->text_end = from->text_end; + to->data_start = from->data_start; + to->data_end = from->data_end; + to->bss_start = from->bss_start; + to->bss_end = from->bss_end; + to->stack_start = from->stack_start; + to->stack_end = from->stack_end; + to->heap_start = from->heap_start; + to->heap_end = from->heap_end; + to->args_start = from->args_start; + to->args_end = from->args_end; + to->map_start = from->map_start; + to->map_end = from->map_end; + + /* Sharing the list of vmas and utcbs */ + if (flags & TCB_SHARED_VM) { + to->vm_area_head = from->vm_area_head; + to->vm_area_head->tcb_refs++; + to->utcb_head = from->utcb_head; + to->utcb_head->tcb_refs++; + } else { + /* Copy all vm areas */ + task_copy_vmas(to, from); + + /* + * NOTE: + * No copy for utcb descriptor list, + * forker shall start its own unique. + */ + } + + /* Copy all file descriptors */ + if (flags & TCB_SHARED_FILES) { + to->files = from->files; + to->files->tcb_refs++; + } else { + /* Bulk copy all file descriptors */ + memcpy(to->files, from->files, sizeof(*to->files)); + + /* Increase refcount for all open files */ + for (int i = 0; i < TASK_FILES_MAX; i++) + if (to->files->fd[i].vmfile) + to->files->fd[i].vmfile->openers++; + } + + return 0; +} + +struct tcb *task_create(struct tcb *parent, struct task_ids *ids, + unsigned int ctrl_flags, unsigned int share_flags) +{ + struct tcb *task; + int err; + + /* Set task ids if a parent is supplied */ + if (parent) { + ids->tid = parent->tid; + ids->spid = parent->spid; + + /* + * Determine whether the cloned thread + * is in parent's thread group + */ + if (share_flags & TCB_SHARED_TGROUP) + ids->tgid = parent->tgid; + else + ids->tgid = TASK_ID_INVALID; + } + + /* Create the thread structures and address space */ + if ((err = l4_thread_control(THREAD_CREATE | ctrl_flags, ids)) < 0) { + printf("l4_thread_control failed with %d.\n", err); + return PTR_ERR(err); + } + + /* Create a task and use given space and thread ids. */ + if (IS_ERR(task = tcb_alloc_init(share_flags))) + return PTR_ERR(task); + + /* Set task's ids */ + task->tid = ids->tid; + task->spid = ids->spid; + task->tgid = ids->tgid; + + /* Set task's creation flags */ + task->clone_flags = share_flags; + + /* + * If a parent task has been specified, that means either + * we are forking, or we are cloning the original tcb fully + * or partially. Therefore we copy tcbs depending on share flags. + */ + if (parent) { + copy_tcb(task, parent, share_flags); + + /* Set up a new utcb for new thread */ + task_setup_utcb(task); + + /* Set up parent-child relationship */ + if ((share_flags & TCB_SHARED_PARENT) || + (share_flags & TCB_SHARED_TGROUP)) { + + /* + * On these conditions child shares + * the parent of the caller + */ + list_insert_tail(&task->child_ref, + &parent->parent->children); + task->parent = parent->parent; + } else { + list_insert_tail(&task->child_ref, + &parent->children); + task->parent = parent; + } + } else { + struct tcb *pager = find_task(PAGER_TID); + + /* All parentless tasks are children of the pager */ + list_insert_tail(&task->child_ref, &pager->children); + task->parent = pager; + } + + return task; +} + +/* + * Copy argument and environment strings into task's stack in a + * format that is expected by the C runtime. + * + * e.g. uclibc expects stack state: + * + * (low) |->argc|argv[0]|argv[1]|...|argv[argc] = 0|envp[0]|...|NULL| (high) + * + */ +int task_args_to_user(char *user_stack, struct args_struct *args, + struct args_struct *env) +{ + BUG_ON((unsigned long)user_stack & 7); + + /* Copy argc */ + *((int *)user_stack) = args->argc; + user_stack += sizeof(int); + + /* Copy argument strings one by one */ + for (int i = 0; i < args->argc; i++) { + strcpy(user_stack, args->argv[i]); + user_stack += strlen(args->argv[i]) + 1; + } + /* Put the null terminator integer */ + *((int *)user_stack) = 0; + user_stack = user_stack + sizeof(int); + + /* Copy environment strings one by one */ + for (int i = 0; i < env->argc; i++) { + strcpy(user_stack, env->argv[i]); + user_stack += strlen(env->argv[i]) + 1; + } + + return 0; +} + +int task_map_stack(struct vm_file *f, struct exec_file_desc *efd, struct tcb *task, + struct args_struct *args, struct args_struct *env) +{ + /* First set up task's stack markers */ + unsigned long stack_used = align_up(args->size + env->size, 8); + unsigned long arg_pages = __pfn(page_align_up(stack_used)); + char *args_on_stack; + void *mapped; + + task->stack_end = USER_AREA_END; + task->stack_start = USER_AREA_END - DEFAULT_STACK_SIZE; + task->args_end = task->stack_end; + task->args_start = task->stack_end - stack_used; + + BUG_ON(stack_used > DEFAULT_STACK_SIZE); + + /* + * mmap task's stack as anonymous memory. + * TODO: Add VMA_GROWSDOWN here so the stack can expand. + */ + if (IS_ERR(mapped = do_mmap(0, 0, task, task->stack_start, + VM_READ | VM_WRITE | + VMA_PRIVATE | VMA_ANONYMOUS, + __pfn(task->stack_end - + task->stack_start)))) { + printf("do_mmap: Mapping stack failed with %d.\n", + (int)mapped); + return (int)mapped; + } + + /* Map the stack's part that will contain args and environment */ + if (IS_ERR(args_on_stack = + pager_validate_map_user_range2(task, + (void *)task->args_start, + stack_used, + VM_READ | VM_WRITE))) { + return (int)args_on_stack; + } + + /* Copy arguments and env */ + task_args_to_user(args_on_stack, args, env); + + /* Unmap task's those stack pages from pager */ + pager_unmap_pages(args_on_stack, arg_pages); + + return 0; +} + +/* + * If bss comes consecutively after the data section, prefault the + * last page of the data section and zero out the bit that contains + * the beginning of bss. If bss spans into more pages, then map those + * pages as anonymous pages which are mapped by the devzero file. + */ +int task_map_bss(struct vm_file *f, struct exec_file_desc *efd, struct tcb *task) +{ + unsigned long bss_mmap_start; + void *mapped; + + /* + * Test if bss starts right from the end of data, + * and not on a new page boundary. + */ + if ((task->data_end == task->bss_start) && + !is_page_aligned(task->bss_start)) { + unsigned long bss_size = task->bss_end - task->bss_start; + struct page *last_data_page; + void *pagebuf, *bss; + + /* Prefault the last data page */ + BUG_ON(prefault_page(task, task->data_end, + VM_READ | VM_WRITE) < 0); + /* Get the page */ + last_data_page = task_virt_to_page(task, task->data_end); + + /* Map the page */ + pagebuf = l4_map_helper((void *)page_to_phys(last_data_page), 1); + + /* Find the bss offset */ + bss = (void *)((unsigned long)pagebuf | + (PAGE_MASK & task->bss_start)); + + /* + * Zero out the part that is bss. This is minimum of either + * end of bss or until the end of page, whichever is met first. + */ + memset((void *)bss, 0, min(TILL_PAGE_ENDS(task->data_end), + (int)bss_size)); + + /* Unmap the page */ + l4_unmap_helper(pagebuf, 1); + + /* Push bss mmap start to next page */ + bss_mmap_start = page_align_up(task->bss_start); + } else /* Otherwise bss mmap start is same as bss_start */ + bss_mmap_start = task->bss_start; + + /* + * Now if there are more pages covering bss, + * map those as anonymous zero pages + */ + if (task->bss_end > bss_mmap_start) { + if (IS_ERR(mapped = do_mmap(0, 0, task, task->bss_start, + VM_READ | VM_WRITE | + VMA_PRIVATE | VMA_ANONYMOUS, + __pfn(page_align_up(task->bss_end) - + page_align(task->bss_start))))) { + printf("do_mmap: Mapping environment failed with %d.\n", + (int)mapped); + return (int)mapped; + } + } + + return 0; +} + +int task_mmap_segments(struct tcb *task, struct vm_file *file, struct exec_file_desc *efd, + struct args_struct *args, struct args_struct *env) +{ + void *mapped; + //struct vm_file *shm; + int err; + int text_size, data_size; + + /* Set up task's user boundary regions */ + task->start = USER_AREA_START; + task->end = USER_AREA_END; + task->map_start = task->start; + task->map_end = task->end; + + text_size = __pfn(page_align_up(task->text_end) - + page_align(task->text_start)); + data_size = __pfn(page_align_up(task->data_end) - + page_align(task->text_start)); + + /* mmap task's text to task's address space. */ + if (IS_ERR(mapped = do_mmap(file, efd->text_offset, task, + task->text_start, VM_READ | VM_WRITE | + VM_EXEC | VMA_PRIVATE, text_size))) { + printf("do_mmap: failed with %d.\n", (int)mapped); + err = (int)mapped; + goto out_err; + } + + /* mmap task's data to task's address space. */ + if (IS_ERR(mapped = do_mmap(file, efd->data_offset, task, + task->data_start, VM_READ | VM_WRITE | + VMA_PRIVATE, data_size))) { + printf("do_mmap: failed with %d.\n", (int)mapped); + err = (int)mapped; + goto out_err; + } + + /* mmap task's bss as anonymous memory. */ + if ((err = task_map_bss(file, efd, task)) < 0) { + printf("%s: Mapping bss has failed.\n", + __FUNCTION__); + goto out_err; + } + + /* mmap task's stack, writing in the arguments and environment */ + if ((err = task_map_stack(file, efd, task, args, env)) < 0) { + printf("%s: Mapping task's stack has failed.\n", + __FUNCTION__); + goto out_err; + } + + /* Get a new utcb slot for new task */ + if ((err = task_setup_utcb(task)) < 0) { + printf("%s: Mapping task's utcb has failed.\n", + __FUNCTION__); + goto out_err; + } + + return 0; + +out_err: + task_free_resources(task); + return err; +} + +int task_setup_registers(struct tcb *task, unsigned int pc, + unsigned int sp, l4id_t pager) +{ + int err; + struct exregs_data exregs; + + /* Set up task's registers to default. */ + if (!sp) + sp = align(task->stack_end - 1, 8); + if (!pc) + if (!(pc = task->entry)) + pc = task->text_start; + if (!pager) + pager = self_tid(); + + /* Set up the task's thread details, (pc, sp, pager etc.) */ + exregs_set_stack(&exregs, sp); + exregs_set_pc(&exregs, pc); + exregs_set_pager(&exregs, pager); + exregs_set_utcb(&exregs, task->utcb_address); + + if ((err = l4_exchange_registers(&exregs, task->tid)) < 0) { + printf("l4_exchange_registers failed with %d.\n", err); + return err; + } + + return 0; +} + +int task_start(struct tcb *task) +{ + int err; + struct task_ids ids = { + .tid = task->tid, + .spid = task->spid, + .tgid = task->tgid, + }; + + /* Start the thread */ + // printf("%s: Starting task with thread id: %d, space id: %d\n", + // __TASKNAME__, task->tid, task->spid); + if ((err = l4_thread_control(THREAD_RUN, &ids)) < 0) { + printf("l4_thread_control failed with %d\n", err); + return err; + } + + return 0; +} + +/* + * During its initialisation FS0 wants to learn how many boot tasks + * are running, and their tids, which includes itself. This function + * provides that information. + */ +int vfs_send_task_data(struct tcb *vfs) +{ + int li = 0; + struct tcb *t, *self; + struct task_data_head *tdata_head; + + if (vfs->tid != VFS_TID) { + printf("%s: Task data requested by %d, which is not " + "FS0 id %d, ignoring.\n", __TASKNAME__, vfs->tid, + VFS_TID); + return 0; + } + + BUG_ON(!(self = find_task(self_tid()))); + BUG_ON(!vfs->shared_page); + + /* Attach mm0 to vfs's utcb segment just like a normal task */ + shpage_map_to_task(vfs, self, SHPAGE_PREFAULT); + + /* Write all requested task information to shared pages's user buffer area */ + tdata_head = (struct task_data_head *)vfs->shared_page; + + /* First word is total number of tcbs */ + tdata_head->total = global_tasks.total; + + /* Write per-task data for all tasks */ + list_foreach_struct(t, &global_tasks.list, list) { + tdata_head->tdata[li].tid = t->tid; + tdata_head->tdata[li].shpage_address = (unsigned long)t->shared_page; + li++; + } + + return 0; +} + +/* + * Prefaults all mapped regions of a task. The reason we have this is + * some servers are in the page fault handling path (e.g. fs0), and we + * don't want them to fault and cause deadlocks and circular deps. + * + * Normally fs0 faults dont cause dependencies because its faults + * are handled by the boot pager, which is part of mm0. BUT: It may + * cause deadlocks because fs0 may fault while serving a request + * from mm0.(Which is expected to also handle the fault). + */ +int task_prefault_regions(struct tcb *task, struct vm_file *f) +{ + struct vm_area *vma; + + list_foreach_struct(vma, &task->vm_area_head->list, list) { + for (int pfn = vma->pfn_start; pfn < vma->pfn_end; pfn++) + BUG_ON(prefault_page(task, __pfn_to_addr(pfn), + VM_READ | VM_WRITE) < 0); + } + return 0; +} + diff --git a/conts/posix/mm0/src/test.c b/conts/posix/mm0/src/test.c new file mode 100644 index 0000000..e04ab66 --- /dev/null +++ b/conts/posix/mm0/src/test.c @@ -0,0 +1,130 @@ +/* + * These functions here do run-time checks on all fields + * of tasks, vmas, and vm objects to see that they + * have expected values. + * + * Copyright (C) 2008 Bahadir Balban + */ + +#include +#include +#include +#include + +struct vm_statistics { + int tasks; /* All tasks counted on the system */ + int vm_objects; /* All objects counted on the system */ + int shadow_objects; /* Shadows counted by hand (well almost!) */ + int shadows_referred; /* Shadows that objects say they have */ + int file_objects; /* Objects that are found to be files */ + int vm_files; /* All files counted on the system */ + int shm_files; /* SHM files counted */ + int boot_files; /* Boot files counted */ + int vfs_files; /* VFS files counted */ + int devzero; /* Devzero count, must be 1 */ +}; + +/* Count links in objects link list, and compare with nlinks */ +int vm_object_test_link_count(struct vm_object *vmo) +{ + int links = 0; + struct vm_obj_link *l; + + list_foreach_struct(l, &vmo->link_list, linkref) + links++; + + BUG_ON(links != vmo->nlinks); + return 0; +} + +int vm_object_test_shadow_count(struct vm_object *vmo) +{ + struct vm_object *sh; + int shadows = 0; + + list_foreach_struct(sh, &vmo->shdw_list, shref) + shadows++; + + BUG_ON(shadows != vmo->shadows); + return 0; +} + +/* TODO: + * Add checking that total open file descriptors are + * equal to total opener count of all files + */ +int mm0_test_global_vm_integrity(void) +{ + struct tcb *task; + struct vm_object *vmo; + struct vm_statistics vmstat; + struct vm_file *f; + + + memset(&vmstat, 0, sizeof(vmstat)); + + /* Count all shadow and file objects */ + list_foreach_struct(vmo, &global_vm_objects.list, list) { + vmstat.shadows_referred += vmo->shadows; + if (vmo->flags & VM_OBJ_SHADOW) + vmstat.shadow_objects++; + if (vmo->flags & VM_OBJ_FILE) + vmstat.file_objects++; + vmstat.vm_objects++; + vm_object_test_shadow_count(vmo); + vm_object_test_link_count(vmo); + } + + /* Count all registered vmfiles */ + list_foreach_struct(f, &global_vm_files.list, list) { + vmstat.vm_files++; + if (f->type == VM_FILE_SHM) + vmstat.shm_files++; + else if (f->type == VM_FILE_BOOTFILE) + vmstat.boot_files++; + else if (f->type == VM_FILE_VFS) + vmstat.vfs_files++; + else if (f->type == VM_FILE_DEVZERO) + vmstat.devzero++; + else BUG(); + } + + if (vmstat.vm_files != global_vm_files.total) { + printf("Total counted files don't match " + "global_vm_files total\n"); + BUG(); + } + + if (vmstat.vm_objects != global_vm_objects.total) { + printf("Total counted vm_objects don't " + "match global_vm_objects total\n"); + BUG(); + } + + /* Total file objects must be equal to total vm files */ + if (vmstat.vm_files != vmstat.file_objects) { + printf("\nTotal files don't match total file objects.\n"); + printf("vm files:\n"); + vm_print_files(&global_vm_files.list); + printf("\nvm objects:\n"); + vm_print_objects(&global_vm_objects.list); + printf("\n"); + BUG(); + } + + /* Counted and referred shadows must match */ + BUG_ON(vmstat.shadow_objects != vmstat.shadows_referred); + + /* Count all tasks */ + list_foreach_struct(task, &global_tasks.list, list) + vmstat.tasks++; + + if (vmstat.tasks != global_tasks.total) { + printf("Total counted tasks don't match global_tasks total\n"); + BUG(); + } + return 0; +} + + + diff --git a/conts/posix/mm0/src/user.c b/conts/posix/mm0/src/user.c new file mode 100644 index 0000000..b3a7d32 --- /dev/null +++ b/conts/posix/mm0/src/user.c @@ -0,0 +1,76 @@ +/* + * Functions to validate, map and unmap user buffers. + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include + +/* + * Checks if the given user virtual address range is + * validly owned by that user with given flags. + * + * FIXME: This scans the vmas page by page, we can do it faster + * by leaping from one vma to next. + */ +int pager_validate_user_range(struct tcb *user, void *userptr, unsigned long size, + unsigned int vmflags) +{ + struct vm_area *vma; + unsigned long start = page_align(userptr); + unsigned long end = page_align_up(userptr + size); + + /* Find the vma that maps that virtual address */ + for (unsigned long vaddr = start; vaddr < end; vaddr += PAGE_SIZE) { + if (!(vma = find_vma(vaddr, &user->vm_area_head->list))) { + //printf("%s: No VMA found for 0x%x on task: %d\n", + // __FUNCTION__, vaddr, user->tid); + return -1; + } + if ((vma->flags & vmflags) != vmflags) + return -1; + } + + return 0; +} + +/* + * Validates and maps the user virtual address range to the pager. + * Every virtual page needs to be mapped individually because it's + * not guaranteed pages are physically contiguous. + * + * FIXME: There's no logic here to make non-contiguous physical pages + * to get mapped virtually contiguous. + */ +void *pager_validate_map_user_range(struct tcb *user, void *userptr, + unsigned long size, unsigned int vm_flags) +{ + unsigned long start = page_align(userptr); + unsigned long end = page_align_up(userptr + size); + void *mapped = 0; + + /* Validate that user task owns this address range */ + if (pager_validate_user_range(user, userptr, size, vm_flags) < 0) + return 0; + + /* Map first page and calculate the mapped address of pointer */ + mapped = l4_map_helper((void *)page_to_phys(task_virt_to_page(user, start)), 1); + mapped = (void *)(((unsigned long)mapped) | + ((unsigned long)(PAGE_MASK & (unsigned long)userptr))); + + /* Map the rest of the pages, if any */ + for (unsigned long i = start + PAGE_SIZE; i < end; i += PAGE_SIZE) + l4_map_helper((void *)page_to_phys(task_virt_to_page(user, + start + i)), 1); + + return mapped; +} + +void pager_unmap_user_range(void *mapped_ptr, unsigned long size) +{ + l4_unmap_helper((void *)page_align(mapped_ptr), + __pfn(page_align_up(size))); +} + diff --git a/conts/posix/mm0/src/utcb.c b/conts/posix/mm0/src/utcb.c new file mode 100644 index 0000000..3e7c814 --- /dev/null +++ b/conts/posix/mm0/src/utcb.c @@ -0,0 +1,184 @@ +/* + * Management of task utcb regions and own utcb. + * + * Copyright (C) 2007-2009 Bahadir Bilgehan Balban + */ +#include +#include +#include INC_GLUE(memlayout.h) +#include +#include +#include +#include + +/* + * UTCB management in Codezero + */ + +/* Globally disjoint utcb virtual region pool */ +static struct address_pool utcb_region_pool; + +int utcb_pool_init() +{ + int err; + + /* Initialise the global shm virtual address pool */ + if ((err = address_pool_init(&utcb_region_pool, + UTCB_AREA_START, UTCB_AREA_END)) < 0) { + printf("UTCB address pool initialisation failed.\n"); + return err; + } + return 0; +} + +void *utcb_new_address(int npages) +{ + return address_new(&utcb_region_pool, npages); +} + +int utcb_delete_address(void *utcb_address, int npages) +{ + return address_del(&utcb_region_pool, utcb_address, npages); +} + +/* Return an empty utcb slot in this descriptor */ +unsigned long utcb_new_slot(struct utcb_desc *desc) +{ + int slot; + + if ((slot = id_new(desc->slots)) < 0) + return 0; + else + return desc->utcb_base + (unsigned long)slot * UTCB_SIZE; +} + +int utcb_delete_slot(struct utcb_desc *desc, unsigned long address) +{ + BUG_ON(id_del(desc->slots, (address - desc->utcb_base) + / UTCB_SIZE) < 0); + return 0; +} + +unsigned long task_new_utcb_desc(struct tcb *task) +{ + struct utcb_desc *d; + + /* Allocate a new descriptor */ + if (!(d = kzalloc(sizeof(*d)))) + return 0; + + link_init(&d->list); + + /* We currently assume UTCB is smaller than PAGE_SIZE */ + BUG_ON(UTCB_SIZE > PAGE_SIZE); + + /* Initialise utcb slots */ + d->slots = id_pool_new_init(PAGE_SIZE / UTCB_SIZE); + + /* Obtain a new and unique utcb base */ + /* FIXME: Use variable size than a page */ + d->utcb_base = (unsigned long)utcb_new_address(1); + + /* Add descriptor to tcb's chain */ + list_insert(&d->list, &task->utcb_head->list); + + /* Obtain and return first slot */ + return utcb_new_slot(d); +} + +int task_delete_utcb_desc(struct tcb *task, struct utcb_desc *d) +{ + /* Unlink desc from its list */ + list_remove_init(&d->list); + + /* Unmap the descriptor region */ + do_munmap(task, d->utcb_base, 1); + + /* Return descriptor address */ + utcb_delete_address((void *)d->utcb_base, 1); + + /* Free the descriptor */ + kfree(d); + + return 0; +} + +/* + * Upon fork, the utcb descriptor list is origaced by a new one, since it is a new + * address space. A new utcb is allocated and mmap'ed for the child task + * running in the newly created address space. + * + * The original privately mmap'ed regions for thread-local utcbs remain + * as copy-on-write on the new task, just like mmap'ed the stacks for cloned + * threads in the parent address space. + * + * Upon clone, naturally the utcb descriptor chain and vm_areas remain to be + * shared. A new utcb slot is allocated either by using an empty one in one of + * the existing mmap'ed utcb regions, or by mmaping a new utcb region. + */ +int task_setup_utcb(struct tcb *task) +{ + struct utcb_desc *udesc; + unsigned long slot; + void *err; + + /* Setting this up twice is a bug */ + BUG_ON(task->utcb_address); + + /* Search for an empty utcb slot already allocated to this space */ + list_foreach_struct(udesc, &task->utcb_head->list, list) + if ((slot = utcb_new_slot(udesc))) + goto out; + + /* Allocate a new utcb memory region and return its base */ + slot = task_new_utcb_desc(task); +out: + + /* Check if utcb is already mapped (in case of multiple threads) */ + if (!find_vma(slot, &task->vm_area_head->list)) { + /* Map this region as private to current task */ + if (IS_ERR(err = do_mmap(0, 0, task, slot, + VMA_ANONYMOUS | VMA_PRIVATE | + VMA_FIXED | VM_READ | VM_WRITE, 1))) { + printf("UTCB: mmapping failed with %d\n", (int)err); + return (int)err; + } + } + + /* Assign task's utcb address */ + task->utcb_address = slot; + // printf("UTCB created at 0x%x.\n", slot); + + return 0; +} + +/* + * Deletes a utcb slot by first deleting the slot entry, the descriptor + * address if emptied, the mapping of the descriptor, and the descriptor itself + */ +int task_destroy_utcb(struct tcb *task) +{ + struct utcb_desc *udesc; + + // printf("UTCB: Destroying 0x%x\n", task->utcb_address); + + /* Find the utcb descriptor slot first */ + list_foreach_struct(udesc, &task->utcb_head->list, list) { + /* FIXME: Use variable alignment than a page */ + /* Detect matching slot */ + if (page_align(task->utcb_address) == udesc->utcb_base) { + + /* Delete slot from the descriptor */ + utcb_delete_slot(udesc, task->utcb_address); + + /* Is the desc completely empty now? */ + if (id_is_empty(udesc->slots)) + /* Delete the descriptor */ + task_delete_utcb_desc(task, udesc); + return 0; /* Finished */ + } + } + BUG(); +} + + diff --git a/conts/posix/mm0/src/vm_object.c b/conts/posix/mm0/src/vm_object.c new file mode 100644 index 0000000..23ee304 --- /dev/null +++ b/conts/posix/mm0/src/vm_object.c @@ -0,0 +1,217 @@ +/* + * vm object utility functions. + * + * Copyright (C) 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include + +/* Global list of all in-memory files on the system */ +struct global_list global_vm_files = { + .list = { &global_vm_files.list, &global_vm_files.list }, + .total = 0, +}; + +/* Global list of in-memory vm objects in the system */ +struct global_list global_vm_objects = { + .list = { &global_vm_objects.list, &global_vm_objects.list }, + .total = 0, +}; + + +void global_add_vm_object(struct vm_object *obj) +{ + BUG_ON(!list_empty(&obj->list)); + list_insert(&obj->list, &global_vm_objects.list); + global_vm_objects.total++; +} + +void global_remove_vm_object(struct vm_object *obj) +{ + BUG_ON(list_empty(&obj->list)); + list_remove_init(&obj->list); + BUG_ON(--global_vm_objects.total < 0); +} + +void global_add_vm_file(struct vm_file *f) +{ + BUG_ON(!list_empty(&f->list)); + list_insert(&f->list, &global_vm_files.list); + global_vm_files.total++; + + global_add_vm_object(&f->vm_obj); +} + +void global_remove_vm_file(struct vm_file *f) +{ + BUG_ON(list_empty(&f->list)); + list_remove_init(&f->list); + BUG_ON(--global_vm_files.total < 0); + + global_remove_vm_object(&f->vm_obj); +} + +void print_cache_pages(struct vm_object *vmo) +{ + struct page *p; + + if (!list_empty(&vmo->page_cache)) + printf("Pages:\n======\n"); + + list_foreach_struct(p, &vmo->page_cache, list) { + dprintf("Page offset: 0x%x, virtual: 0x%x, refcnt: %d\n", p->offset, + p->virtual, p->refcnt); + } +} + +void vm_object_print(struct vm_object *vmo) +{ + struct vm_file *f; + + printf("Object type: %s %s. links: %d, shadows: %d, Pages in cache: %d.\n", + vmo->flags & VM_WRITE ? "writeable" : "read-only", + vmo->flags & VM_OBJ_FILE ? "file" : "shadow", vmo->nlinks, vmo->shadows, + vmo->npages); + if (vmo->flags & VM_OBJ_FILE) { + f = vm_object_to_file(vmo); + char *ftype; + + if (f->type == VM_FILE_DEVZERO) + ftype = "devzero"; + else if (f->type == VM_FILE_BOOTFILE) + ftype = "bootfile"; + else if (f->type == VM_FILE_SHM) + ftype = "shm file"; + else if (f->type == VM_FILE_VFS) + ftype = "regular"; + else + BUG(); + + printf("File type: %s\n", ftype); + } + // print_cache_pages(vmo); + // printf("\n"); +} + +void vm_print_files(struct link *files) +{ + struct vm_file *f; + + list_foreach_struct(f, files, list) + vm_object_print(&f->vm_obj); +} + +void vm_print_objects(struct link *objects) +{ + struct vm_object *vmo; + + list_foreach_struct(vmo, objects, list) + vm_object_print(vmo); +} + +struct vm_object *vm_object_init(struct vm_object *obj) +{ + link_init(&obj->list); + link_init(&obj->shref); + link_init(&obj->shdw_list); + link_init(&obj->page_cache); + link_init(&obj->link_list); + + return obj; +} + +/* Allocate and initialise a vmfile, and return it */ +struct vm_object *vm_object_create(void) +{ + struct vm_object *obj; + + if (!(obj = kzalloc(sizeof(*obj)))) + return 0; + + return vm_object_init(obj); +} + +struct vm_file *vm_file_create(void) +{ + struct vm_file *f; + + if (!(f = kzalloc(sizeof(*f)))) + return PTR_ERR(-ENOMEM); + + link_init(&f->list); + vm_object_init(&f->vm_obj); + f->vm_obj.flags = VM_OBJ_FILE; + + return f; +} + +/* + * Populates the priv_data with vfs-file-specific + * information. + */ +struct vm_file *vfs_file_create(void) +{ + struct vm_file *f = vm_file_create(); + + if (IS_ERR(f)) + return f; + + f->priv_data = kzalloc(sizeof(struct vfs_file_data)); + f->type = VM_FILE_VFS; + + return f; +} + +/* Deletes the object via its base, along with all its pages */ +int vm_object_delete(struct vm_object *vmo) +{ + struct vm_file *f; + + // vm_object_print(vmo); + + /* Release all pages */ + vmo->pager->ops.release_pages(vmo); + + /* Remove from global list */ + if (vmo->flags & VM_OBJ_FILE) + global_remove_vm_file(vm_object_to_file(vmo)); + else if (vmo->flags & VM_OBJ_SHADOW) + global_remove_vm_object(vmo); + else BUG(); + + /* Check any references */ + BUG_ON(vmo->nlinks); + BUG_ON(vmo->shadows); + BUG_ON(!list_empty(&vmo->shdw_list)); + BUG_ON(!list_empty(&vmo->link_list)); + BUG_ON(!list_empty(&vmo->page_cache)); + BUG_ON(!list_empty(&vmo->shref)); + + /* Obtain and free via the base object */ + if (vmo->flags & VM_OBJ_FILE) { + f = vm_object_to_file(vmo); + BUG_ON(!list_empty(&f->list)); + if (f->priv_data) { + if (f->destroy_priv_data) + f->destroy_priv_data(f); + else + kfree(f->priv_data); + } + kfree(f); + } else if (vmo->flags & VM_OBJ_SHADOW) + kfree(vmo); + else BUG(); + + return 0; +} + +int vm_file_delete(struct vm_file *f) +{ + /* Delete file via base object */ + return vm_object_delete(&f->vm_obj); +} + diff --git a/conts/posix/mm0/tests/idpool_test/bit.c b/conts/posix/mm0/tests/idpool_test/bit.c new file mode 100644 index 0000000..df456d4 --- /dev/null +++ b/conts/posix/mm0/tests/idpool_test/bit.c @@ -0,0 +1,98 @@ +/* + * Bit manipulation functions. + * + * Copyright (C) 2007 Bahadir Balban + */ +#include "bit.h" +#include + +/* Emulation of ARM's CLZ (count leading zeroes) instruction */ +unsigned int __clz(unsigned int bitvector) +{ + unsigned int x = 0; + while((!(bitvector & ((unsigned)1 << 31))) && (x < 32)) { + bitvector <<= 1; + x++; + } + return x; +} + +int find_and_set_first_free_bit(u32 *word, unsigned int limit) +{ + int success = 0; + int i; + + for(i = 0; i < limit; i++) { + /* Find first unset bit */ + if (!(word[BITWISE_GETWORD(i)] & BITWISE_GETBIT(i))) { + /* Set it */ + word[BITWISE_GETWORD(i)] |= BITWISE_GETBIT(i); + success = 1; + break; + } + } + + /* Return bit just set */ + if (success) + return i; + else + return -1; +} + +int find_and_set_first_free_contig_bits(u32 *word, unsigned int limit, + int nbits) +{ + int i = 0, first = 0, last = 0, found = 0; + + /* Can't allocate more than the limit */ + if (nbits > limit) + return -1; + + /* This is a state machine that checks n contiguous free bits. */ + while (i < limit) { + first = i; + last = i; + while (!(word[BITWISE_GETWORD(last)] & BITWISE_GETBIT(last))) { + last++; + i++; + if (last == first + nbits) { + found = 1; + break; + } + if (i == limit) + break; + } + if (found) + break; + i++; + } + + /* If found, set the bits */ + if (found) { + for (int x = first; x < first + nbits; x++) + word[BITWISE_GETWORD(x)] |= BITWISE_GETBIT(x); + return first; + } else + return -1; +} + +int check_and_clear_bit(u32 *word, int bit) +{ + /* Check that bit was set */ + if (word[BITWISE_GETWORD(bit)] & BITWISE_GETBIT(bit)) { + word[BITWISE_GETWORD(bit)] &= ~BITWISE_GETBIT(bit); + return 0; + } else { + printf("Trying to clear already clear bit\n"); + return -1; + } +} + +int check_and_clear_contig_bits(u32 *word, int first, int nbits) +{ + for (int i = first; i < first + nbits; i++) + if (check_and_clear_bit(word, i) < 0) + return -1; + return 0; +} + diff --git a/conts/posix/mm0/tests/idpool_test/bit.h b/conts/posix/mm0/tests/idpool_test/bit.h new file mode 100644 index 0000000..6a9facb --- /dev/null +++ b/conts/posix/mm0/tests/idpool_test/bit.h @@ -0,0 +1,51 @@ +#ifndef __LIB_BIT_H__ +#define __LIB_BIT_H__ + +/* Minimum excess needed for word alignment */ +#define SZ_WORD sizeof(unsigned int) +#define WORD_BITS 32 +#define WORD_BITS_LOG2 5 +#define BITWISE_GETWORD(x) ((x) >> WORD_BITS_LOG2) /* Divide by 32 */ +#define BITWISE_GETBIT(x) (1 << ((x) % WORD_BITS)) + + +typedef unsigned int u32; + +unsigned int __clz(unsigned int bitvector); +int find_and_set_first_free_bit(u32 *word, unsigned int lastbit); +int check_and_clear_bit(u32 *word, int bit); + +int check_and_clear_contig_bits(u32 *word, int first, int nbits); + +int find_and_set_first_free_contig_bits(u32 *word, unsigned int limit, + int nbits); +/* Set */ +static inline void setbit(unsigned int *w, unsigned int flags) +{ + *w |= flags; +} + + +/* Clear */ +static inline void clrbit(unsigned int *w, unsigned int flags) +{ + *w &= ~flags; +} + +/* Test */ +static inline int tstbit(unsigned int *w, unsigned int flags) +{ + return *w & flags; +} + +/* Test and clear */ +static inline int tstclr(unsigned int *w, unsigned int flags) +{ + int res = tstbit(w, flags); + + clrbit(w, flags); + + return res; +} + +#endif /* __LIB_BIT_H__ */ diff --git a/conts/posix/mm0/tests/idpool_test/idpool.c b/conts/posix/mm0/tests/idpool_test/idpool.c new file mode 100644 index 0000000..6a89c8e --- /dev/null +++ b/conts/posix/mm0/tests/idpool_test/idpool.c @@ -0,0 +1,63 @@ +/* + * Used for thread and space ids. + * + * Copyright (C) 2007 Bahadir Balban + */ +#include "idpool.h" +#include +#include + +struct id_pool *id_pool_new_init(int totalbits) +{ + int nwords = BITWISE_GETWORD(totalbits); + struct id_pool *new = calloc(1, (nwords * SZ_WORD) + + sizeof(struct id_pool)); + new->nwords = nwords; + return new; +} + +int id_new(struct id_pool *pool) +{ + int id = find_and_set_first_free_bit(pool->bitmap, + pool->nwords * WORD_BITS); + if (id < 0) + printf("%s: Warning! New id alloc failed\n", __FUNCTION__); + return id; +} + +/* This finds n contiguous free ids, allocates and returns the first one */ +int ids_new_contiguous(struct id_pool *pool, int numids) +{ + printf("%s: Enter\n", __FUNCTION__); + int id = find_and_set_first_free_contig_bits(pool->bitmap, + pool->nwords *WORD_BITS, + numids); + if (id < 0) + printf("%s: Warning! New id alloc failed\n", __FUNCTION__); + return id; +} + +/* This deletes a list of contiguous ids given the first one and number of ids */ +int ids_del_contiguous(struct id_pool *pool, int first, int numids) +{ + int ret; + printf("bits: %d, first +nids: %d\n", pool->nwords *WORD_BITS, first+numids); + if (pool->nwords * WORD_BITS < first + numids) + return -1; + if ((ret = check_and_clear_contig_bits(pool->bitmap, first, numids))) + printf("Warning!!!\n"); + return ret; +} + +int id_del(struct id_pool *pool, int id) +{ + int ret; + + if (pool->nwords * WORD_BITS < id) + return -1; + + if ((ret = check_and_clear_bit(pool->bitmap, id) < 0)) + printf("Warning!!!\n"); + return ret; +} + diff --git a/conts/posix/mm0/tests/idpool_test/idpool.h b/conts/posix/mm0/tests/idpool_test/idpool.h new file mode 100644 index 0000000..d7990f1 --- /dev/null +++ b/conts/posix/mm0/tests/idpool_test/idpool.h @@ -0,0 +1,17 @@ +#ifndef __MM0_IDPOOL_H__ +#define __MM0_IDPOOL_H__ + +#include "bit.h" + +struct id_pool { + int nwords; + u32 bitmap[]; +}; + +struct id_pool *id_pool_new_init(int mapsize); +int id_new(struct id_pool *pool); +int id_del(struct id_pool *pool, int id); + +int ids_new_contiguous(struct id_pool *pool, int numids); +int ids_del_contiguous(struct id_pool *pool, int first, int numids); +#endif /* __MM0_IDPOOL_H__ */ diff --git a/conts/posix/mm0/tests/idpool_test/main.c b/conts/posix/mm0/tests/idpool_test/main.c new file mode 100644 index 0000000..eda52b7 --- /dev/null +++ b/conts/posix/mm0/tests/idpool_test/main.c @@ -0,0 +1,58 @@ + + + +#include "bit.h" +#include "idpool.h" +#include + +#define CTOTAL 3 + +int main(int argc, char *argv[]) +{ + struct id_pool *pool = id_pool_new_init(64); + int id_array[64]; + int first; + + + if ((first = ids_new_contiguous(pool, 64)) < 0) + printf("%d contig ids not allocated.\n", 64); + else + printf("%d contig ids allocated starting from %d\n", 64, first); + + if (ids_del_contiguous(pool, 5, 60) == 0) + printf("%d contig ids freed with success.\n", 64); + else + printf("%d-%d contig ids could not be freed\n", 1, 65); + return 0; +} +/* +int main(int argc, char *argv[]) +{ + struct id_pool *pool = id_pool_new_init(64); + int id_array[64]; + int first; + + + for (int i = 0; i < 64; i++) { + id_array[i] = id_new(pool); + printf("Allocated id: %d\n", id_array[i]); + } + if ((first = ids_new_contiguous(pool, CTOTAL)) < 0) + printf("%d contig ids not allocated as expected.\n", CTOTAL); + + printf("Now freeing id_array[30 - 32]\n"); + ids_del_contiguous(pool, id_array[30], 3); + ids_del_contiguous(pool, id_array[35], 9); + if ((first = ids_new_contiguous(pool, CTOTAL + 3)) < 0) + printf("%d contig ids not allocated.\n", CTOTAL + 3); + else + printf("%d contig ids allocated starting from %d\n", CTOTAL + 3, first); + + if ((first = ids_new_contiguous(pool, CTOTAL)) < 0) + printf("Error: %d contig ids not allocated.\n", CTOTAL); + else + printf("%d contig ids allocated as expected starting from %d\n", CTOTAL, first); + + return 0; +} +*/ diff --git a/conts/posix/mm0/tools/generate_bootdesc.py b/conts/posix/mm0/tools/generate_bootdesc.py new file mode 100755 index 0000000..fcd8e89 --- /dev/null +++ b/conts/posix/mm0/tools/generate_bootdesc.py @@ -0,0 +1,28 @@ +#!/usr/bin/python +import os +import sys + +compiler_prefix = "arm-none-linux-gnueabi-" +objdump = "objdump" +command = "-t" +image_name = "inittask.axf" +linkoutput_file_suffix = "-linkinfo.txt" +linkoutput_file = image_name + linkoutput_file_suffix + +def generate_bootdesc(): + command = compiler_prefix + objdump + " -t " + image_name + " > " + linkoutput_file + print command + os.system(command) + f = open(linkoutput_file, "r") + + while True: + line = f.readline() + if len(line) is 0: + break + if "_start" in line or "_end" in line: + print line + f.close() + +if __name__ == "__main__": + generate_bootdesc() + diff --git a/conts/posix/test0/SConscript b/conts/posix/test0/SConscript new file mode 100644 index 0000000..bdcdfa6 --- /dev/null +++ b/conts/posix/test0/SConscript @@ -0,0 +1,26 @@ + +Import('config', 'environment', 'contid') + +import os, sys + +arch = config.arch + +src = [Glob('*.[cS]') + Glob('src/*.c') + Glob('src/arch/arm/*.c')] + +env = environment.Clone() +test_env = environment.Clone() + +env.Append(LIBS = 'posix') +env.Append(LINKFLAGS = ['-T' + "test0/include/linker.lds", '-u_start']) +env.Append(CPPFLAGS = ' -D__USERSPACE__') +objs = env.Object(src) +test0 = env.Program('test0.elf', objs) + +test_env.Append(LINKFLAGS = ['-T' + "test0/include/test_exec_linker.lds", '-u_start']) +test_env.Append(CPPFLAGS = ' -D__USERSPACE__') +test_src = Glob('src/test_exec/*.[cS]') +test_objs = test_env.Object(test_src) +test_exec = test_env.Program('test_exec.elf', test_objs) +env.Depends(test0, test_exec) + +Return('test0') diff --git a/conts/posix/test0/SConstruct b/conts/posix/test0/SConstruct new file mode 100644 index 0000000..8be9ec7 --- /dev/null +++ b/conts/posix/test0/SConstruct @@ -0,0 +1,109 @@ +# +# User space application build script +# +# Copyright (C) 2007 Bahadir Balban +# +import os +import sys +import shutil +from os.path import join +from glob import glob + +task_name = "test0" + +# The root directory of the repository where this file resides: +project_root = "../.." +tools_root = join(project_root, "tools") +prev_image = join(project_root, "tasks/fs0/fs0.axf") +libs_path = join(project_root, "libs") +ld_script = "include/linker.lds" +physical_base_ld_script = "include/physical_base.lds" + +# Libc situation: +# Libposix has uClibc (and therefore posix) headers. +# NICTA libc implements printf for us for now. +# Libposix implements posix calls for us, e.g. mmap. +# In conclusion nicta libc and libposix complement each other +# they should not clash. In future libposix will be part of uclibc +# and uclibc will be used. + +# libc paths: +libc_variant = "userspace" +libc_libpath = join(libs_path, "c/build/%s" % libc_variant) +libc_incpath = join(libc_libpath, "include") +libc_crt0 = join(libs_path, "c/build/crt/sys-userspace/arch-arm/crt0.o") +libc_name = "c-%s" % libc_variant + +# libposix paths: +libposix_libpath = "../libposix" +libposix_incpath = "../libposix/include/posix" + +# libl4 paths: +libl4_path = "../libl4" +libl4_incpath = join(libl4_path, "include") + +# kernel paths: +kernel_incpath = join(project_root, "include") + +# If crt0 is in its library path, it becomes hard to link with it. +# For instance the linker script must use an absolute path for it. +def copy_crt0(source, target, env): + os.system("cp " + str(source[0]) + " " + str(target[0])) + +def get_physical_base(source, target, env): + os.system(join(tools_root, "pyelf/readelf.py --first-free-page " + \ + prev_image + " >> " + physical_base_ld_script)) + +# The kernel build environment: +env = Environment(CC = 'arm-none-linux-gnueabi-gcc', + # We don't use -nostdinc because sometimes we need standard headers, + # such as stdarg.h e.g. for variable args, as in printk(). + CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', '-Werror'], + LINKFLAGS = ['-nostdlib', '-T' + ld_script, "-L" + libc_libpath, "-L" + libl4_path, \ + '-L' + libposix_libpath], + ASFLAGS = ['-D__ASSEMBLY__'], + PROGSUFFIX = '.axf', # The suffix to use for final executable + ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path + LIBS = [libc_name, 'gcc', libc_name, 'libl4', 'libposix', libc_name], + CPPFLAGS = "-D__USERSPACE__", + CPPPATH = ['#include', libl4_incpath, libposix_incpath, kernel_incpath]) + + +test_exec_ld_script = "include/test_exec_linker.lds" +# The kernel build environment: +test_exec_env = Environment(CC = 'arm-none-linux-gnueabi-gcc', + # We don't use -nostdinc because sometimes we need standard headers, + # such as stdarg.h e.g. for variable args, as in printk(). + CCFLAGS = ['-O3', '-nostdlib', '-ffreestanding', '-std=gnu99', '-Wall', '-Werror'], + LINKFLAGS = ['-nostdlib', '-T' + test_exec_ld_script, "-L" + libc_libpath, "-L" + libl4_path, \ + '-L' + libposix_libpath], + ASFLAGS = ['-D__ASSEMBLY__'], + PROGSUFFIX = '.axf', # The suffix to use for final executable + ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path + LIBS = [libc_name, 'gcc', libc_name, 'libl4', 'libposix', libc_name], + CPPFLAGS = "-D__USERSPACE__", + CPPPATH = ['#include', libl4_incpath, libposix_incpath, kernel_incpath]) + +src = [glob("src/*.c"), glob("*.c"), glob("*.S"), glob("src/arch/arm/*.c"), glob("../libcont/*.c")] +objs = env.Object(src) +physical_base = env.Command(physical_base_ld_script, prev_image, get_physical_base) +crt0_copied = env.Command("crt0.o", libc_crt0, copy_crt0) + +test_exec_src = [glob("src/test_exec/*.c")] +test_exec_objs = test_exec_env.Object(test_exec_src) +test_exec_name = "test_exec" +test_exec = test_exec_env.Program(test_exec_name, test_exec_objs + [crt0_copied]) +test_exec_env.Alias(test_exec_name, test_exec) + +env.Depends(objs, test_exec) +task = env.Program(task_name, objs + [crt0_copied]) +env.Alias(task_name, task) + +# I find this to be a BUG related to SCons. SCons is still good compared to +# notoriously horrible makefiles, but it could have been better. +# if test_exec doesn't depend on physical_base, test_exec is compiled but +# task complains that physical_base is not there. However we already declared +# its dependency below. + +env.Depends(test_exec, physical_base) +env.Depends(task, physical_base) diff --git a/conts/posix/test0/container.c b/conts/posix/test0/container.c new file mode 100644 index 0000000..2e145e3 --- /dev/null +++ b/conts/posix/test0/container.c @@ -0,0 +1,25 @@ +/* + * Container entry point for this task. + * + * Copyright (C) 2007-2009 Bahadir Bilgehan Balban + */ + +#include +#include +#include +#include /* Initialisers for posix library */ + +void main(void); + +void __container_init(void) +{ + /* Generic L4 thread initialisation */ + __l4_init(); + + /* Initialise posix library for application */ + libposix_init(); + + /* Entry to main */ + main(); +} + diff --git a/conts/posix/test0/include/linker.lds b/conts/posix/test0/include/linker.lds new file mode 100644 index 0000000..e2edf97 --- /dev/null +++ b/conts/posix/test0/include/linker.lds @@ -0,0 +1,44 @@ +/* + * Simple linker script for userspace or svc tasks. + * + * Copyright (C) 2007 Bahadir Balban + */ + +/* + * The only catch with this linker script is that everything + * is linked starting at virtual_base, and loaded starting + * at physical_base. virtual_base is the predefined region + * of virtual memory for userland applications. physical_base + * is determined at build-time, it is one of the subsequent pages + * that come after the kernel image's load area. + */ +/* USER_AREA_START, see memlayout.h */ +virtual_base = 0x10000000; +physical_base = 0x8000; +__stack = (0x20000000 - 0x1000 - 8); /* First page before the env/args */ +/* INCLUDE "include/physical_base.lds" */ + +/* physical_base = 0x228000; */ +offset = virtual_base - physical_base; + +ENTRY(_start) + +SECTIONS +{ + . = virtual_base; + _start_text = .; + .text : AT (ADDR(.text) - offset) { *(.text.head) *(.text) } + /* rodata is needed else your strings will link at physical! */ + .rodata : AT (ADDR(.rodata) - offset) { *(.rodata) } + .rodata1 : AT (ADDR(.rodata1) - offset) { *(.rodata1) } + .data : AT (ADDR(.data) - offset) + { + . = ALIGN(4K); + _start_test_exec = .; + *(.testexec) + _end_test_exec = .; + *(.data) + } + .bss : AT (ADDR(.bss) - offset) { *(.bss) } + _end = .; +} diff --git a/conts/posix/test0/include/posix_init.h b/conts/posix/test0/include/posix_init.h new file mode 100644 index 0000000..43a99b2 --- /dev/null +++ b/conts/posix/test0/include/posix_init.h @@ -0,0 +1,7 @@ +#ifndef __LIBPOSIX_INIT_H__ +#define __LIBPOSIX_INIT_H__ + +void libposix_init(void); +void posix_service_init(void); + +#endif /* __LIBPOSIX_INIT_H__ */ diff --git a/conts/posix/test0/include/tests.h b/conts/posix/test0/include/tests.h new file mode 100644 index 0000000..e6e313f --- /dev/null +++ b/conts/posix/test0/include/tests.h @@ -0,0 +1,28 @@ +#ifndef __TEST0_TESTS_H__ +#define __TEST0_TESTS_H__ + +#define __TASKNAME__ "test0" + +//#define TEST_VERBOSE_PRINT +#if defined (TEST_VERBOSE_PRINT) +#define test_printf(...) printf(__VA_ARGS__) +#else +#define test_printf(...) +#endif + +#include +extern pid_t parent_of_all; + +void ipc_full_test(void); +void ipc_extended_test(void); + +int shmtest(void); +int forktest(void); +int mmaptest(void); +int dirtest(void); +int fileio(void); +int clonetest(void); +int exectest(void); +int user_mutex_test(void); + +#endif /* __TEST0_TESTS_H__ */ diff --git a/conts/posix/test0/main.c b/conts/posix/test0/main.c new file mode 100644 index 0000000..34d7d35 --- /dev/null +++ b/conts/posix/test0/main.c @@ -0,0 +1,64 @@ +/* + * Some tests for posix syscalls. + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void wait_pager(l4id_t partner) +{ + // printf("%s: Syncing with pager.\n", __TASKNAME__); + for (int i = 0; i < 6; i++) + write_mr(i, i); + l4_send(partner, L4_IPC_TAG_SYNC); + // printf("Pager synced with us.\n"); +} + +pid_t parent_of_all; + +void main(void) +{ + + printf("\n%s: Started with thread id %d\n", __TASKNAME__, getpid()); + + parent_of_all = getpid(); + + wait_pager(0); + + + printf("\n%s: Running POSIX API tests.\n", __TASKNAME__); + + dirtest(); + + mmaptest(); + + shmtest(); + + forktest(); + + fileio(); + + clonetest(); + + if (parent_of_all == getpid()) { + ipc_full_test(); + ipc_extended_test(); + } + if (parent_of_all == getpid()) { + user_mutex_test(); + } + exectest(); + + while (1) + wait_pager(0); +} + diff --git a/conts/posix/test0/src/clonetest.c b/conts/posix/test0/src/clonetest.c new file mode 100644 index 0000000..a0f50d2 --- /dev/null +++ b/conts/posix/test0/src/clonetest.c @@ -0,0 +1,59 @@ +/* + * Clone test. + */ +#include +#include +#include +#include +#include +#include +#include + +int clone_global = 0; + +extern pid_t parent_of_all; + +int my_thread_func(void *arg) +{ + for (int i = 0; i < 25; i++) + clone_global++; + _exit(0); +} + +int clonetest(void) +{ + pid_t childid; + void *child_stack; + + /* Parent loops and calls clone() to clone new threads. Children don't come back from the clone() call */ + for (int i = 0; i < 4; i++) { + if ((child_stack = mmap(0, 0x1000, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_GROWSDOWN, 0, 0)) == MAP_FAILED) { + test_printf("MMAP failed.\n"); + goto out_err; + } else { + test_printf("Mapped area starting at %p\n", child_stack); + } + ((int *)child_stack)[-1] = 5; /* Test mapped area */ + + test_printf("Cloning...\n"); + + if ((childid = clone(my_thread_func, child_stack, + CLONE_PARENT | CLONE_FS | CLONE_VM | CLONE_THREAD | CLONE_SIGHAND, 0)) < 0) { + test_printf("CLONE failed.\n"); + goto out_err; + } else { + test_printf("Cloned a new thread with child pid %d\n", childid); + } + } + + /* TODO: Add wait() or something similar and check that global is 100 */ + + if (getpid() == parent_of_all) + printf("CLONE TEST -- PASSED --\n"); + + return 0; +out_err: + printf("CLONE TEST -- FAILED --\n"); + return 0; +} + diff --git a/conts/posix/test0/src/crt0.S b/conts/posix/test0/src/crt0.S new file mode 100644 index 0000000..9bcb3a8 --- /dev/null +++ b/conts/posix/test0/src/crt0.S @@ -0,0 +1,94 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#ifdef __thumb__ +#define bl blx +#endif + + .section .text.head + .code 32 + .global _start; + .align; +_start: + ldr sp, =__stack + bl platform_init + bl __container_init +1: + b 1b + diff --git a/conts/posix/test0/src/dirtest.c b/conts/posix/test0/src/dirtest.c new file mode 100644 index 0000000..593b44b --- /dev/null +++ b/conts/posix/test0/src/dirtest.c @@ -0,0 +1,210 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DENTS_TOTAL 50 + +void print_fsize(struct stat *s) +{ + printf("%lu", s->st_size); +} + +void print_flink(struct stat *s) +{ + printf("%d", s->st_nlink); +} + +void print_fuser(struct stat *s) +{ + printf("%d", s->st_uid); + printf("%c", ' '); + printf("%c", ' '); + printf("%d", s->st_gid); +} + +void print_ftype(struct stat *s) +{ + unsigned int type = s->st_mode & S_IFMT; + + if (type == S_IFDIR) + printf("%c", 'd'); + else if (type == S_IFSOCK) + printf("%c", 's'); + else if (type == S_IFCHR) + printf("%c", 'c'); + else if (type == S_IFLNK) + printf("%c", 'l'); + else if (type == S_IFREG) + printf("%c", '-'); +} + +void print_fperm(struct stat *s) +{ + if (s->st_mode & S_IRUSR) + printf("%c", 'r'); + else + printf("%c", '-'); + if (s->st_mode & S_IWUSR) + printf("%c", 'w'); + else + printf("%c", '-'); + if (s->st_mode & S_IXUSR) + printf("%c", 'x'); + else + printf("%c", '-'); +} + +void print_fstat(struct stat *s) +{ + print_ftype(s); + print_fperm(s); + printf("%c", ' '); + printf("%c", ' '); + print_fsize(s); + printf("%c", ' '); +} + +void print_dirents(char *path, void *buf, int cnt) +{ + int i = 0; + struct dirent *dp = buf; + // struct stat statbuf; + char pathbuf[256]; + + strncpy(pathbuf, path, 256); + while (cnt > 0) { + strcpy(pathbuf, path); + strcpy(&pathbuf[strlen(pathbuf)],"/"); + strcpy(&pathbuf[strlen(pathbuf)],dp->d_name); + //printf("Dirent %d:\n", i); + //printf("Inode: %d\n", dp->d_ino); + //printf("Offset: %d\n", dp->d_off); + //printf("Reclen: %d\n", dp->d_reclen); + //if (stat(pathbuf, &statbuf) < 0) + // perror("STAT"); + // print_fstat(&statbuf); + test_printf("%s\n", dp->d_name); + cnt -= dp->d_reclen; + dp = (struct dirent *)((void *)dp + dp->d_reclen); + i++; + } +} + +int lsdir(char *path) +{ + struct dirent dents[DENTS_TOTAL]; + int bytes; + int fd; + + memset(dents, 0, sizeof(struct dirent) * DENTS_TOTAL); + + if ((fd = open(path, O_RDONLY)) < 0) { + test_printf("OPEN failed.\n"); + return -1; + } else + test_printf("Got fd: %d for opening %s\n", fd, path); + + if ((bytes = os_readdir(fd, dents, sizeof(struct dirent) * DENTS_TOTAL)) < 0) { + test_printf("GETDENTS error: %d\n", bytes); + return -1; + } else { + print_dirents(path, dents, bytes); + } + + return 0; +} + +int dirtest(void) +{ + if (lsdir(".") < 0) { + test_printf("lsdir failed.\n"); + goto out_err; + } + if (lsdir("/") < 0) { + test_printf("lsdir failed.\n"); + goto out_err; + } + + test_printf("\nCreating directories: usr, etc, tmp, var, home, opt, bin, boot, lib, dev\n"); + if (mkdir("/usr", 0) < 0) { + test_printf("MKDIR: %d\n", errno); + goto out_err; + } + if (mkdir("/etc", 0) < 0) { + test_printf("MKDIR: %d\n", errno); + goto out_err; + } + if (mkdir("/tmp", 0) < 0) { + test_printf("MKDIR: %d\n", errno); + goto out_err; + } + if (mkdir("/var", 0) < 0) { + test_printf("MKDIR: %d\n", errno); + goto out_err; + } + if (mkdir("/bin", 0) < 0) { + test_printf("MKDIR: %d\n", errno); + goto out_err; + } + if (mkdir("/boot", 0) < 0) { + test_printf("MKDIR: %d\n", errno); + goto out_err; + } + if (mkdir("/lib", 0) < 0) { + test_printf("MKDIR: %d\n", errno); + goto out_err; + } + if (mkdir("/dev", 0) < 0) { + test_printf("MKDIR: %d\n", errno); + goto out_err; + } + if (mkdir("/usr/bin", 0) < 0) { + test_printf("MKDIR: %d\n", errno); + goto out_err; + } + if (mkdir("/home/", 0) < 0) { + test_printf("MKDIR: %d\n", errno); + goto out_err; + } + if (mkdir("/home/bahadir", 0) < 0) { + test_printf("MKDIR: %d\n", errno); + goto out_err; + } + if (chdir("/home/bahadir") < 0) { + test_printf("MKDIR: %d\n", errno); + goto out_err; + } + test_printf("Changed curdir to /home/bahadir\n"); + + test_printf("\nlsdir root directory:\n"); + if (lsdir("/") < 0) + goto out_err; + + test_printf("\nlsdir /usr:\n"); + if (lsdir("/usr") < 0) + goto out_err; + + test_printf("\nlsdir current directory:\n"); + if (lsdir(".") < 0) + goto out_err; + test_printf("\nlsdir /usr/./././bin//\n"); + if (lsdir("/usr/./././bin//") < 0) + goto out_err; + + printf("DIR TEST -- PASSED --\n"); + return 0; + +out_err: + printf("DIR TEST -- FAILED --\n"); + return 0; +} + diff --git a/conts/posix/test0/src/exectest.c b/conts/posix/test0/src/exectest.c new file mode 100644 index 0000000..9b9d945 --- /dev/null +++ b/conts/posix/test0/src/exectest.c @@ -0,0 +1,76 @@ +/* + * Execve test. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +extern char _start_test_exec[]; +extern char _end_test_exec[]; + +int exectest(void) +{ + int fd, err; + void *exec_start = (void *)_start_test_exec; + unsigned long size = _end_test_exec - _start_test_exec; + int left, cnt; + char *argv[5]; + char filename[128]; + + memset(filename, 0, 128); + sprintf(filename, "/home/bahadir/execfile%d", getpid()); + + /* First create a new file and write the executable data to that file */ + if ((fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU)) < 0) { + err = errno; + test_printf("OPEN: %d, for %s\n", errno, filename); + /* If it is a minor error like EEXIST, create one with different name */ + if (errno == EEXIST) { + sprintf(filename, "/home/bahadir/execfile%d-2", + getpid()); + if ((fd = open(filename, + O_RDWR | O_CREAT | O_TRUNC, S_IRWXU)) + < 0) { + printf("OPEN: %d, failed twice, " + "last time for %s\n", + errno, filename); + goto out_err; + } + } else + goto out_err; + } + + left = size; + test_printf("Writing %d bytes to %s\n", left, filename); + while (left != 0) { + if ((cnt = write(fd, exec_start, left)) < 0) + goto out_err; + left -= cnt; + } + + if ((err = close(fd)) < 0) { + goto out_err; + } + + /* Set up some arguments */ + argv[0] = "FIRST ARG"; + argv[1] = "SECOND ARG"; + argv[2] = "THIRD ARG"; + argv[3] = "FOURTH ARG"; + argv[4] = 0; + + /* Execute the file */ + err = execve(filename, argv, 0); + +out_err: + printf("EXECVE failed with %d\n", err); + printf("EXECVE TEST -- FAILED --\n"); + return 0; +} + diff --git a/conts/posix/test0/src/fileio.c b/conts/posix/test0/src/fileio.c new file mode 100644 index 0000000..b5aabe3 --- /dev/null +++ b/conts/posix/test0/src/fileio.c @@ -0,0 +1,92 @@ + +#include +#include +#include +#include +#include +#include +#include +#include + +int fileio(void) +{ + int fd; + ssize_t cnt; + int err; + char buf[128]; + off_t offset; + int tid = getpid(); + char *str = "I WROTE TO THIS FILE\n"; + char filename[128]; + + memset(buf, 0, 128); + memset(filename, 0, 128); + sprintf(filename, "/home/bahadir/newfile%d.txt", tid); + if ((fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU)) < 0) { + test_printf("OPEN: %d", errno); + goto out_err; + } + test_printf("%d: Created %s\n", tid, filename); + + test_printf("%d: write.\n", tid); + if ((int)(cnt = write(fd, str, strlen(str))) < 0) { + test_printf("WRITE: %d", errno); + goto out_err; + } + + test_printf("%d: lseek.\n", tid); + if ((int)(offset = lseek(fd, 0, SEEK_SET)) < 0) { + test_printf("LSEEK: %d", errno); + goto out_err; + } + test_printf("%d: read.\n", tid); + if ((int)(cnt = read(fd, buf, strlen(str))) < 0) { + test_printf("READ: %d", errno); + goto out_err; + } + + test_printf("%d: Read: %d bytes from file.\n", tid, cnt); + if (cnt) { + test_printf("%d: Read string: %s\n", tid, buf); + if (strcmp(buf, str)) { + test_printf("Strings not the same:\n"); + test_printf("Str: %s\n", str); + test_printf("Buf: %s\n", buf); + goto out_err; + } + } + + if ((err = close(fd)) < 0) { + test_printf("CLOSE: %d", errno); + goto out_err; + } + + if (getpid() == parent_of_all) + printf("FILE IO TEST -- PASSED --\n"); + return 0; + +out_err: + printf("FILE IO TEST -- FAILED --\n"); + return 0; +} + +#if defined(HOST_TESTS) +int main(void) +{ + test_printf("File IO test 1:\n"); + if (fileio() == 0) + test_printf("-- PASSED --\n"); + else + test_printf("-- FAILED --\n"); + + test_printf("File IO test 2:\n"); + if (fileio2() == 0) + test_printf("-- PASSED --\n"); + else + test_printf("-- FAILED --\n"); + + + return 0; +} +#endif + diff --git a/conts/posix/test0/src/forktest.c b/conts/posix/test0/src/forktest.c new file mode 100644 index 0000000..204b83e --- /dev/null +++ b/conts/posix/test0/src/forktest.c @@ -0,0 +1,55 @@ +/* + * Fork test. + */ + +#include +#include +#include +#include +#include + +int global = 0; + + +int forktest(void) +{ + pid_t myid; + + + /* 16 forks */ + for (int i = 0; i < 4; i++) { + test_printf("%d: Forking...\n", getpid()); + if (fork() < 0) + goto out_err; + } + + myid = getpid(); + + if (global != 0) { + test_printf("Global not zero.\n"); + test_printf("-- FAILED --\n"); + goto out_err; + } + global += myid; + + if (global != myid) + goto out_err; + + + if (getpid() != parent_of_all) { + /* Exit here to exit successful children */ + //_exit(0); + //BUG(); + } + + if (getpid() == parent_of_all) + printf("FORK TEST -- PASSED --\n"); + + return 0; + + /* Any erroneous child or parent comes here */ +out_err: + printf("FORK TEST -- FAILED --\n"); + return 0; +} + diff --git a/conts/posix/test0/src/ipctest.c b/conts/posix/test0/src/ipctest.c new file mode 100644 index 0000000..150b016 --- /dev/null +++ b/conts/posix/test0/src/ipctest.c @@ -0,0 +1,152 @@ +/* + * Tests for more complex ipc such as full and extended + * + * Copyright (C) 2007-2009 Bahadir Bilgehan Balban + */ +#include +#include +#include +#include +#include +#include +#include + +/* + * Full ipc test. Sends/receives full utcb, done with the pager. + */ +void ipc_full_test(void) +{ + int ret = 0; + + /* Fill in all of the utcb locations */ + for (int i = MR_UNUSED_START; i < MR_TOTAL + MR_REST; i++) { + //printf("Writing: MR%d: %d\n", i, i); + write_mr(i, i); + } + + /* Call the pager */ + if ((ret = l4_sendrecv_full(PAGER_TID, PAGER_TID, + L4_IPC_TAG_SYNC_FULL)) < 0) { + printf("%s: Failed with %d\n", __FUNCTION__, ret); + BUG(); + } + /* Read back updated utcb */ + for (int i = MR_UNUSED_START; i < MR_TOTAL + MR_REST; i++) { + //printf("Read MR%d: %d\n", i, read_mr(i)); + if (read_mr(i) != 0) { + printf("Expected 0 on all mrs. Failed.\n"); + BUG(); + } + } + + if (!ret) + printf("FULL IPC TEST: -- PASSED --\n"); + else + printf("FULL IPC TEST: -- FAILED --\n"); +} + +/* + * This is an extended ipc test that is done between 2 tasks that fork. + */ +void ipc_extended_test(void) +{ + pid_t child, parent; + void *base; + char *ipcbuf; + int err; + + /* Get parent pid */ + parent = getpid(); + + /* Fork the current task */ + if ((child = fork()) < 0) { + test_printf("%s: Fork failed with %d\n", __FUNCTION__, errno); + goto out_err; + } + if (child) + test_printf("%d: Created child with pid %d\n", getpid(), child); + else + test_printf("Child %d running.\n", getpid()); + + /* This test makes this assumption */ + BUG_ON(L4_IPC_EXTENDED_MAX_SIZE > PAGE_SIZE); + + /* + * Both child and parent gets 2 pages + * of privately mapped anonymous memory + */ + if ((int)(base = mmap(0, PAGE_SIZE*2, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, 0, 0)) < 0) { + printf("%s: mmap for extended ipc buffer failed: %d\n", + __FUNCTION__, (int)base); + goto out_err; + } else + test_printf("%s: mmap: Anonymous private buffer at %p\n", + __FUNCTION__, base); + + /* + * Both tasks read/write both pages + * across the page boundary for messages + */ + ipcbuf = base + PAGE_SIZE - L4_IPC_EXTENDED_MAX_SIZE / 2; + + /* Child sending message */ + if (child == 0) { + /* Child creates a string of maximum extended ipc size */ + for (int i = 0; i < L4_IPC_EXTENDED_MAX_SIZE; i++) { + ipcbuf[i] = 'A' + i % 20; + } + /* Finish string with newline and null pointer */ + ipcbuf[L4_IPC_EXTENDED_MAX_SIZE - 2] = '\n'; + ipcbuf[L4_IPC_EXTENDED_MAX_SIZE - 1] = '\0'; + + /* Send message to parent */ + test_printf("Child sending message: %s\n", ipcbuf); + if ((err = l4_send_extended(parent, L4_IPC_TAG_SYNC_EXTENDED, + L4_IPC_EXTENDED_MAX_SIZE, + ipcbuf)) < 0) { + printf("Extended ipc error: %d\n", err); + goto out_err; + } + + /* Parent receiving message */ + } else { + /* + * Parent receives on the buffer - we are sure that the + * buffer is not paged in because we did not touch it. + * This should prove that page faults are handled during + * the ipc. + */ + test_printf("Parent: extended receiving from child.\n"); + if ((err = l4_receive_extended(child, L4_IPC_EXTENDED_MAX_SIZE, + ipcbuf)) < 0) { + printf("Extended ipc error: %d\n", err); + goto out_err; + } + + /* We now print the message created by child. */ + test_printf("(%d): Message received from child: %s\n", + getpid(), ipcbuf); + + /* Check that string received from child is an exact match */ + for (int i = 0; i < L4_IPC_EXTENDED_MAX_SIZE - 2; i++) { + if (ipcbuf[i] != ('A' + i % 20)) + goto out_err; + } + if (ipcbuf[L4_IPC_EXTENDED_MAX_SIZE - 2] != '\n') + goto out_err; + if (ipcbuf[L4_IPC_EXTENDED_MAX_SIZE - 1] != '\0') + goto out_err; + + printf("EXTENDED IPC TEST: -- PASSED --\n"); + } + return; + +out_err: + printf("EXTENDED IPC TEST: -- FAILED --\n"); +} + + + + + diff --git a/conts/posix/test0/src/mmaptest.c b/conts/posix/test0/src/mmaptest.c new file mode 100644 index 0000000..5ff6230 --- /dev/null +++ b/conts/posix/test0/src/mmaptest.c @@ -0,0 +1,56 @@ +/* + * Test mmap/munmap posix calls. + * + * Copyright (C) 2007, 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PAGE_SIZE 0x1000 + +int mmaptest(void) +{ + int fd; + void *base; + int x = 0x1000; + + if ((fd = open("./mmapfile.txt", O_CREAT | O_TRUNC | O_RDWR, S_IRWXU)) < 0) + goto out_err; + + /* Extend the file */ + if ((int)lseek(fd, PAGE_SIZE*16, SEEK_SET) < 0) + goto out_err; + + if (write(fd, &x, sizeof(x)) < 0) + goto out_err; + + if ((int)(base = mmap(0, PAGE_SIZE*16, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) < 0) + goto out_err; + + *(unsigned int *)(base + PAGE_SIZE*2) = 0x1000; + if (msync(base + PAGE_SIZE*2, PAGE_SIZE, MS_SYNC) < 0) + goto out_err; + + if (munmap(base + PAGE_SIZE*2, PAGE_SIZE) < 0) + goto out_err; + + *(unsigned int *)(base + PAGE_SIZE*3) = 0x1000; + *(unsigned int *)(base + PAGE_SIZE*1) = 0x1000; + + printf("MMAP TEST -- PASSED --\n"); + return 0; + +out_err: + printf("MMAP TEST -- FAILED --\n"); + return 0; +} + diff --git a/conts/posix/test0/src/mmaptest.c.orig b/conts/posix/test0/src/mmaptest.c.orig new file mode 100644 index 0000000..c5fa918 --- /dev/null +++ b/conts/posix/test0/src/mmaptest.c.orig @@ -0,0 +1,60 @@ +/* + * Test mmap/munmap posix calls. + * + * Copyright (C) 2007 - 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PAGE_SIZE 0x1000 + +int mmaptest(void) +{ + int fd; + void *base; + int x = 0x1000; + + if ((fd = open("./newfile.txt", O_CREAT | O_TRUNC | O_RDWR, S_IRWXU)) < 0) + perror("open:"); + else + printf("open: Success.\n"); + + /* Extend the file */ + if ((int)lseek(fd, PAGE_SIZE*16, SEEK_SET) < 0) + perror("lseek"); + else + printf("lseek: Success.\n"); + + if (write(fd, &x, sizeof(x)) < 0) + perror("write"); + else + printf("write: Success.\n"); + + if ((int)(base = mmap(0, PAGE_SIZE*16, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) < 0) + perror("mmap"); + else + printf("mmap: Success: %p\n", base); + + *(unsigned int *)(base + PAGE_SIZE*2) = 0x1000; + if (msync(base + PAGE_SIZE*2, PAGE_SIZE, MS_SYNC) < 0) + perror("msync"); + else + printf("msync: Success: %p\n", base); + + if (munmap(base + PAGE_SIZE*2, PAGE_SIZE) < 0) + perror("munmap"); + else + printf("munmap: Success: %p\n", base); + *(unsigned int *)(base + PAGE_SIZE*3) = 0x1000; + *(unsigned int *)(base + PAGE_SIZE*1) = 0x1000; + + return 0; +} diff --git a/conts/posix/test0/src/mutextest.c b/conts/posix/test0/src/mutextest.c new file mode 100644 index 0000000..d920c6e --- /dev/null +++ b/conts/posix/test0/src/mutextest.c @@ -0,0 +1,162 @@ +/* + * Tests for userspace mutexes + * + * Copyright (C) 2007-2009 Bahadir Bilgehan Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * This structure is placed at the head of shared memory. + * Tasks lock and write to rest of the page. Indicate that + * they have run, and the later running task tests that both + * processes has run and no data corruption occured on page_rest. + */ +struct shared_page { + struct l4_mutex mutex; + int shared_var; +}; + +static struct shared_page *shared_page; + +/* + * This test forks a parent task, creates a shared memory mapping, and makes two tasks + * lock and write to almost the whole page 10 times with different values, and makes + * the tasks test that the writes are all there without any wrong values. The amount of + * time spent should justify a context switch and demonstrate that lock protects the + * region. + */ +int user_mutex_test(void) +{ + pid_t child, parent; + int map_size = PAGE_SIZE; + void *base; + + /* Get parent pid */ + parent = getpid(); + + + /* + * Create a shared anonymous memory region. This can be + * accessed by both parent and child after a fork. + */ + if ((int)(base = mmap(0, map_size, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_ANONYMOUS, 0, 0)) < 0) { + printf("%s: mmap for extended ipc buffer failed: %d\n", + __FUNCTION__, (int)base); + goto out_err; + } else + test_printf("mmap: Anonymous shared buffer at %p\n", base); + + shared_page = base; + + /* Initialize the mutex */ + l4_mutex_init(&shared_page->mutex); + + /* Initialize the shared variable */ + shared_page->shared_var = 0; + + /* Fork the current task */ + if ((child = fork()) < 0) { + test_printf("%s: Fork failed with %d\n", __FUNCTION__, errno); + goto out_err; + } + + if (child) + test_printf("%d: Created child with pid %d\n", getpid(), child); + else + test_printf("Child %d running.\n", getpid()); + + /* Child locks and produces */ + if (child == 0) { + + for (int x = 0; x < 2000; x++) { + int temp; + + /* Lock page */ + test_printf("Child locking page.\n"); + l4_mutex_lock(&shared_page->mutex); + + /* Read variable */ + test_printf("Child locked page.\n"); + temp = shared_page->shared_var; + + /* Update local copy */ + temp++; + + /* Thread switch */ + l4_thread_switch(0); + + /* Write back the result */ + shared_page->shared_var = temp; + + test_printf("Child modified. Unlocking...\n"); + + /* Unlock */ + l4_mutex_unlock(&shared_page->mutex); + test_printf("Child unlocked page.\n"); + + /* Thread switch */ + l4_thread_switch(0); + + } + /* Sync with the parent */ + l4_send(parent, L4_IPC_TAG_SYNC); + + /* Parent locks and consumes */ + } else { + for (int x = 0; x < 2000; x++) { + int temp; + + /* Lock page */ + test_printf("Parent locking page.\n"); + l4_mutex_lock(&shared_page->mutex); + + /* Read variable */ + test_printf("Parent locked page.\n"); + temp = shared_page->shared_var; + + /* Update local copy */ + temp--; + + /* Thread switch */ + l4_thread_switch(0); + + /* Write back the result */ + shared_page->shared_var = temp; + + test_printf("Parent modified. Unlocking...\n"); + + /* Unlock */ + l4_mutex_unlock(&shared_page->mutex); + test_printf("Parent unlocked page.\n"); + + /* Thread switch */ + l4_thread_switch(0); + } + /* Sync with the child */ + l4_receive(child); + + test_printf("Parent checking validity of value.\n"); + if (shared_page->shared_var != 0) + goto out_err; + + printf("USER MUTEX TEST: -- PASSED --\n"); + } + return 0; + +out_err: + printf("USER MUTEX TEST: -- FAILED --\n"); + return -1; +} + + + + + diff --git a/conts/posix/test0/src/shmtest.c b/conts/posix/test0/src/shmtest.c new file mode 100644 index 0000000..edf4d11 --- /dev/null +++ b/conts/posix/test0/src/shmtest.c @@ -0,0 +1,71 @@ +/* + * Test shmget/shmat/shmdt posix calls. + * + * Copyright (C) 2007 - 2008 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include + +int shmtest(void) +{ + //key_t keys[2] = { 5, 10000 }; + key_t keys[2] = { 2, 3 }; + void *bases[2] = { 0 , 0 }; + int shmids[2]; + + test_printf("Initiating shmget()\n"); + for (int i = 0; i < 2; i++) { + if ((shmids[i] = shmget(keys[i], 27, IPC_CREAT | 0666)) < 0) { + test_printf("SHMGET", errno); + goto out_err; + } else + test_printf("SHMID returned: %d\n", shmids[i]); + } + test_printf("Now shmat()\n"); + for (int i = 0; i < 2; i++) { + if ((int)(bases[i] = shmat(shmids[i], NULL, 0)) == -1) { + test_printf("SHMAT", errno); + goto out_err; + } else + test_printf("SHM base address returned: %p\n", bases[i]); + } + /* Write to the bases */ + *((unsigned int *)bases[0]) = 0xDEADBEEF; + *((unsigned int *)bases[1]) = 0xFEEDBEEF; + + test_printf("Now shmdt()\n"); + for (int i = 0; i < 2; i++) { + if (shmdt(bases[i]) < 0) { + test_printf("SHMDT", errno); + goto out_err; + } else + test_printf("SHM detached OK.\n"); + } + test_printf("Now shmat() again\n"); + for (int i = 0; i < 2; i++) { + bases[i] = shmat(shmids[i], NULL, 0); + + /* SHMAT should fail since no refs were left in last detach */ + if ((int)bases[i] != -1) { + test_printf("SHM base address returned: %p, " + "but it should have failed\n", bases[i]); + goto out_err; + } + } + + if (getpid() == parent_of_all) + printf("SHM TEST -- PASSED --\n"); + + return 0; + +out_err: + printf("SHM TEST -- FAILED --\n"); + return 0; + +} diff --git a/conts/posix/test0/src/test_exec/container.c b/conts/posix/test0/src/test_exec/container.c new file mode 100644 index 0000000..2e145e3 --- /dev/null +++ b/conts/posix/test0/src/test_exec/container.c @@ -0,0 +1,25 @@ +/* + * Container entry point for this task. + * + * Copyright (C) 2007-2009 Bahadir Bilgehan Balban + */ + +#include +#include +#include +#include /* Initialisers for posix library */ + +void main(void); + +void __container_init(void) +{ + /* Generic L4 thread initialisation */ + __l4_init(); + + /* Initialise posix library for application */ + libposix_init(); + + /* Entry to main */ + main(); +} + diff --git a/conts/posix/test0/src/test_exec/crt0.S b/conts/posix/test0/src/test_exec/crt0.S new file mode 100644 index 0000000..d28b311 --- /dev/null +++ b/conts/posix/test0/src/test_exec/crt0.S @@ -0,0 +1,94 @@ +/* + * Australian Public Licence B (OZPLB) + * + * Version 1-0 + * + * Copyright (c) 2004 National ICT Australia + * + * All rights reserved. + * + * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS) + * National ICT Australia + * http://www.ertos.nicta.com.au + * + * Permission is granted by National ICT Australia, free of charge, to + * any person obtaining a copy of this software and any associated + * documentation files (the "Software") to deal with the Software without + * restriction, including (without limitation) the rights to use, copy, + * modify, adapt, merge, publish, distribute, communicate to the public, + * sublicense, and/or sell, lend or rent out copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimers. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimers in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of National ICT Australia, nor the names of its + * contributors, may be used to endorse or promote products derived + * from this Software without specific prior written permission. + * + * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT + * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND + * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS, + * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS + * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE, + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, + * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF + * ERRORS, WHETHER OR NOT DISCOVERABLE. + * + * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL + * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL + * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER + * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR + * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS + * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR + * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT, + * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN + * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER + * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS + * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS, + * DAMAGES OR OTHER LIABILITY. + * + * If applicable legislation implies representations, warranties, or + * conditions, or imposes obligations or liability on National ICT + * Australia or one of its contributors in respect of the Software that + * cannot be wholly or partly excluded, restricted or modified, the + * liability of National ICT Australia or the contributor is limited, to + * the full extent permitted by the applicable legislation, at its + * option, to: + * a. in the case of goods, any one or more of the following: + * i. the replacement of the goods or the supply of equivalent goods; + * ii. the repair of the goods; + * iii. the payment of the cost of replacing the goods or of acquiring + * equivalent goods; + * iv. the payment of the cost of having the goods repaired; or + * b. in the case of services: + * i. the supplying of the services again; or + * ii. the payment of the cost of having the services supplied again. + * + * The construction, validity and performance of this licence is governed + * by the laws in force in New South Wales, Australia. + */ + +#ifdef __thumb__ +#define bl blx +#endif + +.section .text.head + .code 32 + .global _start; + .align; +_start: + ldr sp, =__stack + bl platform_init + bl __container_init +1: + b 1b + diff --git a/conts/posix/test0/src/test_exec/test_exec.c b/conts/posix/test0/src/test_exec/test_exec.c new file mode 100644 index 0000000..5e40cb5 --- /dev/null +++ b/conts/posix/test0/src/test_exec/test_exec.c @@ -0,0 +1,36 @@ +/* + * Some tests for posix syscalls. + * + * Copyright (C) 2007 Bahadir Balban + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void wait_pager(l4id_t partner) +{ + // printf("%s: Syncing with pager.\n", __TASKNAME__); + for (int i = 0; i < 6; i++) + write_mr(i, i); + l4_send(partner, L4_IPC_TAG_SYNC); + // printf("Pager synced with us.\n"); +} + +void main(void) +{ + wait_pager(0); + if (getpid() == 2) { + printf("EXECVE TEST -- PASSED --\n"); + printf("\nThread (%d): Continues to sync with the pager...\n\n", getpid()); + while (1) + wait_pager(0); + } + _exit(0); +} + diff --git a/conts/posix/test0/tools/generate_bootdesc.py b/conts/posix/test0/tools/generate_bootdesc.py new file mode 100755 index 0000000..9761a6d --- /dev/null +++ b/conts/posix/test0/tools/generate_bootdesc.py @@ -0,0 +1,27 @@ +#!/usr/bin/python +import os +import sys + +compiler_prefix = "arm-linux-" +objdump = "objdump" +command = "-t" +image_name = "roottask.axf" +linkoutput_file_suffix = "-linkinfo.txt" +linkoutput_file = image_name + linkoutput_file_suffix +def generate_bootdesc(): + command = compiler_prefix + objdump + " -t " + image_name + " > " + linkoutput_file + print command + os.system(command) + f = open(linkoutput_file, "r") + + while True: + line = f.readline() + if len(line) is 0: + break + if "_start" in line or "_end" in line: + print line + f.close() + +if __name__ == "__main__": + generate_bootdesc() +