local-sysdeps

Gbp-Pq: Topic kfreebsd
Gbp-Pq: Name local-sysdeps.diff
This commit is contained in:
Ubuntu Developers 2022-05-13 23:32:09 +08:00 committed by openKylinBot
parent 8318011d28
commit 809409d9a9
454 changed files with 36279 additions and 0 deletions

View File

@ -0,0 +1,29 @@
bits/mcontext.h
bits/stat16.h
fpu.h
machine/pal.h
net/ethernet.h
net/if_arp.h
net/if_ether.h
net/if_dl.h
net/route.h
nfs/nfs.h
regdef.h
sa_len.c
stat16conv.c
statfsconv.c
sys/acl.h
sys/extattr.h
sys/io.h
sys/jail.h
sys/linker.h
sys/mount.h
sys/perm.h
sys/rfork.h
sys/rtprio.h
sys/syslimits.h
sys/timex.h
sys/vm86.h
sys_lseek.S
sysarch.h
ucontext_i.h

View File

@ -0,0 +1,11 @@
# The kernel include files come from the 'kernel-include' add-on.
# This is actually added by configure.in.
#/usr/src/sys/
# One of two possible utmp file formats.
# This is actually added by configure.in.
#unix/bsd/bsd4.4/kfreebsd/utmp-xyz
# The gnu subdirectory exists for things common to Linux-based, Hurd-based
# and kFreeBSD-based GNU systems.
gnu

View File

@ -0,0 +1,138 @@
# Use bash, not /bin/sh, for executing scripts, because the native
# FreeBSD /bin/sh does not interpret the IFS="<tab>" read ... command
# in localedata/tst-fmon.sh correctly.
SHELL = bash
# Additional header files to be installed in $prefix/include:
ifeq ($(subdir),misc)
sysdep_headers += \
kenv.h \
bits/os-unistd.h \
sys/mount.h \
sys/kd.h \
sys/rfork.h
endif
ifeq ($(subdir),stdlib)
sysdep_headers += \
bits/mcontext.h
endif
# Additional functions, and particular system calls:
ifeq ($(subdir),csu)
# For <errno.h>.
sysdep_routines += errno-loc
endif
ifeq ($(subdir),assert)
CFLAGS-assert.c += -DFATAL_PREPARE_INCLUDE='<fatal-prepare.h>'
CFLAGS-assert-perr.c += -DFATAL_PREPARE_INCLUDE='<fatal-prepare.h>'
endif
ifeq ($(subdir),io)
# For <unistd.h>.
sysdep_routines += sys_access sys_faccessat sys_getcwd
# For <fcntl.h>.
sysdep_routines += sys_open sys_openat open_2
# For <sys/stat.h>.
sysdep_routines += sys_fstat sys_fstatat sys_lstat sys_mkfifoat sys_mknod sys_mknodat sys_nfstat sys_nlstat sys_nstat sys_stat lchflags
# For <sys/statfs.h>.
sysdep_routines += fstatfs64 statfs64 sys_fstatfs sys_statfs
# For <sys/times.h>.
sysdep_routines += sys_futimesat
# Other.
sysdep_routines += lchmod
endif
ifeq ($(subdir),dirent)
# For <dirent.h>.
sysdep_routines += sys_getdents sys_getdirentries getdirentries getdirentries64
endif
ifeq ($(subdir),misc)
# For <kenv.h>.
sysdep_routines += kenv
# For <sched.h>.
sysdep_routines += clone start_thread
# For <unistd.h>.
sysdep_routines += getosreldate
# For <sys/acl.h>.
sysdep_routines += acl_aclcheck_fd acl_aclcheck_file acl_delete_fd acl_delete_file acl_get_fd acl_get_file acl_set_fd acl_set_file
# For <sys/extattr.h>.
sysdep_routines += extattrctl extattr_delete_file extattr_get_file extattr_set_file
# For <sys/jail.h>.
sysdep_routines += jail jail_attach jail_remove jail_get jail_set
# For <sys/ktrace.h>.
sysdep_routines += ktrace utrace
# For <sys/linker.h>.
sysdep_routines += kldfind kldfirstmod kldload kldnext kldstat kldsym kldunload kldunloadf
# For <sys/mman.h>.
sysdep_routines += minherit sys_mmap sys_munmap
# For <sys/mount.h>.
sysdep_routines += fhopen sys_fhstat sys_fhstatfs fhstat fhstat64 fhstatfs fhstatfs64 getfh getfsstat getfsstat64 sys_getfsstat getmntinfo getmntinfo64 mount nmount unmount
# For <sys/rfork.h>.
sysdep_routines += rfork
# For <sys/rtprio.h>.
sysdep_routines += rtprio
# For <sys/socket.h>.
sysdep_routines += bsd_sendfile
# For <sys/stat.h>.
sysdep_routines += devname
# For <sys/sysctl.h>.
sysdep_routines += sysctl sysctlbyname sysctlnametomib
# For <sys/uio.h>.
sysdep_routines += sys_readv sys_writev
# Other.
sysdep_routines += swapon swapoff sys_aio_cancel sys_aio_error sys_aio_read sys_aio_return sys_aio_suspend sys_aio_waitcomplete sys_aio_write sys_lio_listio issetugid modfind modfnext modnext modstat obreak quotactl rfork sysarch undelete yield
# for INLINE_SYSCALL
sysdep_routines += sys_fork sys_sigaction sys_close sys_fcntl
sysdep_routines += sys_clock_getres sys_clock_gettime sys_clock_settime
sysdep_routines += sys_ktimer_create sys_ktimer_gettime sys_ktimer_settime sys_ktimer_getoverrun sys_ktimer_delete
sysdep_routines += sys_semctl sys_shmctl sys_msgctl
endif
ifeq ($(subdir),posix)
# For <unistd.h>.
sysdep_routines += sys_getlogin sys_setlogin sys_read sys_write
# for <sched.h>
sysdep_routines += sys_cpuset_getaffinity sys_cpuset_setaffinity
endif
ifeq ($(subdir),inet)
sysdep_headers += net/ethernet.h net/if_ether.h
endif
ifeq ($(subdir),time)
# For <sys/timex.h>.
sysdep_routines += ntp_adjtime ntp_gettime
endif
ifeq ($(subdir),socket)
sysdep_routines += sa_len sys_bind sys_connect sys_sendto
endif
# Linuxthreads dependencies.
ifeq ($(subdir),posix)
sysdep_headers += bits/initspin.h
endif
# Don't compile the ctype glue code, since we have a much better <ctype.h>
# than the old non-GNU C library.
inhibit-glue = yes
# Special ELF hacks.
ifeq ($(subdir),elf)
sysdep-rtld-routines += dl-brk dl-sbrk dl-getcwd dl-openat64
sysdep_routines += sys_umtx
endif
ifeq ($(subdir),sunrpc)
sysdep_headers += nfs/nfs.h
endif
ifeq ($(subdir),rt)
librt-routines += sys_shm_open
endif

View File

@ -0,0 +1,129 @@
libc {
# The comment lines with "#errlist-compat" are magic; see errlist-compat.awk.
# When you get an error from errlist-compat.awk, you need to add a new
# version here. Don't do this blindly, since this means changing the ABI
# for all GNU/kFreeBSD configurations.
GLIBC_2.2.6 {
# c*
clone;
# e*
extattrctl; extattr_delete_file; extattr_get_file; extattr_set_file;
# f*
fhopen; fhstat; fhstatfs; futimes;
# g*
getdents; getfh; getfsstat; getfsstat64; getmntinfo; getmntinfo64;
getresgid; getresuid;
# i*
issetugid;
# j*
jail;
# k*
kldfind; kldfirstmod; kldload; kldnext; kldstat; kldsym; kldunload; kldunloadf;
ktrace;
# l*
lchmod; lutimes;
# m*
minherit; modfind; modfnext; modnext; modstat; mount;
# n*
nmount; ntp_adjtime; ntp_gettime;
# q*
quotactl;
# r*
rfork; rtprio;
# s*
sendfile; setresgid; setresuid; swapoff; swapon; sysarch; sysctl; sysctlbyname;
# u*
undelete; unmount; utrace;
# see <sys/acl.h>.
__acl_aclcheck_fd; __acl_aclcheck_file; __acl_delete_fd; __acl_delete_file;
__acl_get_fd; __acl_get_file; __acl_set_fd; __acl_set_file;
# see <errno.h>.
__errno_location;
# see <sys/sysctl.h>.
__sysctl;
# Questionable system calls. These functions may be removed at any moment.
__syscall_aio_cancel; __syscall_aio_error; __syscall_aio_read;
__syscall_aio_return; __syscall_aio_suspend; __syscall_aio_waitcomplete;
__syscall_aio_write; __syscall_lio_listio;
__syscall_obreak;
__syscall_yield;
}
GLIBC_2.3 {
#errlist-compat 87
_sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
}
GLIBC_2.3.4 {
# f*
fhstat64; fhstatfs64;
kqueue; kevent;
#errlist-compat 93
_sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
# functions used in inline functions or macros
__libc_sa_len;
}
GLIBC_2.10 {
devname;
devname_r;
kenv;
sysctlnametomib;
}
GLIBC_2.11 {
lchflags;
#errlist-compat 94
_sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
}
GLIBC_2.13 {
jail_attach;
jail_remove;
jail_get;
jail_set;
}
GLIBC_2.18 {
msgctl;
semctl;
shmctl;
waitid;
#errlist-compat 97
_sys_errlist; sys_errlist; _sys_nerr; sys_nerr;
}
GLIBC_2.21 {
__statfs;
}
GLIBC_PRIVATE {
# needed by libpthread.
__clone; __libc_fork; __libc_sigaction; __kernel_getosreldate;
# needed by libpthread as INLINE_SYSCALL:
__syscall_fork;
__syscall_open; __syscall_close;
__syscall_read; __syscall_write;
__syscall_wait4; __syscall_fcntl;
# needed by librt as INLINE_SYSCALL:
__syscall_clock_getres; __syscall_clock_gettime; __syscall_clock_settime;
__syscall_ktimer_create; __syscall_ktimer_gettime; __syscall_ktimer_settime; __syscall_ktimer_getoverrun; __syscall_ktimer_delete;
# misc fixes for FreeBSD:
__syscall_connect; __syscall_sendto;
__syscall_cpuset_getaffinity ; __syscall_cpuset_setaffinity;
# global variable used in brk()
_end;
}
}

View File

@ -0,0 +1,26 @@
/* Copyright (C) 1991,92,97,99,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. */
#include <sysdep.h>
PSEUDO (_exit, exit, 1)
/* Shouldn't get here. */
PSEUDO_END(_exit)
libc_hidden_def (_exit)
rtld_hidden_def (_exit)
weak_alias (_exit, _Exit)

View File

@ -0,0 +1,140 @@
#ifndef __A_OUT_GNU_H__
#define __A_OUT_GNU_H__
#define __GNU_EXEC_MACROS__
struct exec
{
unsigned long a_info; /* Use macros N_MAGIC, etc for access. */
unsigned int a_text; /* Length of text, in bytes. */
unsigned int a_data; /* Length of data, in bytes. */
unsigned int a_bss; /* Length of uninitialized data area for file, in bytes. */
unsigned int a_syms; /* Length of symbol table data in file, in bytes. */
unsigned int a_entry; /* Start address. */
unsigned int a_trsize;/* Length of relocation info for text, in bytes. */
unsigned int a_drsize;/* Length of relocation info for data, in bytes. */
};
enum machine_type
{
M_OLDSUN2 = 0,
M_68010 = 1,
M_68020 = 2,
M_SPARC = 3,
M_386 = 100,
M_MIPS1 = 151,
M_MIPS2 = 152
};
#define N_MAGIC(exec) ((exec).a_info & 0xffff)
#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
#define N_SET_INFO(exec, magic, type, flags) \
((exec).a_info = ((magic) & 0xffff) \
| (((int)(type) & 0xff) << 16) \
| (((flags) & 0xff) << 24))
#define N_SET_MAGIC(exec, magic) \
((exec).a_info = ((exec).a_info & 0xffff0000) | ((magic) & 0xffff))
#define N_SET_MACHTYPE(exec, machtype) \
((exec).a_info = \
((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
#define N_SET_FLAGS(exec, flags) \
((exec).a_info = \
((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
/* Code indicating object file or impure executable. */
#define OMAGIC 0407
/* Code indicating pure executable. */
#define NMAGIC 0410
/* Code indicating demand-paged executable. */
#define ZMAGIC 0413
/* This indicates a demand-paged executable with the header in the text.
The first page is unmapped to help trap NULL pointer references. */
#define QMAGIC 0314
/* Code indicating core file. */
#define CMAGIC 0421
#define N_TRSIZE(a) ((a).a_trsize)
#define N_DRSIZE(a) ((a).a_drsize)
#define N_SYMSIZE(a) ((a).a_syms)
#define N_BADMAG(x) \
(N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
&& N_MAGIC(x) != ZMAGIC && N_MAGIC(x) != QMAGIC)
#define _N_HDROFF(x) (1024 - sizeof (struct exec))
#define N_TXTOFF(x) \
(N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
(N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
#define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
#define N_SYMOFF(x) (N_DRELOFF(x) + N_DRSIZE(x))
#define N_STROFF(x) (N_SYMOFF(x) + N_SYMSIZE(x))
/* Address of text segment in memory after it is loaded. */
#define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? 4096 : 0)
/* Address of data segment in memory after it is loaded. */
#define SEGMENT_SIZE 1024
#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
#define N_DATADDR(x) \
(N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
: (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
#if !defined (N_NLIST_DECLARED)
struct nlist
{
union
{
char *n_name;
union
{
char *n_name;
struct nlist *n_next;
long n_strx;
} n_un;
} __attribute__ ((__transparent_union__));
unsigned char n_type;
char n_other;
short n_desc;
unsigned long n_value;
};
#endif /* no N_NLIST_DECLARED. */
#define N_UNDF 0
#define N_ABS 2
#define N_TEXT 4
#define N_DATA 6
#define N_BSS 8
#define N_FN 15
#define N_EXT 1
#define N_TYPE 036
#define N_STAB 0340
#define N_INDR 0xa
#define N_SETA 0x14 /* Absolute set element symbol. */
#define N_SETT 0x16 /* Text set element symbol. */
#define N_SETD 0x18 /* Data set element symbol. */
#define N_SETB 0x1A /* Bss set element symbol. */
#define N_SETV 0x1C /* Pointer to set vector in data area. */
#if !defined (N_RELOCATION_INFO_DECLARED)
/* This structure describes a single relocation to be performed.
The text-relocation section of the file is a vector of these structures,
all of which apply to the text section.
Likewise, the data-relocation section applies to the data section. */
struct relocation_info
{
int r_address;
unsigned int r_symbolnum:24;
unsigned int r_pcrel:1;
unsigned int r_length:2;
unsigned int r_extern:1;
unsigned int r_pad:4;
};
#endif /* no N_RELOCATION_INFO_DECLARED. */
#endif /* __A_OUT_GNU_H__ */

View File

@ -0,0 +1,82 @@
/* Copyright (C) 2009 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. */
#include <errno.h>
#include <fcntl.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/user.h>
#include <sysdep.h>
/*
The FreeBSD kernel do not test file access correctly when the
process' real user ID is superuser. In particular, they always return
zero when testing execute permissions without regard to whether the
file is executable.
While this behaviour conforms to POSIX.1-2008, it is explicitely
discouraged. This wrapper implements the recommended behaviour.
*/
extern int __syscall_access (const char *path, int mode);
libc_hidden_proto (__syscall_access)
int
__access (const char *path, int mode)
{
struct stat64 stats;
if ((__getuid() != 0) || !(mode & X_OK))
return __syscall_access (path, mode);
/* Althought the super-user can read and write any file,
the file-system might be i.e. read-only. Do the check. */
if (__syscall_access (path, mode))
return -1;
if (stat64 (path, &stats))
return -1;
/* The super-user can execute any file that anyone can execute. */
if (stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
return 0;
__set_errno (EACCES);
return -1;
}
/* Test for access to FILE by our real user and group IDs without setting
errno. */
int
__access_noerrno (const char *file, int type)
{
int ret;
int saved_errno = errno;
ret = __access (file, type);
__set_errno(saved_errno);
return ret;
}
weak_alias (__access, access)

View File

@ -0,0 +1,38 @@
/* Copyright (C) 2013 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, see
<http://www.gnu.org/licenses/>. */
#include <aio.h>
#include <errno.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>
#include <sysdep.h>
#include <sys/syscall.h>
#include <aio_misc.h>
int
internal_function
__aio_sigqueue (int sig, const union sigval val, pid_t caller_pid)
{
#if !IS_IN (libc)
return sigqueue(caller_pid, sig, val);
#else
return __sigqueue(caller_pid, sig, val);
#endif
}

View File

@ -0,0 +1,56 @@
/* Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Aurelien Jarno <aurelien@aurel32.net>, 2005.
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 <sys/socket.h>
#include <sysdep.h>
/* According to POSIX.1-2004 the len argument specifies the length of
the sockaddr structure pointed to by the addrarg argument. However
the FreeBSD kernel waits the actual length of the address stored
there. The code below emulate this behaviour. */
extern int __libc_sa_len (sa_family_t __af);
libc_hidden_proto (__libc_sa_len)
extern int __syscall_bind (int fd, __CONST_SOCKADDR_ARG addr,
socklen_t addrlen) __THROW;
libc_hidden_proto (__syscall_bind)
/* 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. */
int
__bind (int fd, __CONST_SOCKADDR_ARG addr, socklen_t addrlen)
{
socklen_t new_addrlen;
new_addrlen = __libc_sa_len ((addr.__sockaddr__)->sa_family);
/* Only allow a smaller size, otherwise it could lead to
stack corruption */
if ((new_addrlen != 0) && (new_addrlen < addrlen))
addrlen = new_addrlen;
/* We pass 3 arguments. */
return INLINE_SYSCALL (bind, 3, fd, addr.__sockaddr__, addrlen);
}
weak_alias (__bind, bind)

View File

@ -0,0 +1,44 @@
/* Copyright (C) 1995-2013 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, see
<http://www.gnu.org/licenses/>. */
/* 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_EXECPATH 15 /* Path to the executable. */
#define AT_CANARY 16 /* Canary for SSP. */
#define AT_CANARYLEN 17 /* Length of the canary. */
#define AT_OSRELDATE 18 /* OSRELDATE. */
#define AT_NCPUS 19 /* Number of CPUs. */
#define AT_PAGESIZES 20 /* Pagesizes. */
#define AT_PAGESIZESLEN 21 /* Number of pagesizes. */
#define AT_TIMEKEEP 22 /* Pointer to timehands. */
#define AT_STACKPROT 23 /* Initial stack protection. */

View File

@ -0,0 +1,55 @@
/* Directory entry structure `struct dirent'. FreeBSD version.
Copyright (C) 1996-1998,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 _DIRENT_H
# error "Never use <bits/dirent.h> directly; include <dirent.h> instead."
#endif
struct dirent
{
unsigned int d_ino; /* File serial number. */
unsigned short int d_reclen; /* Length of the whole `struct dirent'. */
unsigned char d_type; /* File type, possibly unknown. */
unsigned char d_namlen; /* Length of the file name. */
/* Only this member is in the POSIX standard. */
char d_name[256]; /* File name (actually longer). */
};
#ifdef __USE_LARGEFILE64
struct dirent64
{
unsigned int d_ino; /* File serial number. */
unsigned short int d_reclen; /* Length of the whole `struct dirent'. */
unsigned char d_type; /* File type, possibly unknown. */
unsigned char d_namlen; /* Length of the file name. */
/* Only this member is in the POSIX standard. */
char d_name[256]; /* File name (actually longer). */
};
#endif
#define d_fileno d_ino /* Backwards compatibility. */
#define _DIRENT_HAVE_D_RECLEN 1
#define _DIRENT_HAVE_D_NAMLEN 1
#define _DIRENT_HAVE_D_TYPE 1
/* Inform libc code that these two types are effectively identical. */
# define _DIRENT_MATCHES_DIRENT64 1

View File

@ -0,0 +1,195 @@
/*-
* Copyright (c) 1982, 1986, 1989, 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.
*
* @(#)errno.h 8.5 (Berkeley) 1/21/94
* $FreeBSD$
*/
#ifdef _ERRNO_H
# undef EDOM
# undef EILSEQ
# undef ERANGE
#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 /* Input/output error */
#define ENXIO 6 /* Device not configured */
#define E2BIG 7 /* Argument list too long */
#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file descriptor */
#define ECHILD 10 /* No child processes */
#define EDEADLK 11 /* Resource deadlock avoided */
/* 11 was EAGAIN */
#define ENOMEM 12 /* Cannot allocate memory */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
#define ENOTBLK 15 /* Block device required */
#define EBUSY 16 /* Device busy */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */
#define ENODEV 19 /* Operation not supported by device */
#define ENOTDIR 20 /* Not a directory */
#define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */
#define ENFILE 23 /* Too many open files in system */
#define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Inappropriate ioctl for device */
#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 filesystem */
#define EMLINK 31 /* Too many links */
#define EPIPE 32 /* Broken pipe */
/* math software */
#define EDOM 33 /* Numerical argument out of domain */
#define ERANGE 34 /* Result too large */
/* non-blocking and interrupt i/o */
#define EAGAIN 35 /* Resource temporarily unavailable */
#define EWOULDBLOCK EAGAIN /* Operation would block */
#define EINPROGRESS 36 /* Operation now in progress */
#define EALREADY 37 /* Operation already in progress */
/* ipc/network software -- argument errors */
#define ENOTSOCK 38 /* Socket operation on non-socket */
#define EDESTADDRREQ 39 /* Destination address required */
#define EMSGSIZE 40 /* Message too long */
#define EPROTOTYPE 41 /* Protocol wrong type for socket */
#define ENOPROTOOPT 42 /* Protocol not available */
#define EPROTONOSUPPORT 43 /* Protocol not supported */
#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
#define EOPNOTSUPP 45 /* Operation not supported */
#define ENOTSUP EOPNOTSUPP /* Operation not supported */
#define EPFNOSUPPORT 46 /* Protocol family not supported */
#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
#define EADDRINUSE 48 /* Address already in use */
#define EADDRNOTAVAIL 49 /* Can't assign requested address */
/* ipc/network software -- operational errors */
#define ENETDOWN 50 /* Network is down */
#define ENETUNREACH 51 /* Network is unreachable */
#define ENETRESET 52 /* Network dropped connection on reset */
#define ECONNABORTED 53 /* Software caused connection abort */
#define ECONNRESET 54 /* Connection reset by peer */
#define ENOBUFS 55 /* No buffer space available */
#define EISCONN 56 /* Socket is already connected */
#define ENOTCONN 57 /* Socket is not connected */
#define ESHUTDOWN 58 /* Can't send after socket shutdown */
#define ETOOMANYREFS 59 /* Too many references: can't splice */
#define ETIMEDOUT 60 /* Operation timed out */
#define ECONNREFUSED 61 /* Connection refused */
#define ELOOP 62 /* Too many levels of symbolic links */
#define ENAMETOOLONG 63 /* File name too long */
/* should be rearranged */
#define EHOSTDOWN 64 /* Host is down */
#define EHOSTUNREACH 65 /* No route to host */
#define ENOTEMPTY 66 /* Directory not empty */
/* quotas & mush */
#define EPROCLIM 67 /* Too many processes */
#define EUSERS 68 /* Too many users */
#define EDQUOT 69 /* Disc quota exceeded */
/* Network File System */
#define ESTALE 70 /* Stale NFS file handle */
#define EREMOTE 71 /* Too many levels of remote in path */
#define EBADRPC 72 /* RPC struct is bad */
#define ERPCMISMATCH 73 /* RPC version wrong */
#define EPROGUNAVAIL 74 /* RPC prog. not avail */
#define EPROGMISMATCH 75 /* Program version wrong */
#define EPROCUNAVAIL 76 /* Bad procedure for program */
#define ENOLCK 77 /* No locks available */
#define ENOSYS 78 /* Function not implemented */
#define EFTYPE 79 /* Inappropriate file type or format */
#define EAUTH 80 /* Authentication error */
#define ENEEDAUTH 81 /* Need authenticator */
#define EIDRM 82 /* Identifier removed */
#define ENOMSG 83 /* No message of desired type */
#define EOVERFLOW 84 /* Value too large to be stored in data type */
#define ECANCELED 85 /* Operation canceled */
#define EILSEQ 86 /* Illegal byte sequence */
#define ENOATTR 87 /* Attribute not found */
#define EDOOFUS 88 /* Programming error */
#define EBADMSG 89 /* Bad message */
#define EMULTIHOP 90 /* Multihop attempted */
#define ENOLINK 91 /* Link has been severed */
#define EPROTO 92 /* Protocol error */
#define ENOTCAPABLE 93 /* Capabilities insufficient */
#define ECAPMODE 94 /* Not permitted in capability mode */
#define ENOTRECOVERABLE 95 /* State not recoverable */
#define EOWNERDEAD 96 /* Previous owner died */
#define ELAST 96 /* Must be equal largest errno */
#ifdef _KERNEL
/* pseudo-errors returned inside kernel to modify return to process */
#define ERESTART (-1) /* restart syscall */
#define EJUSTRETURN (-2) /* don't modify regs, just return */
#define ENOIOCTL (-3) /* ioctl not handled by this layer */
#define EDIRIOCTL (-4) /* do direct ioctl in GEOM */
#endif
# ifndef __ASSEMBLER__
/* Function to get address of global `errno' variable. */
extern int *__errno_location (void) __THROW __attribute__ ((__const__));
# if !defined _LIBC || defined _LIBC_REENTRANT
/* 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 /* Numerical argument out of domain */
#define ERANGE 34 /* Result too large */
#define EILSEQ 86 /* Illegal byte sequence */
#endif /* !_ERRNO_H && __need_Emath */

View File

@ -0,0 +1,233 @@
/* O_*, F_*, FD_* bit values for FreeBSD.
Copyright (C) 1991-1992, 1997-2013 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 <bits/fcntl.h> directly; include <fcntl.h> instead."
#endif
#include <sys/types.h>
#include <bits/wordsize.h>
#ifdef __USE_GNU
# include <bits/uio.h>
#endif
/*
* File status flags: these are used by open(2), fcntl(2).
* They are also used (indirectly) in the kernel file structure f_flags,
* which is a superset of the open/fcntl flags. Open flags and f_flags
* are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
* Open/fcntl flags begin with O_; kernel-internal flags begin with F.
*/
/* open-only flags */
#define O_RDONLY 0x0000 /* open for reading only */
#define O_WRONLY 0x0001 /* open for writing only */
#define O_RDWR 0x0002 /* open for reading and writing */
#define O_ACCMODE 0x0003 /* mask for above modes */
/*
* Kernel encoding of open mode; separate read and write bits that are
* independently testable: 1 greater than the above.
*/
#define O_NONBLOCK 0x0004 /* no delay */
#define O_NDELAY O_NONBLOCK /* compat */
#define O_APPEND 0x0008 /* set append mode */
#if defined __USE_MISC
#define O_SHLOCK 0x0010 /* open with shared file lock */
#define O_EXLOCK 0x0020 /* open with exclusive file lock */
#endif
#define O_ASYNC 0x0040 /* signal pgrp when data ready */
#define O_FSYNC 0x0080 /* synchronous writes */
#define O_SYNC O_FSYNC /* POSIX synonym for O_FSYNC */
#if defined (__USE_XOPEN2K8) || defined (__USE_MISC)
#define O_NOFOLLOW 0x0100 /* don't follow symlinks */
#endif
#define O_CREAT 0x0200 /* create if nonexistent */
#define O_TRUNC 0x0400 /* truncate to zero length */
#define O_EXCL 0x0800 /* error if already exists */
/* Defined by POSIX 1003.1; BSD default, but must be distinct from O_RDONLY. */
#define O_NOCTTY 0x8000 /* don't assign controlling terminal */
#if defined __USE_MISC
/* Attempt to bypass buffer cache */
#define O_DIRECT 0x00010000
enum { O_NOATIME = 0}; /* Do not set atime. */
#endif
/* Defined by POSIX Extended API Set Part 2 */
#if defined (__USE_XOPEN2K8) || defined (__USE_MISC)
#define O_DIRECTORY 0x00020000 /* Fail if not directory */
#define O_EXEC 0x00040000 /* Open for execute only */
#endif
#if defined (__USE_XOPEN2K8) || defined (__USE_MISC)
/* Defined by POSIX 1003.1-2008; BSD default, but reserve for future use. */
#define O_TTY_INIT 0x00080000 /* Restore default termios attributes */
#define O_CLOEXEC 0x00100000
#endif
/* For now FreeBSD 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
/* Since 'off_t' is 64-bit, O_LARGEFILE is a no-op. */
#define O_LARGEFILE 0
#ifdef __USE_MISC
/* Bits in the file status flags returned by F_GETFL.
These are all the O_* flags, plus FREAD and FWRITE, which are
independent bits set by which of O_RDONLY, O_WRONLY, and O_RDWR, was
given to `open'. */
#define FREAD 1
#define FWRITE 2
#endif
#ifdef __USE_ATFILE
# define AT_FDCWD -100 /* Special value used to indicate
the *at functions should use the
current working directory. */
# define AT_EACCESS 0x100 /* Test access permitted for
effective IDs, not real IDs. */
# define AT_SYMLINK_NOFOLLOW 0x200 /* Do not follow symbolic links. */
# define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */
# define AT_REMOVEDIR 0x800 /* Remove directory instead of
unlinking file. */
#endif
/*
* We are out of bits in f_flag (which is a short). However,
* the flag bits not set in FMASK are only meaningful in the
* initial open syscall. Those bits can thus be given a
* different meaning for fcntl(2).
*/
#ifdef __USE_MISC
/*
* Set by shm_open(3) to get automatic MAP_ASYNC behavior
* for POSIX shared memory objects (which are otherwise
* implemented as plain files).
*/
#define FRDAHEAD O_CREAT
#define FPOSIXSHM O_NOFOLLOW
#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. */
#define F_GETLK 11 /* Get record locking info. */
#define F_SETLK 12 /* Set record locking info (non-blocking). */
#define F_SETLKW 13 /* Set record locking info (blocking). */
/* Not necessary, we always have 64-bit offsets. */
#define F_GETLK64 11 /* Get record locking info. */
#define F_SETLK64 12 /* Set record locking info (non-blocking). */
#define F_SETLKW64 13 /* Set record locking info (blocking). */
#ifdef __USE_XOPEN2K8
#define F_DUPFD_CLOEXEC 17 /* Like F_DUPFD, but FD_CLOEXEC is set */
#endif
#if defined __USE_MISC
#define F_DUP2FD_CLOEXEC 18 /* Like F_DUP2FD, but FD_CLOEXEC is set */
#endif
#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
# define F_GETOWN 5 /* Get owner of socket (receiver of SIGIO). */
# define F_SETOWN 6 /* Set owner of socket (receiver of SIGIO). */
#endif
/* For F_[GET|SET]FD. */
#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
#define F_RDLCK 1 /* shared or read lock */
#define F_UNLCK 2 /* unlock */
#define F_WRLCK 3 /* exclusive or write lock */
#if defined __USE_MISC
#define F_UNLCKSYS 4 /* purge locks for a given system ID */
#define F_CANCEL 5 /* cancel an async lock request */
#endif
#ifdef __USE_MISC
/* 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
struct flock
{
__off_t l_start; /* Offset where the lock begins. */
__off_t l_len; /* Size of the locked area; zero means until EOF. */
__pid_t l_pid; /* Process holding the lock. */
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'). */
int __l_sysid; /* remote system id or zero for local */
};
#ifdef __USE_LARGEFILE64
struct flock64
{
__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. */
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'). */
int __l_sysid; /* remote system id or zero for local */
};
#endif
/* Define some more compatibility macros to be backward compatible with
BSD systems which did not managed to hide these kernel macros. */
#ifdef __USE_MISC
# define FAPPEND O_APPEND
# define FFSYNC O_FSYNC
# define FASYNC O_ASYNC
# define FNONBLOCK O_NONBLOCK
# define FNDELAY O_NDELAY
#define FCREAT O_CREAT
#define FEXCL O_EXCL
#define FTRUNC O_TRUNC
#define FNOCTTY O_NOCTTY
#define FSYNC O_SYNC
#endif /* Use BSD. */
#ifdef __USE_XOPEN2K
/*
* Advice to posix_fadvise
*/
#define POSIX_FADV_NORMAL 0 /* no 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 /* dont need these pages */
#define POSIX_FADV_NOREUSE 5 /* access data only once */
#endif

View File

@ -0,0 +1,310 @@
/* Copyright (C) 1997, 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; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
/* FreeBSD version. */
#ifndef _NETINET_IN_H
# error "Never use <bits/in.h> directly; include <netinet/in.h> instead."
#endif
/* This is the FreeBSD version, do not assume a linux-based kernel. */
#define __USE_KERNEL_IPV6_DEFS 0
/* Link numbers. */
#define IMPLINK_IP 155
#define IMPLINK_LOWEXPER 156
#define IMPLINK_HIGHEXPER 158
#define IPPROTO_DIVERT 258 /* divert pseudo-protocol */
/* To select the IP level. */
#define SOL_IP 0
/*
* Options for use with [gs]etsockopt at the IP level.
* First word of comment is data type; bool is stored in int.
*/
#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */
#define IP_HDRINCL 2 /* int; header is included with data */
#define IP_TOS 3 /* int; IP type of service and preced. */
#define IP_TTL 4 /* int; IP time to live */
#define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */
#define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */
#define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */
#define IP_SENDSRCADDR IP_RECVDSTADDR /* cmsg_type to set src addr */
#define IP_RETOPTS 8 /* ip_opts; set/get IP options */
#define IP_MULTICAST_IF 9 /* struct in_addr *or* struct ip_mreqn;
* set/get IP multicast i/f */
#define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */
#define IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */
#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */
#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */
#define IP_MULTICAST_VIF 14 /* set/get IP mcast virt. iface */
#define IP_RSVP_ON 15 /* enable RSVP in kernel */
#define IP_RSVP_OFF 16 /* disable RSVP in kernel */
#define IP_RSVP_VIF_ON 17 /* set RSVP per-vif socket */
#define IP_RSVP_VIF_OFF 18 /* unset RSVP per-vif socket */
#define IP_PORTRANGE 19 /* int; range to choose for unspec port */
#define IP_RECVIF 20 /* bool; receive reception if w/dgram */
/* for IPSEC */
#define IP_IPSEC_POLICY 21 /* int; set/get security policy */
#define IP_FAITH 22 /* bool; accept FAITH'ed connections */
#define IP_ONESBCAST 23 /* bool: send all-ones broadcast */
#define IP_NONLOCALOK 24 /* bool: allow bind to spoof non-local addresses;
requires kernel compile option IP_NONLOCALBIND */
#define IP_FW_TABLE_ADD 40 /* add entry */
#define IP_FW_TABLE_DEL 41 /* delete entry */
#define IP_FW_TABLE_FLUSH 42 /* flush table */
#define IP_FW_TABLE_GETSIZE 43 /* get table size */
#define IP_FW_TABLE_LIST 44 /* list table contents */
#define IP_FW_ADD 50 /* add a firewall rule to chain */
#define IP_FW_DEL 51 /* delete a firewall rule from chain */
#define IP_FW_FLUSH 52 /* flush firewall rule chain */
#define IP_FW_ZERO 53 /* clear single/all firewall counter(s) */
#define IP_FW_GET 54 /* get entire firewall rule chain */
#define IP_FW_RESETLOG 55 /* reset logging counters */
#define IP_FW_NAT_CFG 56 /* add/config a nat rule */
#define IP_FW_NAT_DEL 57 /* delete a nat rule */
#define IP_FW_NAT_GET_CONFIG 58 /* get configuration of a nat rule */
#define IP_FW_NAT_GET_LOG 59 /* get log of a nat rule */
#define IP_DUMMYNET_CONFIGURE 60 /* add/configure a dummynet pipe */
#define IP_DUMMYNET_DEL 61 /* delete a dummynet pipe from chain */
#define IP_DUMMYNET_FLUSH 62 /* flush dummynet */
#define IP_DUMMYNET_GET 64 /* get entire dummynet pipes */
#define IP_RECVTTL 65 /* bool; receive IP TTL w/dgram */
#define IP_MINTTL 66 /* minimum TTL for packet or drop */
#define IP_DONTFRAG 67 /* don't fragment packet */
/* IPv4 Source Filter Multicast API [RFC3678] */
#define IP_ADD_SOURCE_MEMBERSHIP 70 /* join a source-specific group */
#define IP_DROP_SOURCE_MEMBERSHIP 71 /* drop a single source */
#define IP_BLOCK_SOURCE 72 /* block a source */
#define IP_UNBLOCK_SOURCE 73 /* unblock a source */
/* The following option is private; do not use it from user applications. */
#define IP_MSFILTER 74 /* set/get filter list */
/* Protocol Independent Multicast API [RFC3678] */
#define MCAST_JOIN_GROUP 80 /* join an any-source group */
#define MCAST_LEAVE_GROUP 81 /* leave all sources for group */
#define MCAST_JOIN_SOURCE_GROUP 82 /* join a source-specific group */
#define MCAST_LEAVE_SOURCE_GROUP 83 /* leave a single source */
#define MCAST_BLOCK_SOURCE 84 /* block a source */
#define MCAST_UNBLOCK_SOURCE 85 /* unblock a source */
/*
* Defaults and limits for options
*/
#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */
#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
/*
* The imo_membership vector for each socket is now dynamically allocated at
* run-time, bounded by USHRT_MAX, and is reallocated when needed, sized
* according to a power-of-two increment.
*/
#define IP_MIN_MEMBERSHIPS 31
#define IP_MAX_MEMBERSHIPS 4095
#define IP_MAX_SOURCE_FILTER 1024 /* # of filters per socket, per group */
/*
* Filter modes; also used to represent per-socket filter mode internally.
*/
#define MCAST_UNDEFINED 0 /* fmode: not yet defined */
#define MCAST_INCLUDE 1 /* fmode: include these source(s) */
#define MCAST_EXCLUDE 2 /* fmode: exclude these source(s) */
/*
* Argument for IP_PORTRANGE:
* - which range to search when port is unspecified at bind() or connect()
*/
#define IP_PORTRANGE_DEFAULT 0 /* default range */
#define IP_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */
#define IP_PORTRANGE_LOW 2 /* "low" - vouchsafe security */
/*
* Names for IP sysctl objects
*/
#define IPCTL_FORWARDING 1 /* act as router */
#define IPCTL_SENDREDIRECTS 2 /* may send redirects when forwarding */
#define IPCTL_DEFTTL 3 /* default TTL */
#ifdef notyet
#define IPCTL_DEFMTU 4 /* default MTU */
#endif
#define IPCTL_RTEXPIRE 5 /* cloned route expiration time */
#define IPCTL_RTMINEXPIRE 6 /* min value for expiration time */
#define IPCTL_RTMAXCACHE 7 /* trigger level for dynamic expire */
#define IPCTL_SOURCEROUTE 8 /* may perform source routes */
#define IPCTL_DIRECTEDBROADCAST 9 /* may re-broadcast received packets */
#define IPCTL_INTRQMAXLEN 10 /* max length of netisr queue */
#define IPCTL_INTRQDROPS 11 /* number of netisr q drops */
#define IPCTL_STATS 12 /* ipstat structure */
#define IPCTL_ACCEPTSOURCEROUTE 13 /* may accept source routed packets */
#define IPCTL_FASTFORWARDING 14 /* use fast IP forwarding code */
#define IPCTL_KEEPFAITH 15 /* FAITH IPv4->IPv6 translater ctl */
#define IPCTL_GIF_TTL 16 /* default TTL for gif encap packet */
#define IPCTL_MAXID 17
/* 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. */
};
/* 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_SOCKOPT_RESERVED1 3 /* reserved for future use */
#define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */
#define IPV6_MULTICAST_IF 9 /* u_int; set/get IP6 multicast i/f */
#define IPV6_MULTICAST_HOPS 10 /* int; set/get IP6 multicast hops */
#define IPV6_MULTICAST_LOOP 11 /* u_int; set/get IP6 multicast loopback */
#define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */
#define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */
#define IPV6_PORTRANGE 14 /* int; range to choose for unspec port */
#define ICMP6_FILTER 18 /* icmp6_filter; icmp6 filter */
#define IPV6_CHECKSUM 26 /* int; checksum offset for raw socket */
#define IPV6_V6ONLY 27 /* bool; make AF_INET6 sockets v6 only */
#define IPV6_IPSEC_POLICY 28 /* struct; get/set security policy */
#define IPV6_FAITH 29 /* bool; accept FAITH'ed connections */
#define IPV6_FW_ADD 30 /* add a firewall rule to chain */
#define IPV6_FW_DEL 31 /* delete a firewall rule from chain */
#define IPV6_FW_FLUSH 32 /* flush firewall rule chain */
#define IPV6_FW_ZERO 33 /* clear single/all firewall counter(s) */
#define IPV6_FW_GET 34 /* get entire firewall rule chain */
#define IPV6_RTHDRDSTOPTS 35 /* ip6_dest; send dst option before rthdr */
#define IPV6_RECVPKTINFO 36 /* bool; recv if, dst addr */
#define IPV6_RECVHOPLIMIT 37 /* bool; recv hop limit */
#define IPV6_RECVRTHDR 38 /* bool; recv routing header */
#define IPV6_RECVHOPOPTS 39 /* bool; recv hop-by-hop option */
#define IPV6_RECVDSTOPTS 40 /* bool; recv dst option after rthdr */
#define IPV6_USE_MIN_MTU 42 /* bool; send packets at the minimum MTU */
#define IPV6_RECVPATHMTU 43 /* bool; notify an according MTU */
#define IPV6_PATHMTU 44 /* mtuinfo; get the current path MTU (sopt),
4 bytes int; MTU notification (cmsg) */
#define IPV6_PKTINFO 46 /* in6_pktinfo; send if, src addr */
#define IPV6_HOPLIMIT 47 /* int; send hop limit */
#define IPV6_NEXTHOP 48 /* sockaddr; next hop addr */
#define IPV6_HOPOPTS 49 /* ip6_hbh; send hop-by-hop option */
#define IPV6_DSTOPTS 50 /* ip6_dest; send dst option befor rthdr */
#define IPV6_RTHDR 51 /* ip6_rthdr; send routing header */
#define IPV6_RECVTCLASS 57 /* bool; recv traffic class values */
#define IPV6_AUTOFLOWLABEL 59 /* bool; attach flowlabel automagically */
#define IPV6_TCLASS 61 /* int; send traffic class value */
#define IPV6_DONTFRAG 62 /* bool; disable IPv6 fragmentation */
#define IPV6_PREFER_TEMPADDR 63 /* int; prefer temporary addresses as
* the source address.
*/
/* 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
/* Socket level values for IPv6. */
#define SOL_IPV6 41
#define SOL_ICMPV6 58
/*
* Defaults and limits for options
*/
#define IPV6_DEFAULT_MULTICAST_HOPS 1 /* normally limit m'casts to 1 hop */
#define IPV6_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
/*
* Argument for IPV6_PORTRANGE:
* - which range to search when port is unspecified at bind() or connect()
*/
#define IPV6_PORTRANGE_DEFAULT 0 /* default range */
#define IPV6_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */
#define IPV6_PORTRANGE_LOW 2 /* "low" - vouchsafe security */
/* 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. */
/*
* Names for IP sysctl objects
*/
#define IPV6CTL_FORWARDING 1 /* act as router */
#define IPV6CTL_SENDREDIRECTS 2 /* may send redirects when forwarding*/
#define IPV6CTL_DEFHLIM 3 /* default Hop-Limit */
#define IPV6CTL_FORWSRCRT 5 /* forward source-routed dgrams */
#define IPV6CTL_STATS 6 /* stats */
#define IPV6CTL_MRTSTATS 7 /* multicast forwarding stats */
#define IPV6CTL_MRTPROTO 8 /* multicast routing protocol */
#define IPV6CTL_MAXFRAGPACKETS 9 /* max packets reassembly queue */
#define IPV6CTL_SOURCECHECK 10 /* verify source route and intf */
#define IPV6CTL_SOURCECHECK_LOGINT 11 /* minimume logging interval */
#define IPV6CTL_ACCEPT_RTADV 12
#define IPV6CTL_KEEPFAITH 13
#define IPV6CTL_LOG_INTERVAL 14
#define IPV6CTL_HDRNESTLIMIT 15
#define IPV6CTL_DAD_COUNT 16
#define IPV6CTL_AUTO_FLOWLABEL 17
#define IPV6CTL_DEFMCASTHLIM 18
#define IPV6CTL_GIF_HLIM 19 /* default HLIM for gif encap packet */
#define IPV6CTL_KAME_VERSION 20
#define IPV6CTL_USE_DEPRECATED 21 /* use deprecated addr (RFC2462 5.5.4) */
#define IPV6CTL_RR_PRUNE 22 /* walk timer for router renumbering */
#define IPV6CTL_V6ONLY 24
#define IPV6CTL_RTEXPIRE 25 /* cloned route expiration time */
#define IPV6CTL_RTMINEXPIRE 26 /* min value for expiration time */
#define IPV6CTL_RTMAXCACHE 27 /* trigger level for dynamic expire */
#define IPV6CTL_USETEMPADDR 32 /* use temporary addresses (RFC3041) */
#define IPV6CTL_TEMPPLTIME 33 /* preferred lifetime for tmpaddrs */
#define IPV6CTL_TEMPVLTIME 34 /* valid lifetime for tmpaddrs */
#define IPV6CTL_AUTO_LINKLOCAL 35 /* automatic link-local addr assign */
#define IPV6CTL_RIP6STATS 36 /* raw_ip6 stats */
#define IPV6CTL_PREFER_TEMPADDR 37 /* prefer temporary addr as src */
#define IPV6CTL_ADDRCTLPOLICY 38 /* get/set address selection policy */
#define IPV6CTL_USE_DEFAULTZONE 39 /* use default scope zone */
#define IPV6CTL_MAXFRAGS 41 /* max fragments */
#define IPV6CTL_MCAST_PMTU 44 /* enable pMTU discovery for multicast? */
/* New entries should be added here from current IPV6CTL_MAXID value. */
/* to define items, should talk with KAME guys first, for *BSD compatibility */
/* 42-44 is already used in KAME */
#define IPV6CTL_STEALTH 45
#define ICMPV6CTL_ND6_ONLINKNSRFC4861 47
#define IPV6CTL_MAXID 48

View File

@ -0,0 +1,37 @@
/* Structure types for pre-termios terminal ioctls. FreeBSD version.
Copyright (C) 1996, 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_IOCTL_H
# error "Never use <bits/ioctl-types.h> directly; include <sys/ioctl.h> instead."
#endif
/* Many systems that have TIOCGWINSZ define TIOCGSIZE for source
compatibility with Sun; they define `struct ttysize' to have identical
layout as `struct winsize' and #define TIOCGSIZE to be TIOCGWINSZ
(likewise TIOCSSIZE and TIOCSWINSZ). */
/* struct ttysize is in FreeBSD originally defined in <sys/ioctl.h>,
which is replaced by GLIBC version -> define here */
struct ttysize
{
unsigned short int ts_lines;
unsigned short int ts_cols;
unsigned short int ts_xxx;
unsigned short int ts_yyy;
};
#define _IOT_ttysize _IOT_winsize

View File

@ -0,0 +1,50 @@
/*-
* Copyright (c) 1982, 1986, 1990 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.
*
* @(#)ioctl.h 8.6 (Berkeley) 3/28/94
*/
#ifndef _IOCTLS_H_
#define _IOCTLS_H_
#include <sys/ioccom.h>
#include <sys/ttycom.h>
/*
* @(#)ioctl.h 8.6 (Berkeley) 3/28/94
*/
#define TIOCGSIZE TIOCGWINSZ
#define TIOCSSIZE TIOCSWINSZ
#include <sys/filio.h>
#include <sys/sockio.h>
#endif /* !_IOCTLS_H_ */

View File

@ -0,0 +1,56 @@
/* Copyright (C) 1995-1997, 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 _SYS_IPC_H
# error "Never use <bits/ipc.h> directly; include <sys/ipc.h> instead."
#endif
#include <bits/types.h>
/* 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 */
/* Special key values. */
#define IPC_PRIVATE ((__key_t) 0) /* private key */
#ifdef __USE_MISC
/* Common mode bits. */
# define IPC_R 0400 /* read permission, same as S_IRUSR */
# define IPC_W 0200 /* write permission, same as S_IWUSR */
# define IPC_M 0x1000 /* control permission */
#endif
/* Data structure used to pass permission information to IPC operations. */
struct ipc_perm
{
__uid_t cuid; /* creator user id */
__gid_t cgid; /* creator group id */
__uid_t uid; /* user id */
__gid_t gid; /* group id */
__mode_t mode; /* r/w permission */
__uint16_t __seq; /* sequence # (to generate unique ipcid) */
__key_t __key; /* user specified msg/sem/shm key */
};

View File

@ -0,0 +1,130 @@
/* Definitions for POSIX memory map interface. FreeBSD version.
Copyright (C) 1994-1998, 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; 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 <bits/mman.h> directly; include <sys/mman.h> instead."
#endif
#include <features.h>
#include <stddef.h>
/* 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_NONE 0x00 /* No access. */
#define PROT_READ 0x01 /* Pages can be read. */
#define PROT_WRITE 0x02 /* Pages can be written. */
#define PROT_EXEC 0x04 /* Pages can be executed. */
/* Flags contain mapping type, sharing type and options. */
/* Mapping type (must choose one and only one of these). */
#ifdef __USE_MISC
# define MAP_FILE 0x0000 /* Mapped from a file or device. */
# define MAP_ANON 0x1000 /* Allocated from anonymous virtual memory. */
# define MAP_TYPE 0x1000 /* Mask for type field. */
# ifdef __USE_MISC
# define MAP_ANONYMOUS MAP_ANON /* Linux name. */
# endif
#endif
/* Sharing types (must choose one and only one of these). */
#define MAP_SHARED 0x0001 /* Share changes. */
#define MAP_PRIVATE 0x0002 /* Changes private; copy pages on write. */
#ifdef __USE_MISC
# define MAP_COPY MAP_PRIVATE /* Virtual copy of region at mapping time. */
#endif
/* Other flags. */
#define MAP_FIXED 0x0010 /* Map address must be exactly as requested. */
#ifdef __USE_MISC
#define MAP_RENAME 0x0020 /* Sun: rename private pages to file */
#define MAP_NORESERVE 0x0040 /* Sun: don't reserve needed swap area */
#define MAP_RESERVED0080 0x0080 /* previously misimplemented MAP_INHERIT */
#define MAP_RESERVED0100 0x0100 /* previously unimplemented MAP_NOEXTEND */
# define MAP_HASSEMPHORE 0x0200 /* Region may contain semaphores. */
# define MAP_STACK 0x0400 /* Region grows down, like a stack. */
# define MAP_NOSYNC 0x0800 /* Try to avoid flushing to the disk. */
# define MAP_NOCORE 0x20000 /* Don't include these pages in a core dump. */
#endif
/* Advice to `madvise'. */
#ifdef __USE_MISC
# 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_FREE 5 /* Don't need these pages, they contain junk. */
# define MADV_NOSYNC 6 /* Try to avoid flushing to the disk. */
# define MADV_AUTOSYNC 7 /* Use the default flushing strategy. */
# define MADV_NOCORE 8 /* Don't include these pages in a core dump. */
# define MADV_CORE 9 /* Include pages in a core dump (default). */
# define MADV_PROTECT 10 /* protect process from pageout kill */
#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
/* Flags to `msync'. */
#define MS_ASYNC 1 /* Sync memory asynchronously. */
#define MS_SYNC 0 /* Synchronous memory sync. */
#define MS_INVALIDATE 2 /* Invalidate the caches. */
/* Flags for `mlockall' (can be OR'd together). */
#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
#define MCL_FUTURE 2 /* Lock all additions to address
space. */
/* Flags for 'minherit'. */
#ifdef __USE_MISC
# define INHERIT_SHARE 0
# define INHERIT_COPY 1
# define INHERIT_NONE 2
#endif
/*
* Return bits from mincore
*/
#ifdef __USE_MISC
#define MINCORE_INCORE 0x1 /* Page is incore */
#define MINCORE_REFERENCED 0x2 /* Page has been referenced by us */
#define MINCORE_MODIFIED 0x4 /* Page has been modified by us */
#define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */
#define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */
#endif /* Use MISC */
#ifdef __USE_MISC
__BEGIN_DECLS
extern int minherit (void *__addr, size_t __len, int __inherit);
__END_DECLS
#endif /* Use BSD */

View File

@ -0,0 +1,65 @@
/* Copyright (C) 1995, 1997, 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; 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 <bits/msq.h> directly; include <sys/msg.h> instead."
#endif
#include <bits/types.h>
/* Define options for message queue functions. */
#define MSG_NOERROR 010000 /* no error if message is too big */
/* 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; /* msg queue permission bits */
void *__msg_first; /* first message in the queue */
void *__msg_last; /* last message in the queue */
msglen_t __msg_cbytes; /* number of bytes in use on the queue */
msgqnum_t msg_qnum; /* number of msgs in the queue */
msglen_t msg_qbytes; /* max # of bytes on the queue */
__pid_t msg_lspid; /* pid of last msgsnd() */
__pid_t msg_lrpid; /* pid of last msgrcv() */
__time_t msg_stime; /* time of last msgsnd() */
__time_t msg_rtime; /* time of last msgrcv() */
__time_t msg_ctime; /* time of last msgctl() */
};
#ifdef __USE_MISC
# define msg_cbytes __msg_cbytes
/* buffer for msgctl calls IPC_INFO, MSG_INFO */
struct msginfo
{
int msgmax;
int msgmni;
int msgmnb;
int msgtql;
int msgssz;
int msgseg;
};
#endif /* __USE_MISC */

View File

@ -0,0 +1,8 @@
__BEGIN_DECLS
/* whether is current process tainted by uid or gid changes */
extern int issetugid(void) __THROW;
__END_DECLS

View File

@ -0,0 +1,189 @@
/* 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
# error "Never use <bits/param.h> directly; include <sys/param.h> instead."
#endif
#include <limits.h>
#include <sys/syslimits.h>
/*
* __FreeBSD_version numbers are documented in the Porter's Handbook.
* If you bump the version for any reason, you should update the documentation
* there.
* Currently this lives here:
*
* doc/en_US.ISO8859-1/books/porters-handbook/book.sgml
*
* scheme is: <major><two digit minor><0 if release branch, otherwise 1>xx
*/
#include <osreldate.h>
/* Some inet code expects that this file defines the 'u_int32_t' type. */
#include <stdint.h>
/* FreeBSD code expects that this file implicitly defines SIG* macros. */
#include <signal.h>
/*
* Machine-independent constants (some used in following include files).
* Redefined constants are from POSIX 1003.1 limits file.
*
* MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
* MAXLOGNAME should be == UT_NAMESIZE+1 (see <utmp.h>)
*/
#define MAXCOMLEN 19 /* max command name remembered */
#define MAXINTERP 32 /* max interpreter file name length */
#define MAXLOGNAME 33 /* max login name length (incl. NUL) */
#define MAXUPRC CHILD_MAX /* max simultaneous processes */
#define NGROUPS (NGROUPS_MAX+1) /* max number groups */
#define MAXHOSTNAMELEN 256 /* max hostname size */
#define SPECNAMELEN 63 /* max length of devicename */
#define TTY_NAME_MAX SPECNAMELEN
/* BSD names for some <limits.h> values. */
#define MAXSYMLINKS 32
#define CANBSIZ MAX_CANON
/* Machine type dependent parameters. */
#include <machine/param.h>
#ifndef BLKDEV_IOSIZE
#define BLKDEV_IOSIZE PAGE_SIZE /* default block device I/O size */
#endif
#ifndef DFLTPHYS
#define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */
#endif
#ifndef MAXPHYS
#define MAXPHYS (128 * 1024) /* max raw I/O transfer size */
#endif
#ifndef MAXDUMPPGS
#define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE)
#endif
/*
* Constants related to network buffer management.
* MCLBYTES must be no larger than PAGE_SIZE.
*/
#ifndef MSIZE
#define MSIZE 256 /* size of an mbuf */
#endif /* MSIZE */
#ifndef MCLSHIFT
#define MCLSHIFT 11 /* convert bytes to mbuf clusters */
#endif /* MCLSHIFT */
#define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */
/*
* Some macros for units conversion
*/
/* clicks to bytes */
#ifndef ctob
#define ctob(x) ((x)<<PAGE_SHIFT)
#endif
/* bytes to clicks */
#ifndef btoc
#define btoc(x) (((vm_offset_t)(x)+PAGE_MASK)>>PAGE_SHIFT)
#endif
/*
* btodb() is messy and perhaps slow because `bytes' may be an off_t. We
* want to shift an unsigned type to avoid sign extension and we don't
* want to widen `bytes' unnecessarily. Assume that the result fits in
* a daddr_t.
*/
#ifndef btodb
#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
(sizeof (bytes) > sizeof(long) \
? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \
: (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT))
#endif
#ifndef dbtob
#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
((off_t)(db) << DEV_BSHIFT)
#endif
#define PRIMASK 0x0ff
#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */
#define PDROP 0x200 /* OR'd with pri to stop re-entry of interlock mutex */
#define NBPW sizeof(int) /* number of bytes per word (integer) */
#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
#define NODEV (dev_t)(-1) /* non-existent device */
#define CBLOCK 128 /* Clist block size, must be a power of 2. */
#define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */
/* Data chars/clist. */
#define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE)
#define CROUND (CBLOCK - 1) /* Clist rounding. */
/*
* File system parameters and macros.
*
* MAXBSIZE - Filesystems are made out of blocks of at most MAXBSIZE bytes
* per block. MAXBSIZE may be made larger without effecting
* any existing filesystems as long as it does not exceed MAXPHYS,
* and may be made smaller at the risk of not being able to use
* filesystems which require a block size exceeding MAXBSIZE.
*
* BKVASIZE - Nominal buffer space per buffer, in bytes. BKVASIZE is the
* minimum KVM memory reservation the kernel is willing to make.
* Filesystems can of course request smaller chunks. Actual
* backing memory uses a chunk size of a page (PAGE_SIZE).
*
* If you make BKVASIZE too small you risk seriously fragmenting
* the buffer KVM map which may slow things down a bit. If you
* make it too big the kernel will not be able to optimally use
* the KVM memory reserved for the buffer cache and will wind
* up with too-few buffers.
*
* The default is 16384, roughly 2x the block size used by a
* normal UFS filesystem.
*/
#define MAXBSIZE 65536 /* must be power of 2 */
#define BKVASIZE 16384 /* must be power of 2 */
#define BKVAMASK (BKVASIZE-1)
/*
* Scale factor for scaled integers used to count %cpu time and load avgs.
*
* The number of CPU `tick's that map to a unique `%age' can be expressed
* by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that
* can be calculated (assuming 32 bits) can be closely approximated using
* the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
*
* For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
* FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
*/
#define FSHIFT 11 /* bits to right of fixed binary point */
#define FSCALE (1<<FSHIFT)
#define dbtoc(db) /* calculates devblks to pages */ \
((db + (ctodb(1) - 1)) >> (PAGE_SHIFT - DEV_BSHIFT))
#define ctodb(db) /* calculates pages to devblks */ \
((db) << (PAGE_SHIFT - DEV_BSHIFT))

View File

@ -0,0 +1,62 @@
/* Copyright (C) 1997, 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_POLL_H
# error "Never use <bits/poll.h> directly; include <sys/poll.h> 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 0x0001 /* There is data to read. */
#define POLLPRI 0x0002 /* There is urgent data to read. */
#define POLLOUT 0x0004 /* Writing now will not block. */
#if defined __USE_XOPEN || defined __USE_XOPEN2K8
/* These values are defined in XPG4.2. */
# define POLLRDNORM 0x0040 /* Normal data may be read. */
# define POLLRDBAND 0x0080 /* Priority data may be read. */
# define POLLWRNORM POLLOUT /* Writing now will not block. */
# define POLLWRBAND 0x0100 /* Priority data may be written. */
#endif
#ifdef __USE_MISC
/* General FreeBSD extension (currently only supported for sockets): */
# define POLLINIGNEOF 0x2000 /* like POLLIN, except ignore EOF */
#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 0x0008 /* Error condition. */
#define POLLHUP 0x0010 /* Hung up. */
#define POLLNVAL 0x0020 /* Invalid polling request. */
#ifdef __USE_MISC
# define POLLSTANDARD (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|\
POLLWRBAND|POLLERR|POLLHUP|POLLNVAL)
/*
* Request that poll() wait forever.
* XXX in SYSV, this is defined in stropts.h, which is not included
* by poll.h.
*/
#define INFTIM (-1)
#endif

View File

@ -0,0 +1,92 @@
/* Define POSIX options for FreeBSD.
Copyright (C) 1996-1997, 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; 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 <unistd.h> instead.
*/
#ifndef _BITS_POSIX_OPT_H
#define _BITS_POSIX_OPT_H 1
#include <bits/os-unistd.h>
/* 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 1
/* Synchronizing file data is supported. */
#define _POSIX_SYNCHRONIZED_IO 1
/* The fsync function is present. */
#define _POSIX_FSYNC 1
/* Mapping of files to memory is supported. */
#define _POSIX_MAPPED_FILES 1
/* Locking of all memory is supported. */
#define _POSIX_MEMLOCK 1
/* Locking of ranges of memory is supported. */
#define _POSIX_MEMLOCK_RANGE 1
/* Setting of memory protections is supported. */
#define _POSIX_MEMORY_PROTECTION 1
/* Implementation supports `poll' function. */
#define _POSIX_POLL 1
/* Implementation supports `select' and `pselect' functions. */
#define _POSIX_SELECT 1
/* XPG4.2 shared memory is supported. */
#define _XOPEN_SHM 1
/* X/Open realtime support is available. */
#define _XOPEN_REALTIME 1
/* 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 ((unsigned char)'\377')
/* The LFS interface is available, except for the asynchronous I/O. */
#define _LFS_LARGEFILE 1
#define _LFS64_LARGEFILE 1
#define _LFS64_STDIO 1
/* POSIX timers are available. */
#define _POSIX_TIMERS 1
/* GNU libc provides regular expression handling. */
#define _POSIX_REGEXP 1
/* We have a POSIX shell. */
#define _POSIX_SHELL 1
/* The `spawn' function family is supported. */
#define _POSIX_SPAWN 200912L
#endif /* bits/posix_opt.h */

View File

@ -0,0 +1,219 @@
/* Bit values & structures for resource limits. FreeBSD version.
Copyright (C) 1994, 1996-1998, 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_RESOURCE_H
# error "Never use <bits/resource.h> directly; include <sys/resource.h> instead."
#endif
#include <bits/types.h>
#include <sys/_types.h>
/* 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.
These are the values for FreeBSD. Earlier BSD systems have a subset of
these kinds of resource limit. */
/* 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
/* Locked-in-memory address space. */
__RLIMIT_MEMLOCK = 6,
#define RLIMIT_MEMLOCK __RLIMIT_MEMLOCK
/* Number of processes. */
__RLIMIT_NPROC = 7,
#define RLIMIT_NPROC __RLIMIT_NPROC
/* Number of open files. */
RLIMIT_NOFILE = 8,
#define RLIMIT_NOFILE RLIMIT_NOFILE
/* Maximum size of all socket buffers. */
__RLIMIT_SBSIZE = 9,
#define RLIMIT_SBSIZE __RLIMIT_SBSIZE
/* Address space limit. */
RLIMIT_AS = 10,
#define RLIMIT_AS RLIMIT_AS
RLIMIT_VMEM = RLIMIT_AS,
/* Pseudo-terminals. */
RLIMIT_NPTS = 11,
#define RLIMIT_NPTS RLIMIT_NPTS
/* Swap used. */
RLIMIT_SWAP = 12,
#define RLIMIT_SWAP RLIMIT_SWAP
__RLIMIT_NLIMITS = 13,
__RLIM_NLIMITS = __RLIMIT_NLIMITS
#define RLIMIT_NLIMITS __RLIMIT_NLIMITS
#define RLIM_NLIMITS __RLIM_NLIMITS
};
/* Value to indicate that there is no limit. */
#define RLIM_INFINITY 0x7fffffffffffffffLL
#ifdef __USE_LARGEFILE64
# define RLIM64_INFINITY 0x7fffffffffffffffLL
#endif
/* Type for resource quantity measurement. */
typedef __rlim_t rlim_t;
#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
struct orlimit {
__int32_t rlim_cur; /* current (soft) limit */
__int32_t rlim_max; /* maximum value for rlim_cur */
};
struct loadavg {
__fixpt_t ldavg[3];
long fscale;
};
#define CP_USER 0
#define CP_NICE 1
#define CP_SYS 2
#define CP_INTR 3
#define CP_IDLE 4
#define CPUSTATES 5
/* 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
};
#include <bits/types/struct_timeval.h>
/* 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
};

View File

@ -0,0 +1,183 @@
/* Definitions of constants and data structure for POSIX 1003.1b-1993
scheduling interface.
Copyright (C) 1996-1999,2001-2003,2005,2006,2007,2008
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 <bits/sched.h> directly; use <sched.h> instead."
#endif
/* Scheduling algorithms. */
#define SCHED_OTHER 2
#define SCHED_FIFO 1
#define SCHED_RR 3
#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_SYSVSEM 0x00040000 /* share system V SEM_UNDO semantics */
#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;
/* Unshare the specified resources. */
extern int unshare (int __flags) __THROW;
/* Get index of currently used CPU. */
extern int sched_getcpu (void) __THROW;
#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 128
# define __NCPUBITS (8 * sizeof (__cpu_mask))
/* Type for array elements in 'cpu_set_t'. */
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. */
# if __GNUC_PREREQ (2, 91)
# define __CPU_ZERO_S(setsize, cpusetp) \
do __builtin_memset (cpusetp, '\0', setsize); while (0)
# else
# define __CPU_ZERO_S(setsize, cpusetp) \
do { \
size_t __i; \
size_t __imax = (setsize) / sizeof (__cpu_mask); \
__cpu_mask *__bits = (cpusetp)->__bits; \
for (__i = 0; __i < __imax; ++__i) \
__bits[__i] = 0; \
} while (0)
# endif
# define __CPU_SET_S(cpu, setsize, cpusetp) \
(__extension__ \
({ size_t __cpu = (cpu); \
__cpu < 8 * (setsize) \
? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
|= __CPUMASK (__cpu)) \
: 0; }))
# define __CPU_CLR_S(cpu, setsize, cpusetp) \
(__extension__ \
({ size_t __cpu = (cpu); \
__cpu < 8 * (setsize) \
? (((__cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
&= ~__CPUMASK (__cpu)) \
: 0; }))
# define __CPU_ISSET_S(cpu, setsize, cpusetp) \
(__extension__ \
({ size_t __cpu = (cpu); \
__cpu < 8 * (setsize) \
? ((((__const __cpu_mask *) ((cpusetp)->__bits))[__CPUELT (__cpu)] \
& __CPUMASK (__cpu))) != 0 \
: 0; }))
# define __CPU_COUNT_S(setsize, cpusetp) \
__sched_cpucount (setsize, cpusetp)
# if __GNUC_PREREQ (2, 91)
# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
(__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0)
# else
# define __CPU_EQUAL_S(setsize, cpusetp1, cpusetp2) \
(__extension__ \
({ __const __cpu_mask *__arr1 = (cpusetp1)->__bits; \
__const __cpu_mask *__arr2 = (cpusetp2)->__bits; \
size_t __imax = (setsize) / sizeof (__cpu_mask); \
size_t __i; \
for (__i = 0; __i < __imax; ++__i) \
if (__bits[__i] != __bits[__i]) \
break; \
__i == __imax; }))
# endif
# define __CPU_OP_S(setsize, destset, srcset1, srcset2, op) \
(__extension__ \
({ cpu_set_t *__dest = (destset); \
__const __cpu_mask *__arr1 = (srcset1)->__bits; \
__const __cpu_mask *__arr2 = (srcset2)->__bits; \
size_t __imax = (setsize) / sizeof (__cpu_mask); \
size_t __i; \
for (__i = 0; __i < __imax; ++__i) \
((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i]; \
__dest; }))
# define __CPU_ALLOC_SIZE(count) \
((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask))
# define __CPU_ALLOC(count) __sched_cpualloc (count)
# define __CPU_FREE(cpuset) __sched_cpufree (cpuset)
__BEGIN_DECLS
extern int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp)
__THROW;
extern cpu_set_t *__sched_cpualloc (size_t __count) __THROW __wur;
extern void __sched_cpufree (cpu_set_t *__set) __THROW;
__END_DECLS
#endif

View File

@ -0,0 +1,93 @@
/* Copyright (C) 1995-1998, 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_SEM_H
# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
#endif
#include <sys/types.h>
/* Flags for `semop'. */
#define SEM_UNDO 0x1000 /* undo the operation on exit */
/* Commands for `semctl'. */
#define GETPID 4 /* get sempid */
#define GETVAL 5 /* get semval */
#define GETALL 6 /* get all semval's */
#define GETNCNT 3 /* get semncnt */
#define GETZCNT 7 /* get semzcnt */
#define SETVAL 8 /* set semval */
#define SETALL 9 /* set all semval's */
#ifdef __USE_MISC
# define SEM_R IPC_R /* read permission for user */
# define SEM_A IPC_W /* alter permission for user */
#endif
/* Data structure describing a set of semaphores. */
struct semid_ds
{
struct ipc_perm sem_perm; /* operation permission struct */
void *__sem_base; /* pointer to first semaphore in set */
unsigned short sem_nsems; /* number of sems in set */
__time_t sem_otime; /* last operation time */
__time_t sem_ctime; /* last change time */
/* Times measured in secs since */
/* 00:00:00 GMT, Jan. 1, 1970 */
};
/* 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 10
# define SEM_INFO 11
/*
* semaphore info struct
*/
struct seminfo {
int semmap, /* # of entries in semaphore map */
semmni, /* # of semaphore identifiers */
semmns, /* # of semaphores in system */
semmnu, /* # of undo structures in system */
semmsl, /* max # of semaphores per id */
semopm, /* max # of operations per semop call */
semume, /* max # of undo entries per process */
semusz, /* size in bytes of undo structure */
semvmx, /* semaphore maximum value */
semaem; /* adjust on exit max value */
};
#endif

View File

@ -0,0 +1,89 @@
/* Copyright (C) 1995-1997, 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; 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 <bits/shm.h> directly; use <sys/shm.h> instead."
#endif
#include <bits/types.h>
/* Permission flag for shmget. */
#ifdef __USE_MISC
# define SHM_R IPC_R /* read permission for user */
# define SHM_W IPC_W /* write permission for user */
#endif
/* Flags for `shmat'. */
#define SHM_RDONLY 010000 /* attach read-only else read-write */
#define SHM_RND 020000 /* round attach address to SHMLBA */
/* 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 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 */
__pid_t shm_lpid; /* pid of last shmop */
__pid_t shm_cpid; /* pid of creator */
shmatt_t shm_nattch; /* number of current attaches */
__time_t shm_atime; /* time of last shmat() */
__time_t shm_dtime; /* time of last shmdt() */
__time_t shm_ctime; /* time of last change by shmctl() */
};
#ifdef __USE_MISC
/* ipcs ctl commands */
# define SHM_STAT 13
# define SHM_INFO 14
struct shminfo
{
int shmmax, /* max shared memory segment size (bytes) */
shmmin, /* min shared memory segment size (bytes) */
shmmni, /* max number of shared memory identifiers */
shmseg, /* max shared memory segments per process */
shmall; /* max amount of shared memory (pages) */
};
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

View File

@ -0,0 +1,76 @@
/* Copyright (C) 1991-1992,1996-1998,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 _SIGNAL_H
# error "Never include <bits/sigaction.h> directly; use <signal.h> instead."
#endif
/* These definitions match those used by the FreeBSD kernel. */
/* 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
/* Special flags. */
int sa_flags;
/* Additional set of signals to be blocked. */
__sigset_t sa_mask;
};
/* Bits in `sa_flags'. */
#if defined __USE_UNIX98 || defined __USE_MISC
# define SA_ONSTACK 0x0001 /* Take signal on signal stack. */
# define SA_RESTART 0x0002 /* Restart syscall on signal return. */
# define SA_RESETHAND 0x0004 /* Reset to SIG_DFL on entry to handler. */
# define SA_NODEFER 0x0010 /* Don't automatically block the signal when
its handler is being executed. */
# define SA_NOCLDWAIT 0x0020 /* Don't save zombie processes. */
# define SA_SIGINFO 0x0040 /* Provide additional info to the handler. */
#endif
#define SA_NOCLDSTOP 0x0008 /* Don't send SIGCHLD when children stop. */
#ifdef __USE_MISC
# define SA_INTERRUPT 0 /* Historical no-op ("not SA_RESTART"). */
/* 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 1 /* Block signals. */
#define SIG_UNBLOCK 2 /* Unblock signals. */
#define SIG_SETMASK 3 /* Set the set of blocked signals. */

View File

@ -0,0 +1,282 @@
/* siginfo_t, sigevent and constants. FreeBSD version.
Copyright (C) 1997-1998, 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; 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 <signal.h> instead"
#endif
#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
#include <bits/types.h> /* __pid_t, __uid_t */
typedef struct siginfo
{
int si_signo; /* Signal number. */
int si_errno; /* If non-zero, an errno value associated with
this signal, as defined in <errno.h>. */
int si_code; /* Signal code. */
__pid_t si_pid; /* Sending process ID. */
__uid_t si_uid; /* Real user ID of sending process. */
int si_status; /* Exit value or signal. */
void *si_addr; /* Address of faulting instruction. */
union sigval si_value; /* Signal value. */
union
{
struct
{
int _trapno; /* machine specific trap code */
} _fault;
/* POSIX.1b timers. */
struct
{
int _timerid;
int _overrun;
} _timer;
struct
{
int _mqd;
} _mesgq;
/* SIGPOLL. */
struct
{
long _band; /* band event for SIGPOLL. */
} _poll;
struct
{
long __spare1__;
int __spare2__[7];
} __spare__;
} _reason;
} siginfo_t;
/* X/Open requires some more fields with fixed names. */
# define si_int si_value.sival_int
# define si_ptr si_value.sival_ptr
# define si_trapno _reason._fault._trapno
# define si_timerid _reason._timer._timerid
# define si_overrun _reason._timer._overrun
# define si_mqd _reason._mesgq._mqd
# define si_band _reason._poll._band
/* Values for `si_code'. Positive values are reserved for kernel-generated
signals. */
enum
{
SI_ASYNCIO = 0x10004, /* Sent by AIO completion. */
# define SI_ASYNCIO SI_ASYNCIO
SI_MESGQ = 0x10005, /* Sent by real time mesq state change. */
# define SI_MESGQ SI_MESGQ
SI_TIMER = 0x10003, /* Sent by timer expiration. */
# define SI_TIMER SI_TIMER
SI_QUEUE = 0x10002, /* Sent by sigqueue. */
# define SI_QUEUE SI_QUEUE
SI_USER = 0x10001, /* Sent by kill, sigsend, raise. */
# define SI_USER SI_USER
SI_KERNEL = 0x10006,
# define SI_KERNEL SI_KERNEL
SI_LWP = 0x10007, /* Sent by thr_kill. */
# define SI_LWP SI_LWP
SI_UNDEFINED = 0
# define SI_UNDEFINED SI_UNDEFINED
};
/* `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_INTOVF = 1, /* Integer overflow. */
# define FPE_INTOVF FPE_INTOVF
FPE_INTDIV, /* Integer divide by zero. */
# define FPE_INTDIV FPE_INTDIV
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. */
/* XXX These are only used by the waitid() function, not by the kernel. */
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
#include <sys/_types.h> /* __lwpid_t */
/* Forward declaration. */
# ifndef __have_pthread_attr_t
typedef union pthread_attr_t pthread_attr_t;
# define __have_pthread_attr_t 1
# endif
/* Structure to transport application-defined values with signals. */
typedef struct sigevent
{
int sigev_notify;
int sigev_signo;
sigval_t sigev_value;
union
{
__lwpid_t threadid;
struct
{
void (*_function) (sigval_t); /* Function to start. */
pthread_attr_t *_attribute; /* Really pthread_attr_t. */
} _sigev_thread;
} _sigev_un;
} sigevent_t;
#define sigev_notify_kqueue sigev_signo
#define sigev_notify_function _sigev_un._sigev_thread._function
#define sigev_notify_attributes _sigev_un._sigev_thread._attribute
#define sigev_notify_thread_id _sigev_un.threadid
/* `sigev_notify' values. */
enum
{
SIGEV_SIGNAL = 1, /* Notify via signal. */
# define SIGEV_SIGNAL SIGEV_SIGNAL
SIGEV_NONE = 0, /* Other notification: meaningless. */
# define SIGEV_NONE SIGEV_NONE
/* Not yet supported by the kernel. */
SIGEV_THREAD = 2, /* Deliver via thread creation. */
# define SIGEV_THREAD SIGEV_THREAD
SIGEV_KEVENT = 3,
# define SIGEV_KEVENT SIGEV_KEVENT
SIGEV_THREAD_ID = 4,
# define SIGEV_THREAD_ID SIGEV_THREAD_ID
};
#endif /* have _SIGNAL_H. */

View File

@ -0,0 +1,84 @@
/* Signal number definitions. FreeBSD version.
Copyright (C) 1991-1993, 1996, 1998, 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. */
#ifdef _SIGNAL_H
/* This file defines the fake signal functions and signal
number constants for 4.2 or 4.3 BSD-derived Unix system. */
/* 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. */
#define SIG_CATCH ((__sighandler_t) 2) /* FreeBSD specific ? */
#define SIG_HOLD ((__sighandler_t) 3) /* Add signal to hold mask. */
/* Signals. */
#define SIGHUP 1 /* Hangup (POSIX). */
#define SIGINT 2 /* Interrupt (ANSI). */
#define SIGQUIT 3 /* Quit (POSIX). */
#define SIGILL 4 /* Illegal instruction (ANSI). */
#define SIGABRT SIGIOT /* Abort (ANSI). */
#define SIGTRAP 5 /* Trace trap (POSIX). */
#define SIGIOT 6 /* IOT trap (4.2 BSD). */
#define SIGEMT 7 /* EMT trap (4.2 BSD). */
#define SIGFPE 8 /* Floating-point exception (ANSI). */
#define SIGKILL 9 /* Kill, unblockable (POSIX). */
#define SIGBUS 10 /* Bus error (4.2 BSD). */
#define SIGSEGV 11 /* Segmentation violation (ANSI). */
#define SIGSYS 12 /* Bad argument to system call (4.2 BSD). */
#define SIGPIPE 13 /* Broken pipe (POSIX). */
#define SIGALRM 14 /* Alarm clock (POSIX). */
#define SIGTERM 15 /* Termination (ANSI). */
#define SIGURG 16 /* Urgent condition on socket (4.2 BSD). */
#define SIGSTOP 17 /* Stop, unblockable (POSIX). */
#define SIGTSTP 18 /* Keyboard stop (POSIX). */
#define SIGCONT 19 /* Continue (POSIX). */
#define SIGCHLD 20 /* Child status has changed (POSIX). */
#define SIGCLD SIGCHLD /* Same as SIGCHLD (System V). */
#define SIGTTIN 21 /* Background read from tty (POSIX). */
#define SIGTTOU 22 /* Background write to tty (POSIX). */
#define SIGIO 23 /* I/O now possible (4.2 BSD). */
#define SIGPOLL SIGIO /* Pollable event occurred (System V). */
#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 SIGINFO 29 /* Information request (4.4 BSD). */
#define SIGUSR1 30 /* User-defined signal 1 (POSIX). */
#define SIGUSR2 31 /* User-defined signal 2 (POSIX). */
/* Signals 32 and 33 are reserved for system libraries. */
/* Signal 34 is used (but not reserved) by thread library.
See PTHREAD_SIGBASE in kernel-features.h. */
#define _NSIG 129 /* 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 65 /* be in sync with FreeBSD kernel */
#define __SIGRTMAX 126 /* be in sync with FreeBSD kernel */
#endif /* <signal.h> included. */

View File

@ -0,0 +1,140 @@
/* __sig_atomic_t, __sigset_t, and related definitions. FreeBSD version.
Copyright (C) 1994-1996, 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 _SIGSET_H_types
# define _SIGSET_H_types 1
typedef int __sig_atomic_t;
/* A `sigset_t' has a bit for each signal. */
__extension__ typedef struct
{
__extension__ union
{
unsigned int __sigbits[4];
unsigned int __bits[4];
};
} __sigset_t;
#endif
/* We only want to define these functions if <signal.h> 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 int) 1 << ((sig) - 1) % 32)
/* Return the word index for SIG. */
# define __sigword(sig) (((sig) - 1) >> 5)
# if defined __GNUC__ && __GNUC__ >= 2
# define __sigemptyset(set) \
(__extension__ ({ sigset_t *__set = (set); \
__set->__sigbits[0] = 0; __set->__sigbits[1] = 0; \
__set->__sigbits[2] = 0; __set->__sigbits[3] = 0; \
0; }))
# define __sigfillset(set) \
(__extension__ ({ sigset_t *__set = (set); \
__set->__sigbits[0] = ~0; __set->__sigbits[1] = ~0; \
__set->__sigbits[2] = ~0; __set->__sigbits[3] = ~0; \
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__ ({ const sigset_t *__set = (set); \
__set->__sigbits[0] == 0 \
&& __set->__sigbits[1] == 0 \
&& __set->__sigbits[2] == 0 \
&& __set->__sigbits[3] == 0; }))
# define __sigandset(dest, left, right) \
(__extension__ ({ sigset_t *__dest = (dest); \
const sigset_t *__left = (left); \
const sigset_t *__right = (right); \
__dest->__sigbits[0] = \
__left->__sigbits[0] & __right->__sigbits[0]; \
__dest->__sigbits[1] = \
__left->__sigbits[1] & __right->__sigbits[1]; \
__dest->__sigbits[2] = \
__left->__sigbits[2] & __right->__sigbits[2]; \
__dest->__sigbits[3] = \
__left->__sigbits[3] & __right->__sigbits[3]; \
0; }))
# define __sigorset(dest, left, right) \
(__extension__ ({ sigset_t *__dest = (dest); \
const sigset_t *__left = (left); \
const sigset_t *__right = (right); \
__dest->__sigbits[0] = \
__left->__sigbits[0] | __right->__sigbits[0]; \
__dest->__sigbits[1] = \
__left->__sigbits[1] | __right->__sigbits[1]; \
__dest->__sigbits[2] = \
__left->__sigbits[2] | __right->__sigbits[2]; \
__dest->__sigbits[3] = \
__left->__sigbits[3] | __right->__sigbits[3]; \
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
_EXTERN_INLINE int
__sigismember (__const __sigset_t *__set, int __sig)
{
return (__set->__sigbits[__sigword (__sig)] & __sigmask (__sig) ? 1 : 0);
}
_EXTERN_INLINE int
__sigaddset (__sigset_t *__set, int __sig)
{
__set->__sigbits[__sigword (__sig)] |= __sigmask (__sig);
return 0;
}
_EXTERN_INLINE int
__sigdelset (__sigset_t *__set, int __sig)
{
__set->__sigbits[__sigword (__sig)] &= ~__sigmask (__sig);
return 0;
}
# endif
#endif /* ! _SIGSET_H_fns. */

View File

@ -0,0 +1,431 @@
/* System-specific socket constants and types. FreeBSD version.
Copyright (C) 1991-1992,1994-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 Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library 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_SOCKET_H
#define __BITS_SOCKET_H 1
#if !defined _SYS_SOCKET_H && !defined _NETINET_IN_H
# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
#endif
#define __need_size_t
#define __need_NULL
#include <stddef.h>
#include <limits.h> /* XXX Is this allowed? */
#include <bits/types.h>
/* 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
/* Flags to be ORed into the type parameter of socket and socketpair and
used for the flags parameter of paccept. */
SOCK_CLOEXEC = 0x10000000, /* Atomically set close-on-exec flag for the
new descriptor(s). */
#define SOCK_CLOEXEC SOCK_CLOEXEC
SOCK_NONBLOCK = 0x20000000 /* Atomically mark descriptor(s) as
non-blocking. */
#define SOCK_NONBLOCK SOCK_NONBLOCK
};
/*
* Structure used by kernel to pass protocol
* information in raw sockets.
*/
struct sockproto {
unsigned short sp_family; /* address family */
unsigned short sp_protocol; /* protocol */
};
/* 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 /* POSIX name for PF_LOCAL. */
#define PF_INET 2 /* IP protocol family. */
#define PF_IMPLINK 3 /* ARPAnet IMP protocol. */
#define PF_PUP 4 /* PUP protocols. */
#define PF_CHAOS 5 /* MIT Chaos protocols. */
#define PF_NETBIOS 6 /* SMB protocols. */
#define PF_ISO 7 /* ISO protocols. */
#define PF_OSI PF_ISO
#define PF_ECMA 8 /* ECMA protocols. */
#define PF_DATAKIT 9 /* AT&T Datakit protocols. */
#define PF_CCITT 10 /* CCITT protocols (X.25 et al). */
#define PF_SNA 11 /* IBM SNA protocol. */
#define PF_DECnet 12 /* DECnet protocols. */
#define PF_DLI 13 /* Direct data link interface. */
#define PF_LAT 14 /* DEC Local Area Transport protocol. */
#define PF_HYLINK 15 /* NSC Hyperchannel protocol. */
#define PF_APPLETALK 16 /* Don't use this. */
#define PF_ROUTE 17 /* Internal Routing Protocol. */
#define PF_LINK 18 /* Link layer interface. */
#define PF_XTP 19 /* eXpress Transfer Protocol (no AF). */
#define PF_COIP 20 /* Connection-oriented IP, aka ST II. */
#define PF_CNT 21 /* Computer Network Technology. */
#define PF_RTIP 22 /* Help Identify RTIP packets. **/
#define PF_IPX 23 /* Novell Internet Protocol. */
#define PF_SIP 24 /* Simple Internet Protocol. */
#define PF_PIP 25 /* Help Identify PIP packets. */
#define PF_ISDN 26 /* Integrated Services Digital Network. */
#define PF_KEY 27 /* Internal key-management function. */
#define PF_INET6 28 /* IP version 6. */
#define PF_NATM 29 /* Native ATM access. */
#define PF_ATM 30 /* ATM. */
#define PF_HDRCMPLT 31 /* Used by BPF to not rewrite headers in
interface output routine. */
#define PF_NETGRAPH 32 /* Netgraph sockets. */
#define PF_MAX 33
/* 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_IMPLINK PF_IMPLINK
#define AF_PUP PF_PUP
#define AF_CHAOS PF_CHAOS
#define AF_NETBIOS PF_NETBIOS
#define AF_ISO PF_ISO
#define AF_OSI PF_OSI
#define AF_ECMA PF_ECMA
#define AF_DATAKIT PF_DATAKIT
#define AF_CCITT PF_CCITT
#define AF_SNA PF_SNA
#define AF_DECnet PF_DECnet
#define AF_DLI PF_DLI
#define AF_LAT PF_LAT
#define AF_HYLINK PF_HYLINK
#define AF_APPLETALK PF_APPLETALK
#define AF_ROUTE PF_ROUTE
#define AF_LINK PF_LINK
#define pseudo_AF_XTP PF_XTP
#define AF_COIP PF_COIP
#define AF_CNT PF_CNT
#define pseudo_AF_RTIP PF_RTIP
#define AF_IPX PF_IPX
#define AF_SIP PF_SIP
#define pseudo_AF_PIP PF_PIP
#define AF_ISDN PF_ISDN
#define AF_E164 AF_ISDN /* CCITT E.164 recommendation. */
#define pseudo_AF_KEY PF_KEY
#define AF_INET6 PF_INET6
#define AF_NATM PF_NATM
#define AF_ATM PF_ATM
#define pseudo_AF_HDRCMPLT PF_HDRCMPLT
#define AF_NETGRAPH PF_NETGRAPH
#define AF_MAX PF_MAX
/* Maximum queue length specifiable by listen. */
#define SOMAXCONN 128 /* 5 on the original 4.4 BSD. */
/* Get the definition of the macro to define the common sockaddr members. */
#include <bits/sockaddr.h>
/* 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). */
#if ULONG_MAX > 0xffffffff
# define __ss_aligntype __uint64_t
#else
# define __ss_aligntype __uint32_t
#endif
#define _SS_PADSIZE \
(_SS_SIZE - __SOCKADDR_COMMON_SIZE - sizeof (__ss_aligntype))
struct sockaddr_storage
{
__SOCKADDR_COMMON (ss_); /* Address family, etc. */
char __ss_padding[_SS_PADSIZE];
__ss_aligntype __ss_align; /* Force desired alignment. */
};
/* 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
MSG_EOR = 0x08, /* Data completes record. */
#define MSG_EOR MSG_EOR
MSG_TRUNC = 0x10, /* Data discarded before delivery. */
#define MSG_TRUNC MSG_TRUNC
MSG_CTRUNC = 0x20, /* Control data lost before delivery. */
#define MSG_CTRUNC MSG_CTRUNC
MSG_WAITALL = 0x40, /* Wait for full request or error. */
#define MSG_WAITALL MSG_WAITALL
MSG_DONTWAIT = 0x80, /* This message should be nonblocking. */
#define MSG_DONTWAIT MSG_DONTWAIT
MSG_EOF = 0x100, /* Data completes connection. */
#define MSG_EOF MSG_EOF
MSG_NOTIFICATION = 0x2000,/* SCTP notification */
#define MSG_NOTIFICATION MSG_NOTIFICATION
MSG_NBIO = 0x4000,/*FIONBIO mode, used by fifofs */
#define MSG_NBIO MSG_NBIO
MSG_COMPAT = 0x8000,/* Used in sendit(). */
#define MSG_COMPAT MSG_COMPAT
MSG_NOSIGNAL = 0x20000 /* do not generate SIGPIPE on EOF */
#define MSG_NOSIGNAL MSG_NOSIGNAL
};
/* Structure describing messages sent by
`sendmsg' and received by `recvmsg'. */
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. */
int msg_iovlen; /* Number of elements in the vector. */
void *msg_control; /* Ancillary data (eg BSD filedesc passing). */
socklen_t msg_controllen; /* Ancillary data buffer length. */
int msg_flags; /* Flags in received message. */
};
/* Structure used for storage of ancillary data object information. */
struct cmsghdr
{
socklen_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 __glibc_c99_flexarr_available
__extension__ unsigned char __cmsg_data __flexarr __attribute__ ((aligned (__alignof__(size_t)))); /* Ancillary data. */
#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))
/* Ancillary data object manipulation macros. */
#if __glibc_c99_flexarr_available
# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
#else
# define CMSG_DATA(cmsg) ((unsigned char *) (cmsg) + CMSG_ALIGN(sizeof (struct cmsghdr)))
#endif
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. */
enum
{
SCM_RIGHTS = 0x01, /* Access rights (array of int). */
#define SCM_RIGHTS SCM_RIGHTS
SCM_TIMESTAMP = 0x02, /* Timestamp (struct timeval). */
#define SCM_TIMESTAMP SCM_TIMESTAMP
SCM_CREDS = 0x03 /* Process creds (struct cmsgcred). */
#define SCM_CREDS SCM_CREDS
};
/* Unfortunately, BSD practice dictates this structure be of fixed size.
If there are more than CMGROUP_MAX groups, the list is truncated.
(On GNU systems, the `cmcred_euid' field is just the first in the
list of effective UIDs.) */
#define CMGROUP_MAX 16
/* Structure delivered by SCM_CREDS. This describes the identity of the
sender of the data simultaneously received on the socket. By BSD
convention, this is included only when a sender on a AF_LOCAL socket
sends cmsg data of this type and size; the sender's structure is
ignored, and the system fills in the various IDs of the sender process. */
struct cmsgcred
{
__pid_t cmcred_pid;
__uid_t cmcred_uid;
__uid_t cmcred_euid;
__gid_t cmcred_gid;
short cmcred_ngroups;
__gid_t cmcred_groups[CMGROUP_MAX];
};
/* Protocol number used to manipulate socket-level options
with `getsockopt' and `setsockopt'. */
#define SOL_SOCKET 0xffff
/* Socket-level options for `getsockopt' and `setsockopt'. */
enum
{
SO_DEBUG = 0x0001, /* Record debugging information. */
#define SO_DEBUG SO_DEBUG
SO_ACCEPTCONN = 0x0002, /* Accept connections on socket. */
#define SO_ACCEPTCONN SO_ACCEPTCONN
SO_REUSEADDR = 0x0004, /* Allow reuse of local addresses. */
#define SO_REUSEADDR SO_REUSEADDR
SO_KEEPALIVE = 0x0008, /* Keep connections alive and send
SIGPIPE when they die. */
#define SO_KEEPALIVE SO_KEEPALIVE
SO_DONTROUTE = 0x0010, /* Don't do local routing. */
#define SO_DONTROUTE SO_DONTROUTE
SO_BROADCAST = 0x0020, /* Allow transmission of
broadcast messages. */
#define SO_BROADCAST SO_BROADCAST
SO_USELOOPBACK = 0x0040, /* Use the software loopback to avoid
hardware use when possible. */
#define SO_USELOOPBACK SO_USELOOPBACK
SO_LINGER = 0x0080, /* Block on close of a reliable
socket to transmit pending data. */
#define SO_LINGER SO_LINGER
SO_OOBINLINE = 0x0100, /* Receive out-of-band data in-band. */
#define SO_OOBINLINE SO_OOBINLINE
SO_REUSEPORT = 0x0200, /* Allow local address and port reuse. */
#define SO_REUSEPORT SO_REUSEPORT
SO_TIMESTAMP = 0x0400, /* Timestamp received dgram traffic. */
#define SO_TIMESTAMP SO_TIMESTAMP
SO_SNDBUF = 0x1001, /* Send buffer size. */
#define SO_SNDBUF SO_SNDBUF
SO_RCVBUF = 0x1002, /* Receive buffer. */
#define SO_RCVBUF SO_RCVBUF
SO_SNDLOWAT = 0x1003, /* Send low-water mark. */
#define SO_SNDLOWAT SO_SNDLOWAT
SO_RCVLOWAT = 0x1004, /* Receive low-water mark. */
#define SO_RCVLOWAT SO_RCVLOWAT
SO_SNDTIMEO = 0x1005, /* Send timeout. */
#define SO_SNDTIMEO SO_SNDTIMEO
SO_RCVTIMEO = 0x1006, /* Receive timeout. */
#define SO_RCVTIMEO SO_RCVTIMEO
SO_ERROR = 0x1007, /* Get and clear error status. */
#define SO_ERROR SO_ERROR
SO_STYLE = 0x1008, /* Get socket connection style. */
#define SO_STYLE SO_STYLE
SO_TYPE = SO_STYLE, /* Compatible name for SO_STYLE. */
#define SO_TYPE SO_TYPE
SO_LABEL = 0x1009,
#define SO_LABEL SO_LABEL
SO_PEERLABEL = 0x1010,
#define SO_PEERLABEL SO_PEERLABEL
SO_LISTENQLIMIT = 0x1011,
#define SO_LISTENQLIMIT SO_LISTENQLIMIT
SO_LISTENQLEN = 0x1012,
#define SO_LISTENQLEN SO_LISTENQLEN
SO_LISTENINCQLEN = 0x1013,
#define SO_LISTENINCQLEN SO_LISTENINCQLEN
SO_SETFIB = 0x1014,
#define SO_SETFIB SO_SETFIB
SO_USER_COOKIE = 0x1015,
#define SO_USER_COOKIE SO_USER_COOKIE
SO_PROTOCOL = 0x1016,
#define SO_PROTOCOL SO_PROTOCOL
SO_PROTOTYPE = SO_PROTOCOL
#define SO_PROTOTYPE SO_PROTOTYPE
};
/* Socket options. */
#define LOCAL_PEERCRED 0x001 /* retrieve peer credentials */
#define LOCAL_CREDS 0x002 /* pass credentials to receiver */
#define LOCAL_CONNWAIT 0x004 /* connects block until accepted */
/* Structure used to manipulate the SO_LINGER option. */
struct linger
{
int l_onoff; /* Nonzero to linger on close. */
int l_linger; /* Time to linger. */
};
/* Magic IPv4 addresses defined in FreeBSD version of <netinet/in.h>, but not
included in Glibc version of the same header. */
#define INADDR_ALLRPTS_GROUP (uint32_t)0xe0000016 /* 224.0.0.22, IGMPv3 */
#define INADDR_CARP_GROUP (uint32_t)0xe0000012 /* 224.0.0.18 */
#define INADDR_PFSYNC_GROUP (uint32_t)0xe00000f0 /* 224.0.0.240 */
#define INADDR_ALLMDNS_GROUP (uint32_t)0xe00000fb /* 224.0.0.251 */
#ifdef __USE_MISC
struct sf_hdtr;
__BEGIN_DECLS
extern int bsd_sendfile (int __in_fd, int __out_sock,
__off_t __in_offset, size_t __nbytes,
struct sf_hdtr *__hdtr, __off_t *__sockbytes,
int __flags) __THROW;
__END_DECLS
#endif /* Use BSD */
#endif /* bits/socket.h */

View File

@ -0,0 +1,219 @@
/* Copyright (C) 1992, 1996-1997, 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; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#if !defined _SYS_STAT_H && !defined _FCNTL_H
# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
#endif
#ifndef _BITS_STAT_H
#define _BITS_STAT_H 1
/* This structure needs to be defined in accordance with the
implementation of __stat, __fstat, and __lstat. */
#include <bits/types.h>
/* Versions of the 'struct stat' data structure. */
#define _STAT_VER_ostat 0 /* 'struct ostat' in /usr/src/sys/sys/stat.h */
#define _STAT_VER_stat 1 /* 'struct stat' in /usr/src/sys/sys/stat.h */
#define _STAT_VER_nstat 2 /* 'struct nstat' in /usr/src/sys/sys/stat.h */
#define _STAT_VER_gstat 3 /* glibc's 'struct stat' without LFS */
/* By default we use _STAT_VER_gstat, but we support also _STAT_VER_stat */
#define _STAT_VER _STAT_VER_gstat
/* Structure describing file characteristics. */
struct stat
{
__dev_t st_dev; /* Device containing the file. */
#ifndef __USE_FILE_OFFSET64
__ino_t st_ino; /* File serial number. */
#else
__ino64_t st_ino; /* File serial number. */
#endif
__mode_t st_mode; /* File mode. */
__mode_t __pad_mode; /* __mode_t is 16 bit, fill to 32 bit to retain previous ABI */
__nlink_t st_nlink; /* Link count. */
__nlink_t __pad_nlink; /* __nlink_t is 16 bit, fill to 32 bit to retain previous ABI */
__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. */
#if defined __USE_MISC || defined __USE_XOPEN2K8
/* 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 <sys/stat.h> 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. */
long int st_atimensec; /* Nanoseconds of last access. */
__time_t st_mtime; /* Time of last modification. */
long int st_mtimensec; /* Nanoseconds of last modification. */
__time_t st_ctime; /* Time of last status change. */
long int st_ctimensec; /* Nanoseconds of last status change. */
#endif
__off_t st_size; /* Size of file, in bytes. */
__blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */
__blksize_t st_blksize; /* Optimal block size for I/O. */
#define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
__uint32_t st_flags; /* User defined flags. */
__uint32_t st_gen; /* Generation number. */
__uint64_t __unused1[2];
};
#ifdef __USE_LARGEFILE64
struct stat64
{
__dev_t st_dev; /* Device containing the file. */
__ino64_t st_ino; /* File serial number. */
__mode_t st_mode; /* File mode. */
__mode_t __pad_mode; /* __mode_t is 16 bit, fill to 32 bit to retain previous ABI */
__nlink_t st_nlink; /* Link count. */
__nlink_t __pad_nlink; /* __nlink_t is 16 bit, fill to 32 bit to retain previous ABI */
__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. */
#if defined __USE_MISC || defined __USE_XOPEN2K8
/* 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 <sys/stat.h> 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. */
long int st_atimensec; /* Nanoseconds of last access. */
__time_t st_mtime; /* Time of last modification. */
long int st_mtimensec; /* Nanoseconds of last modification. */
__time_t st_ctime; /* Time of last status change. */
long int st_ctimensec; /* Nanoseconds of last status change. */
#endif
__off_t st_size; /* Size of file, in bytes. */
__blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */
__blksize_t st_blksize; /* Optimal block size for I/O. */
__uint32_t st_flags; /* User defined flags. */
__uint32_t st_gen; /* Generation number. */
__uint64_t __unused1[2];
};
#endif
/* Encoding of the file mode. These are the standard Unix values,
but POSIX.1 does not specify what values should be used. */
#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_IFLNK 0120000 /* Symbolic link. */
#define __S_IFSOCK 0140000 /* Socket. */
#define __S_IFWHT 0160000 /* Whiteout. */
#define __S_IFIFO 0010000 /* FIFO. */
/* POSIX.1b objects. */
#define __S_TYPEISMQ(buf) 0
#define __S_TYPEISSEM(buf) 0
#define __S_TYPEISSHM(buf) 0
/* 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. */
#ifdef __USE_MISC
/* Definitions of flags stored in file flags word. */
/* Super-user and owner changeable flags. */
# define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
# define UF_NODUMP 0x00000001 /* do not dump file */
# define UF_IMMUTABLE 0x00000002 /* file may not be changed */
# define UF_APPEND 0x00000004 /* writes to file may only append */
# define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
# define UF_NOUNLINK 0x00000010 /* file may not be removed or renamed */
/* Super-user changeable flags. */
# define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
# define SF_ARCHIVED 0x00010000 /* file is archived */
# define SF_IMMUTABLE 0x00020000 /* file may not be changed */
# define SF_APPEND 0x00040000 /* writes to file may only append */
# define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */
# define SF_SNAPSHOT 0x00200000 /* snapshot inode */
__BEGIN_DECLS
/* Set file flags for FILE to FLAGS. */
extern int chflags (__const char *__file, unsigned long int __flags) __THROW;
/* Set file flags of the file referred to by FD to FLAGS. */
extern int fchflags (int __fd, unsigned long int __flags) __THROW;
/* Set file flags for FILE to FLAGS without following symlinks. */
extern int lchflags(__const char *__file, int __flags);
/* Get device name in /dev with a device number of dev and a file type
matching the one encoded in type. */
extern char *devname(__dev_t dev, __mode_t type) __THROW;
/* Store at most BUFLEN characters of the device name in /dev with a
device number of dev and a file type matching the one encoded in type. */
extern char *devname_r(__dev_t dev, __mode_t type, char *buf, int buflen) __THROW;
__END_DECLS
#endif /* __USE_MISC */
#endif /* bits/stat.h */

View File

@ -0,0 +1,56 @@
/* Copyright (C) 2002, 2006, 2010 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 structure corresponds to the standard FreeBSD 'struct stat'
(i.e. _STAT_VER_stat), and is used by the stat() system call family. */
struct stat16
{
__dev_t st_dev; /* Device containing the file. */
__ino_t st_ino; /* File serial number. */
__uint16_t st_mode; /* File mode. */
__uint16_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. */
struct timespec st_atimespec; /* time of last access */
struct timespec st_mtimespec; /* time of last data modification */
struct timespec st_ctimespec; /* time of last file status change */
__off_t st_size; /* Size of file, in bytes. */
__blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */
__blksize_t st_blksize; /* Optimal block size for I/O. */
__uint32_t st_flags; /* User defined flags. */
__uint32_t st_gen; /* Generation number. */
__uint32_t __unused1;
__time_t st_birthtime; /* Time of file creation. */
long int st_birthtimensec; /* Nanoseconds of file creation. */
#define _BIRTH_PADSIZE (16 - sizeof(__time_t) - sizeof (long int))
char __birth_padding[_BIRTH_PADSIZE];
};

View File

@ -0,0 +1,91 @@
/* Definition of `struct statfs', information about a filesystem.
Copyright (C) 1996-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 _BITS_STATFS_H
#define _BITS_STATFS_H 1
#if !defined _SYS_STATFS_H && !defined _SYS_MOUNT_H
# error "Never include <bits/statfs.h> directly; use <sys/statfs.h> instead."
#endif
#include <bits/types.h>
struct statfs
{
unsigned long f_version;
unsigned long f_bsize;
unsigned long f_iosize;
#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;
__uid_t f_owner;
int f_type;
int f_flags;
unsigned long int f_syncwrites;
unsigned long int f_asyncwrites;
char f_fstypename[16];
char f_mntonname[80];
unsigned long int f_syncreads;
unsigned long int f_asyncreads;
unsigned short f_namemax;
char f_mntfromname[80];
short __unused3;
long __unused4[2];
};
#ifdef __USE_LARGEFILE64
struct statfs64
{
unsigned long f_version;
unsigned long f_bsize;
unsigned long f_iosize;
__fsblkcnt64_t f_blocks;
__fsblkcnt64_t f_bfree;
__fsblkcnt64_t f_bavail;
__fsfilcnt64_t f_files;
__fsfilcnt64_t f_ffree;
__fsid_t f_fsid;
__uid_t f_owner;
int f_type;
int f_flags;
unsigned long int f_syncwrites;
unsigned long int f_asyncwrites;
char f_fstypename[16];
char f_mntonname[80];
unsigned long int f_syncreads;
unsigned long int f_asyncreads;
unsigned short f_namemax;
char f_mntfromname[80];
short __unused3;
long __unused4[2];
};
#endif
#endif /* _BITS_STATFS_H */

View File

@ -0,0 +1,97 @@
/* Definition of `struct statvfs', information about a filesystem.
Copyright (C) 1998, 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; 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 <bits/statvfs.h> directly; use <sys/statvfs.h> instead."
#endif
#include <bits/types.h>
#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;
unsigned 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;
unsigned int f_spare[6];
};
#endif
/* Definitions for the flag in `f_flag'. */
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_NOATIME = 0x10000000 /* Do not update access times. */
# define ST_NOATIME ST_NOATIME
#endif /* Use GNU. */
};

View File

@ -0,0 +1,33 @@
/* Declare sys_errlist and sys_nerr, or don't. Compatibility (do) version.
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 _STDIO_H
# error "Never include <bits/sys_errlist.h> directly; use <stdio.h> instead."
#endif
/* sys_errlist and sys_nerr are deprecated. Use strerror instead. */
#ifdef __USE_MISC
extern int sys_nerr;
extern __const char *__const sys_errlist[];
#endif
#ifdef __USE_GNU
extern int _sys_nerr;
extern __const char *__const _sys_errlist[];
#endif

View File

@ -0,0 +1,31 @@
/* <bits/syslog-path.h> -- _PATH_LOG definition
Copyright (C) 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_SYSLOG_H
# error "Never include this file directly. Use <sys/syslog.h> instead"
#endif
#ifndef _BITS_SYSLOG_PATH_H
#define _BITS_SYSLOG_PATH_H 1
/* On kFreeBSD, named pipes are not allowed in /dev (devfs), so we pick this
alternate path. */
#define _PATH_LOG "/var/run/log"
#endif /* bits/syslog-path.h */

View File

@ -0,0 +1,60 @@
/* Definitions of macros to access `dev_t' values. FreeBSD version.
Copyright (C) 1996-2017 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, see
<http://www.gnu.org/licenses/>. */
#ifndef _BITS_SYSMACROS_H
#define _BITS_SYSMACROS_H 1
#ifndef _SYS_SYSMACROS_H
# error "Never include <bits/sysmacros.h> directly; use <sys/sysmacros.h> instead."
#endif
/* The FreeBSD version of dev_t in glibc is a 32-bit quantity, with 8-bit
major and 24-bit minor numbers. The encoding is mmmmMMmm, where M is a
hex digit of the major number and m is a hex digit of the minor number. */
#define __SYSMACROS_DECLARE_MAJOR(DECL_TEMPL) \
DECL_TEMPL(unsigned int, major, (__dev_t __dev))
#define __SYSMACROS_DEFINE_MAJOR(DECL_TEMPL) \
__SYSMACROS_DECLARE_MAJOR (DECL_TEMPL) \
{ \
return ((__dev & (__dev_t) 0x0000ff00u) >> 8); \
}
#define __SYSMACROS_DECLARE_MINOR(DECL_TEMPL) \
DECL_TEMPL(unsigned int, minor, (__dev_t __dev))
#define __SYSMACROS_DEFINE_MINOR(DECL_TEMPL) \
__SYSMACROS_DECLARE_MINOR (DECL_TEMPL) \
{ \
return (__dev & (__dev_t) 0xffff00ff); \
}
#define __SYSMACROS_DECLARE_MAKEDEV(DECL_TEMPL) \
DECL_TEMPL(__dev_t, makedev, (unsigned int __major, unsigned int __minor))
#define __SYSMACROS_DEFINE_MAKEDEV(DECL_TEMPL) \
__SYSMACROS_DECLARE_MAKEDEV (DECL_TEMPL) \
{ \
__dev_t __dev; \
__dev = (((__dev_t) (__major & 0x000000ffu)) << 8); \
__dev |= (((__dev_t) (__minor & 0xffff00ffu)) << 0); \
return __dev; \
}
#endif /* bits/sysmacros.h */

View File

@ -0,0 +1,245 @@
/* termios type and macro definitions. FreeBSD version.
Copyright (C) 1993-1994,1996-1997,1999,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 _TERMIOS_H
# error "Never include <bits/termios.h> directly; use <termios.h> instead."
#endif
/* These macros are also defined in some <bits/ioctls.h> files (with
numerically identical values), but this serves to shut up cpp's
complaining. */
#ifdef __USE_MISC
# ifdef MDMBUF
# undef MDMBUF
# endif
# ifdef FLUSHO
# undef FLUSHO
# endif
# ifdef PENDIN
# undef PENDIN
# endif
#endif /* __USE_MISC */
#ifdef ECHO
# undef ECHO
#endif
#ifdef TOSTOP
# undef TOSTOP
#endif
#ifdef NOFLSH
# undef NOFLSH
#endif
typedef unsigned char cc_t;
typedef unsigned int speed_t;
typedef unsigned int tcflag_t;
#define NCCS 20
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_cc[NCCS]; /* control characters */
speed_t c_ispeed; /* input speed */
speed_t c_ospeed; /* output speed */
#define __ispeed c_ispeed
#define __ospeed c_ospeed
#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
};
/* c_cc characters */
#define VEOF 0
#define VEOL 1
#define VEOL2 2
#define VERASE 3
#define VWERASE 4
#define VKILL 5
#define VREPRINT 6
#ifdef __USE_MISC
# define VERASE2 7
#endif
#define VINTR 8
#define VQUIT 9
#define VSUSP 10
#ifdef __USE_MISC
# define VDSUSP 11
#endif
#define VSTART 12
#define VSTOP 13
#define VLNEXT 14
#define VDISCARD 15
#define VMIN 16
#define VTIME 17
#ifdef __USE_MISC
# define VSTATUS 18
#endif
/* 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 IXON 0001000
#define IXOFF 0002000
#define IXANY 0004000
#define IMAXBEL 0020000
/* c_oflag bits */
#define OPOST (1 << 0) /* Perform output processing. */
#define ONLCR (1 << 1) /* Map NL to CR-NL on output. */
#if defined __USE_MISC || defined __USE_XOPEN
# define TAB0 (0 << 2) /* no tab delay and expansion */
# define TAB3 (1 << 2) /* expand tabs to spaces */
# define TABDLY TAB3 /* tab delay mask */
# define OXTABS TAB3
# define XTABS TAB3
#endif
#ifdef __USE_MISC
# define ONOEOT (1 << 3) /* Discard EOT (^D) on output. */
#endif
#define OCRNL (1 << 4) /* map CR to NL on output */
#define ONOCR (1 << 5) /* no CR output at column 0 */
#define ONLRET (1 << 6) /* NL performs CR function */
/* c_cflag bit meaning */
#ifdef __USE_MISC
# define CIGNORE (1 << 0) /* Ignore these control flags. */
#endif
#define CSIZE (CS5|CS6|CS7|CS8) /* Number of bits per byte (mask). */
#define CS5 (0 << 8) /* 5 bits per byte. */
#define CS6 (1 << 8) /* 6 bits per byte. */
#define CS7 (2 << 8) /* 7 bits per byte. */
#define CS8 (3 << 8) /* 8 bits per byte. */
#define CSTOPB (1 << 10) /* Two stop bits instead of one. */
#define CREAD (1 << 11) /* Enable receiver. */
#define PARENB (1 << 12) /* Parity enable. */
#define PARODD (1 << 13) /* Odd parity instead of even. */
#define HUPCL (1 << 14) /* Hang up on last close. */
#define CLOCAL (1 << 15) /* Ignore modem status lines. */
#ifdef __USE_MISC
# define CCTS_OFLOW (1 << 16) /* CTS flow control of output. */
# define CRTS_IFLOW (1 << 17) /* RTS flow control of input. */
# define CRTSCTS (CCTS_OFLOW|CRTS_IFLOW) /* CTS/RTS flow control. */
# define CDTR_IFLOW (1 << 18) /* DTR flow control of input. */
# define CDSR_OFLOW (1 << 19) /* DSR flow control of output. */
# define CCAR_OFLOW (1 << 20) /* DCD flow control of output. */
# define MDMBUF (1 << 20) /* Carrier flow control of output. */
#endif
/* c_lflag bits */
#ifdef __USE_MISC
# define ECHOKE (1 << 0) /* Visual erase for KILL. */
#endif
#define ECHOE (1 << 1) /* Visual erase for ERASE. */
#define ECHOK (1 << 2) /* Echo NL after KILL. */
#define ECHO (1 << 3) /* Enable echo. */
#define ECHONL (1 << 4) /* Echo NL even if ECHO is off. */
#ifdef __USE_MISC
# define ECHOPRT (1 << 5) /* Hardcopy visual erase. */
# define ECHOCTL (1 << 6) /* Echo control characters as ^X. */
#endif
#define ISIG (1 << 7) /* Enable signals. */
#define ICANON (1 << 8) /* Do erase and kill processing. */
#ifdef __USE_MISC
# define ALTWERASE (1 << 9) /* Alternate WERASE algorithm. */
#endif
#define IEXTEN (1 << 10) /* Enable DISCARD and LNEXT. */
#ifdef __USE_MISC
# define EXTPROC (1 << 11) /* External processing. */
#endif
#define TOSTOP (1 << 22) /* Send SIGTTOU for background output. */
#ifdef __USE_MISC
# define FLUSHO (1 << 23) /* Output being flushed (state). */
# define NOKERNINFO (1 << 25) /* Disable VSTATUS. */
# define PENDIN (1 << 29) /* Retype pending input (state). */
#endif
#define NOFLSH (1 << 31) /* Disable flush after interrupt. */
/* Input and output baud rates. */
#define B0 0 /* Hang up. */
#define B50 50 /* 50 baud. */
#define B75 75 /* 75 baud. */
#define B110 110 /* 110 baud. */
#define B134 134 /* 134.5 baud. */
#define B150 150 /* 150 baud. */
#define B200 200 /* 200 baud. */
#define B300 300 /* 300 baud. */
#define B600 600 /* 600 baud. */
#define B1200 1200 /* 1200 baud. */
#define B1800 1800 /* 1800 baud. */
#define B2400 2400 /* 2400 baud. */
#define B4800 4800 /* 4800 baud. */
#define B9600 9600 /* 9600 baud. */
#define B19200 19200 /* 19200 baud. */
#define B38400 38400 /* 38400 baud. */
#define B76800 76800
#ifdef __USE_MISC
# define EXTA 19200
# define EXTB 38400
#endif
#define B7200 7200
#define B14400 14400
#define B28800 28800
#define B57600 57600
#define B115200 115200
#define B230400 230400
#define B460800 460800
#define B500000 500000
#define B576000 576000
#define B921600 921600
#define B1000000 1000000
#define B1152000 1152000
#define B1500000 1500000
#define B2000000 2000000
#define B2500000 2500000
#define B3000000 3000000
#define B3500000 3500000
#define B4000000 4000000
#define __MAX_BAUD B4000000
/* tcflow() and TCXONC use these */
#define TCOOFF 1
#define TCOON 2
#define TCIOFF 3
#define TCION 4
/* tcflush() and TCFLSH use these */
#define TCIFLUSH 1
#define TCOFLUSH 2
#define TCIOFLUSH 3
/* tcsetattr uses these */
#define TCSANOW 0
#define TCSADRAIN 1
#define TCSAFLUSH 2
#ifdef __USE_MISC
# define TCSASOFT 0x10 /* Flag: Don't alter hardware state. */
#endif

View File

@ -0,0 +1,87 @@
/* System-dependent timing definitions. FreeBSD version.
Copyright (C) 1996-2017 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, see
<http://www.gnu.org/licenses/>. */
/*
* Never include this file directly; use <time.h> instead.
*/
#ifndef _BITS_TIME_H
#define _BITS_TIME_H 1
#include <bits/types.h>
/* ISO/IEC 9899:1999 7.23.1: Components of time
The macro `CLOCKS_PER_SEC' is an expression with type `clock_t' that is
the number per second of the value returned by the `clock' function. */
/* CAE XSH, Issue 4, Version 2: <time.h>
The value of CLOCKS_PER_SEC is required to be 1 million on all
XSI-conformant systems. */
#define CLOCKS_PER_SEC ((__clock_t) 1000000)
#if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \
&& !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. */
extern long int __sysconf (int);
# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
#endif
#ifdef __USE_POSIX199309
/* Identifier for system-wide realtime clock. */
# define CLOCK_REALTIME 0
/* Monotonic system-wide clock. */
# define CLOCK_MONOTONIC 4
/* These are BSD specific clocks. */
# ifdef __USE_MISC
# define CLOCK_VIRTUAL 1
# define CLOCK_PROF 2
# define CLOCK_UPTIME 5 /* FreeBSD-specific. */
# define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */
# define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */
# define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */
# define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */
# define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */
# define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */
# define CLOCK_SECOND 13 /* FreeBSD-specific. */
# endif
/* Thread-specific CPU-time clock. */
# define CLOCK_THREAD_CPUTIME_ID 14
/* High-resolution timer from the CPU. */
# define CLOCK_PROCESS_CPUTIME_ID 15
# ifdef __USE_MISC
# define CPUCLOCK_WHICH_PID 0
# define CPUCLOCK_WHICH_TID 1
# endif
/* Flag to indicate time is absolute. */
# define TIMER_RELTIME 0 /* relative timer */
# define TIMER_ABSTIME 1 /* absolute timer */
#endif
/* Getkerninfo clock information structure */
struct clockinfo
{
int hz; /* clock frequency */
int tick; /* micro-seconds per hz tick */
int spare;
int stathz; /* statistics clock frequency */
int profhz; /* profiling clock frequency */
};
#endif /* bits/time.h */

View File

@ -0,0 +1,91 @@
/* bits/typesizes.h -- underlying types for *_t. kFreeBSD version.
Copyright (C) 2002, 2003, 2010 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 <bits/typesizes.h> directly; use <sys/types.h> instead."
#endif
#ifndef _BITS_TYPESIZES_H
#define _BITS_TYPESIZES_H 1
/* See <bits/types.h> for the meaning of these macros. This file exists so
that <bits/types.h> need not vary across different GNU platforms. */
#define __DEV_T_TYPE __U32_TYPE
#define __UID_T_TYPE __U32_TYPE
#define __GID_T_TYPE __U32_TYPE
#define __INO_T_TYPE __U32_TYPE
#define __INO64_T_TYPE __UQUAD_TYPE
#define __MODE_T_TYPE __U16_TYPE
#define __NLINK_T_TYPE __U16_TYPE
#define __OFF_T_TYPE __SQUAD_TYPE
#define __OFF64_T_TYPE __SQUAD_TYPE
#define __PID_T_TYPE __S32_TYPE
#define __RLIM_T_TYPE __SQUAD_TYPE
#define __RLIM64_T_TYPE __SQUAD_TYPE
#define __BLKCNT_T_TYPE __SQUAD_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 __S32_TYPE
#define __FSWORD_T_TYPE __SWORD_TYPE
/*
* This one is a bit tricky. It needs to match the size
* in the sys/${arch}/include/_types.h typedefs.
*
* However, for i386 and amd64 we started with __SLONGWORD_TYPE
* and we need to maintain ABI. Even if size is the same, using
* a different type may affect C++ ABI (this distinction is
* necessary to implement function overload), so it must stay
* with __SLONGWORD_TYPE.
*/
#if defined(__i386__) || defined(__amd64__) || defined(__powerpc__)
#define __TIME_T_TYPE __SLONGWORD_TYPE
#else
#define __TIME_T_TYPE __S64_TYPE
#endif
#define __USECONDS_T_TYPE __U32_TYPE
#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
#define __DADDR_T_TYPE __SQUAD_TYPE
#define __SWBLK_T_TYPE __S32_TYPE
#define __KEY_T_TYPE __SLONGWORD_TYPE
#define __CLOCKID_T_TYPE __S32_TYPE
#define __TIMER_T_TYPE __S32_TYPE
#define __BLKSIZE_T_TYPE __U32_TYPE
#define __FSID_T_TYPE union { int __val[2]; int val[2]; }
#define __SSIZE_T_TYPE __SWORD_TYPE
#define __SNSECONDS_T_TYPE __SLONGWORD_TYPE
#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
/* Tell the libc code that off_t and off64_t are actually the same type
for all ABI purposes, even if possibly expressed as different base types
for C type-checking purposes. */
#define __OFF_T_MATCHES_OFF64_T 1
/* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 1024
#endif /* bits/typesizes.h */

View File

@ -0,0 +1,55 @@
/* Copyright (C) 1996-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. */
#if !defined _SYS_UIO_H && !defined _FCNTL_H
# error "Never include <bits/uio.h> directly; use <sys/uio.h> instead."
#endif
#ifndef _BITS_UIO_H
#define _BITS_UIO_H 1
#include <sys/types.h>
/* `struct iovec' -- Structure describing a section of memory. */
struct iovec
{
/* Starting address. */
__ptr_t iov_base;
/* Length in bytes. */
size_t iov_len;
};
/* Maximum number of 'struct iovec's that can be passed to a readv() or
writev() system call. For larger arrays of 'struct iovec', the libc
uses a single read() or write() call to guarantee atomicity. */
#define UIO_MAXIOV 1024
#ifdef __USE_MISC
enum uio_rw { UIO_READ, UIO_WRITE };
/* Segment flag values. */
enum uio_seg {
UIO_USERSPACE, /* from user data space */
UIO_SYSSPACE, /* from system space */
UIO_NOCOPY /* don't copy, already in object */
};
#endif
#endif

View File

@ -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_UTSNAME_H
# error "Never include <bits/utsname.h> directly; use <sys/utsname.h> instead."
#endif
/* Length of the entries in 'struct utsname' is 32. */
#define _UTSNAME_LENGTH 32
/* But the version entry is longer. */
#define _UTSNAME_VERSION_LENGTH 256
/* If nonzero, the size of of the `domainname` field in `struct utsname'.
This is zero to indicate that there should be no such field at all. */
#define _UTSNAME_DOMAIN_LENGTH 0

View File

@ -0,0 +1,82 @@
/* Definitions of flag bits for `waitpid' et al.
Copyright (C) 1992, 1996-1997, 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; 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 <bits/waitflags.h> directly; use <sys/wait.h> 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 WCONTINUED 4 /* Report continued child. */
#define WNOWAIT 8 /* Poll only. Don't delete the proc entry. */
#define WEXITED 16 /* Wait for exited processes. */
#define WTRAPPED 32 /* Wait for a process to hit a trap or
a breakpoint. */
#define __WCLONE 0x80000000 /* Wait for cloned process. */
#ifdef __USE_MISC
# define WLINUXCLONE __WCLONE /* FreeBSD name for __WCLONE. */
#endif
/* The following values are used by the `waitid' function. */
#if defined __USE_MISC || defined __USE_XOPEN || defined __USE_XOPEN2K8
# ifndef __ENUM_IDTYPE_T
# define __ENUM_IDTYPE_T 1
typedef enum
{
/*
* These names were mostly lifted from Solaris source code and
* still use Solaris style naming to avoid breaking any
* OpenSolaris code which has been ported to FreeBSD. There
* is no clear FreeBSD counterpart for all of the names, but
* some have a clear correspondence to FreeBSD entities.
*
* The numerical values are kept synchronized with the Solaris
* values.
*/
P_PID, /* A process identifier. */
P_PPID, /* A parent process identifier. */
P_PGID, /* A process group identifier. */
P_SID, /* A session identifier. */
P_CID, /* A scheduling class identifier. */
P_UID, /* A user identifier. */
P_GID, /* A group identifier. */
P_ALL, /* All processes. */
P_LWPID, /* An LWP identifier. */
P_TASKID, /* A task identifier. */
P_PROJID, /* A project identifier. */
P_POOLID, /* A pool identifier. */
P_JAILID, /* A zone identifier. */
P_CTID, /* A (process) contract identifier. */
P_CPUID, /* CPU identifier. */
P_PSETID /* Processor set identifier. */
} idtype_t; /* The type of id_t we are using. */
# if defined __USE_MISC
# define P_ZONEID P_JAILID
# endif
# endif
#endif

View File

@ -0,0 +1,102 @@
/* 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 <bits/waitstatus.h> directly; use <sys/wait.h> instead."
#endif
/* 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 the child is stopped. */
#define __WIFSTOPPED(status) (((status) & 0x7f) == 0x7f)
/* Linux uses 0xffff, BSD uses SIGCONT */
#define __W_CONTINUED 0x13
#define __WCOREFLAG 0x80
/* Nonzero if STATUS indicates the child continued after a stop. */
#define __WIFCONTINUED(status) ((status) == __W_CONTINUED)
/* Nonzero if STATUS indicates the child dumped core. */
#define __WCOREDUMP(status) ((status) & __WCOREFLAG)
/* Nonzero if STATUS indicates termination by a signal. */
#define __WIFSIGNALED(status) \
(!__WIFSTOPPED(status) && !__WIFEXITED(status) && !__WIFCONTINUED(status))
/* Macros for constructing status values. */
#define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
#define __W_STOPCODE(sig) ((sig) << 8 | 0x7f)
#ifdef __USE_MISC
# include <endian.h>
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. */

View File

@ -0,0 +1,49 @@
/* Copyright (C) 2004, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Robert Millan
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 <errno.h>
#include <unistd.h>
#include <sysdep.h>
extern int __syscall_obreak (void *addr);
libc_hidden_proto (__syscall_obreak)
extern char _end[];
/* sbrk.c expects this. */
void *__curbrk = _end;
/* Set the end of the process's data space to ADDR.
Return 0 if successful, -1 if not. */
int
__brk (void *addr)
{
if ((char*)addr < _end)
return 0;
if (INLINE_SYSCALL (obreak, 1, addr) == -1)
{
__set_errno (ENOMEM);
return -1;
}
__curbrk = addr;
return 0;
}
weak_alias (__brk, brk)

View File

@ -0,0 +1 @@
void __libc_check_standard_fds (void) {;}

View File

@ -0,0 +1,42 @@
/* Determine whether interfaces use native transport. Dummy version.
Copyright (C) 2008 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. */
#include <assert.h>
#include <errno.h>
#include <ifaddrs.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <sys/ioctl.h>
#include <not-cancel.h>
void
__check_native (uint32_t a1_index, int *a1_native,
uint32_t a2_index, int *a2_native)
{
#warning __check_native() not yet implemented
return;
}

View File

@ -0,0 +1 @@
#include <inet/check_pf.c>

View File

@ -0,0 +1,44 @@
/* Copyright (C) 1991, 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. */
#include <sys/resource.h>
#include <sys/time.h>
#include <time.h>
#ifdef __GNUC__
__inline
#endif
static clock_t
timeval_to_clock_t (const struct timeval *tv)
{
return (clock_t) ((tv->tv_sec * CLOCKS_PER_SEC) +
(tv->tv_usec * CLOCKS_PER_SEC / 1000000));
}
/* Return the time used by the program so far (user time + system time). */
clock_t
clock (void)
{
struct rusage usage;
if (__getrusage (RUSAGE_SELF, &usage) < 0)
return (clock_t) -1;
return (timeval_to_clock_t (&usage.ru_stime) +
timeval_to_clock_t (&usage.ru_utime));
}

View File

@ -0,0 +1,43 @@
/* Copyright (C) 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. */
#include <sysdep.h>
int __syscall_clock_getres(clockid_t clock_id, struct timespec *tp);
libc_hidden_proto (__syscall_clock_getres)
# define SYSDEP_GETRES \
case CLOCK_REALTIME: \
case CLOCK_VIRTUAL: \
case CLOCK_PROF: \
case CLOCK_MONOTONIC: \
case CLOCK_UPTIME: \
case CLOCK_UPTIME_PRECISE: \
case CLOCK_UPTIME_FAST: \
case CLOCK_REALTIME_PRECISE: \
case CLOCK_REALTIME_FAST: \
case CLOCK_MONOTONIC_PRECISE: \
case CLOCK_MONOTONIC_FAST: \
case CLOCK_SECOND: \
retval = INLINE_SYSCALL (clock_getres, 2, clock_id, res); \
break
/* We handled the REALTIME clock here. */
# define HANDLED_REALTIME 1
#include <sysdeps/posix/clock_getres.c>

View File

@ -0,0 +1,43 @@
/* Copyright (C) 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. */
#include <sysdep.h>
#include "kernel-posix-cpu-timers.h"
int __syscall_clock_gettime(clockid_t clock_id, struct timespec *tp);
libc_hidden_proto (__syscall_clock_gettime)
# define SYSDEP_GETTIME \
case CLOCK_REALTIME: \
case CLOCK_VIRTUAL: \
case CLOCK_PROF: \
case CLOCK_MONOTONIC: \
case CLOCK_UPTIME: \
case CLOCK_UPTIME_PRECISE: \
case CLOCK_UPTIME_FAST: \
case CLOCK_REALTIME_PRECISE: \
case CLOCK_REALTIME_FAST: \
case CLOCK_MONOTONIC_PRECISE: \
case CLOCK_MONOTONIC_FAST: \
case CLOCK_SECOND: \
retval = INLINE_SYSCALL (clock_gettime, 2, clock_id, tp); \
break
/* We handled the REALTIME clock here. */
# define HANDLED_REALTIME 1
#include <sysdeps/unix/clock_gettime.c>

View File

@ -0,0 +1,32 @@
/* Copyright (C) 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. */
#include <sysdep.h>
#include "kernel-posix-cpu-timers.h"
int __syscall_clock_settime(clockid_t clock_id, const struct timespec *tp);
libc_hidden_proto (__syscall_clock_settime)
# define SYSDEP_SETTIME \
case CLOCK_REALTIME: \
retval = INLINE_SYSCALL (clock_settime, 2, clock_id, tp); \
break
/* We handled the REALTIME clock here. */
# define HANDLED_REALTIME 1
#include <sysdeps/unix/clock_settime.c>

View File

@ -0,0 +1,122 @@
/* Create a thread.
Copyright (C) 2002 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Bruno Haible <bruno@clisp.org>, 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. */
#define __clone __no_broken_clone_decl
#include <sched.h>
#include <sys/rfork.h>
#include <errno.h>
#include <signal.h>
#include <stddef.h>
#include <getosreldate.h>
#undef __clone
/* __start_thread (flags, child_stack, fn, arg)
is roughly equivalent to
int retval = __rfork (flags);
if (retval == 0)
{
// Here we are in the child thread.
%stackpointer = child_stack;
_exit (fn (arg));
}
return retval;
but it cannot be done in portable C because it must access fn and arg
after having replaced the stack pointer. */
extern int __start_thread (int flags, void *child_stack,
int (*fn) (void *), void *arg);
int __clone (int (*fn) (void *), void *child_stack, int flags, void *arg)
{
int rfork_flags = RFPROC;
if (fn == NULL || child_stack == NULL)
{
__set_errno (EINVAL);
return -1;
}
/* This implementation of clone() does not support all Linux flags. */
if (flags & ~(CSIGNAL | CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND
| CLONE_VFORK | CLONE_SYSVSEM))
{
__set_errno (EINVAL);
return -1;
}
if ((flags & CSIGNAL) != SIGCHLD)
{
if (__kernel_getosreldate() >= 802510)
/* we slightly cheat here, */
/* the 9.x snapshot prior to r223966 does not support it too */
{
if ((flags & CSIGNAL) & ~RFTSIGMASK)
{
__set_errno (EINVAL);
return -1;
}
rfork_flags |= (RFTSIGZMB | RFTSIGFLAGS(flags & CSIGNAL));
}
else
{
if ((flags & CSIGNAL) & ~RFTHPNMASK)
{
__set_errno (EINVAL);
return -1;
}
if ((flags & CSIGNAL) == 0)
rfork_flags |= (RFLINUXTHPN | ((SIGCHLD) << RFTHPNSHIFT));
else
rfork_flags |= (RFLINUXTHPN | ((flags & CSIGNAL) << RFTHPNSHIFT));
}
}
if (flags & CLONE_VM)
rfork_flags |= RFMEM;
if (flags & CLONE_FS)
/* Sharing the filesystem related info (umask, cwd, root dir)
is not supported by rfork. Ignore this; let's hope programs
will set their umask and cwd before spawning threads. */
;
if (flags & CLONE_SYSVSEM)
/* Ignore this; it has been introduced into linuxthreads in post 2.4 glibc */
;
if (!(flags & CLONE_FILES))
rfork_flags |= RFFDG;
if (flags & CLONE_SIGHAND)
{
rfork_flags |= RFSIGSHARE;
/* Also set the undocumented flag RFTHREAD. It has the effect that when
the thread leader exits, all threads belonging to it are killed. */
rfork_flags |= RFTHREAD;
}
if (flags & CLONE_VFORK)
rfork_flags |= RFPPWAIT;
return __start_thread (rfork_flags, child_stack, fn, arg);
}
weak_alias (__clone, clone)

View File

@ -0,0 +1,423 @@
# This file is generated from configure.in by Autoconf. DO NOT EDIT!
# Local configure fragment for sysdeps/unix/bsd/bsd4.4/kfreebsd.
# The kFreeBSD headers can be found in
# /usr/src/sys/
# Check whether this directory is available.
if test -z "$sysheaders" &&
test "x$cross_compiling" = xno &&
test -d /usr/src/sys/ ; then
sysheaders="/usr/src/sys/"
ccheaders=`$CC -print-file-name=include`
SYSINCLUDES="-I $sysheaders"
fi
# Don't bother trying to generate any glue code to be compatible with the
# existing system library, because we are the only system library.
inhibit_glue=yes
if test -n "$sysheaders"; then
OLD_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $SYSINCLUDES"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
if test "${ac_cv_path_GREP+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -z "$GREP"; then
ac_path_GREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in grep ggrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
# Check for GNU ac_path_GREP and select it if it is found.
# Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
*GNU*)
ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'GREP' >> "conftest.nl"
"$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
as_fn_arith $ac_count + 1 && ac_count=$as_val
if test $ac_count -gt ${ac_path_GREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_GREP="$ac_path_GREP"
ac_path_GREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_GREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_GREP"; then
as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_GREP=$GREP
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
$as_echo "$ac_cv_path_GREP" >&6; }
GREP="$ac_cv_path_GREP"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
$as_echo_n "checking for egrep... " >&6; }
if test "${ac_cv_path_EGREP+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
then ac_cv_path_EGREP="$GREP -E"
else
if test -z "$EGREP"; then
ac_path_EGREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in egrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
# Check for GNU ac_path_EGREP and select it if it is found.
# Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
*GNU*)
ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'EGREP' >> "conftest.nl"
"$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
as_fn_arith $ac_count + 1 && ac_count=$as_val
if test $ac_count -gt ${ac_path_EGREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_EGREP="$ac_path_EGREP"
ac_path_EGREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_EGREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_EGREP"; then
as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_EGREP=$EGREP
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
$as_echo "$ac_cv_path_EGREP" >&6; }
EGREP="$ac_cv_path_EGREP"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking installed kFreeBSD kernel header files" >&5
$as_echo_n "checking installed kFreeBSD kernel header files... " >&6; }
if test "${libc_cv_kfreebsd830+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <osreldate.h>
#if !defined(__FreeBSD_kernel_version) && defined(__FreeBSD_version)
#define __FreeBSD_kernel_version __FreeBSD_version
#endif
#if !defined __FreeBSD_kernel_version || __FreeBSD_kernel_version < (8 *100000+ 3 *1000+ 0) /* 8.3.0 */
eat flaming death
#endif
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "eat flaming death" >/dev/null 2>&1; then :
libc_cv_kfreebsd830='TOO OLD!'
else
libc_cv_kfreebsd830='8.3.0 or later'
fi
rm -f conftest*
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_kfreebsd830" >&5
$as_echo "$libc_cv_kfreebsd830" >&6; }
if test "$libc_cv_kfreebsd830" != '8.3.0 or later'; then
as_fn_error "GNU libc requires kernel header files from
kFreeBSD 8.3.0 or later to be installed before configuring.
The kernel header files are found usually in /usr/src/sys/; make sure
these directories use files from kFreeBSD 8.3.0 or later.
This check uses <osreldate.h>, so
make sure that file was built correctly when installing the kernel header
files. To use kernel headers not from /usr/src/sys/, use the
configure option --with-headers." "$LINENO" 5
fi
# Check whether --enable-compatible-utmp was given.
if test "${enable_compatible_utmp+set}" = set; then :
enableval=$enable_compatible_utmp; enable_utmp_compat=$enableval
else
enable_utmp_compat=no
fi
if test "$enable_utmp_compat" = no; then
utmp_subdir=utmp-utmpx
else
utmp_subdir=utmp-compat
fi
sysnames="$sysnames sysdeps/unix/bsd/bsd4.4/kfreebsd/$utmp_subdir"
# If the user gave a minimal version number test whether the available
# kernel headers are young enough. Additionally we have minimal
# kernel versions for some architectures. If a previous configure fragment
# set arch_minimum_kernel already, let that override our defaults here.
# Note that we presume such a fragment has set libc_cv_gcc_unwind_find_fde
# if appropriate too.
test -n "$arch_minimum_kernel" ||
case "$machine" in
i386*)
libc_cv_gcc_unwind_find_fde=yes
arch_minimum_kernel=8.3.0
;;
x86_64*)
arch_minimum_kernel=8.3.0
;;
*)
arch_minimum_kernel=8.3.0
;;
esac
if test -n "$minimum_kernel"; then
user_version=$((`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`))
arch_version=$((`echo "$arch_minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`))
if test $user_version -lt $arch_version; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: minimum kernel version reset to $arch_minimum_kernel" >&5
$as_echo "$as_me: WARNING: minimum kernel version reset to $arch_minimum_kernel" >&2;}
minimum_kernel=$arch_minimum_kernel
fi
else
if test $arch_minimum_kernel != '8.3.0'; then
minimum_kernel=$arch_minimum_kernel
fi
fi
if test -n "$minimum_kernel"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for kernel header at least $minimum_kernel" >&5
$as_echo_n "checking for kernel header at least $minimum_kernel... " >&6; }
hdrnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 100000 + \2 * 1000 + \3)/'`;
decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <osreldate.h>
#if !defined(__FreeBSD_kernel_version) && defined(__FreeBSD_version)
#define __FreeBSD_kernel_version __FreeBSD_version
#endif
#if __FreeBSD_kernel_version < $hdrnum
eat flaming death
#endif
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "eat flaming death" >/dev/null 2>&1; then :
libc_minimum_kernel='too old!'
else
libc_minimum_kernel=ok
fi
rm -f conftest*
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_minimum_kernel" >&5
$as_echo "$libc_minimum_kernel" >&6; }
if test "$libc_minimum_kernel" = ok; then
cat >>confdefs.h <<_ACEOF
#define __KFREEBSD_KERNEL_VERSION $decnum
_ACEOF
cat >>confdefs.h <<_ACEOF
#define __ABI_TAG_VERSION $abinum
_ACEOF
else
as_fn_error "*** The available kernel headers are older than the requested
*** compatible kernel version" "$LINENO" 5
fi
fi
if test -n "$sysheaders"; then
CPPFLAGS=$OLD_CPPFLAGS
fi
# The Linux filesystem standard prescribes where to place "essential"
# files. I.e., when the installation prefix is "/usr" we have to place
# shared library objects and the configuration files on the root partition
# in /lib and /etc.
case "$prefix" in
/usr | /usr/)
# 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib
case $machine in
sparc/sparc64 | x86_64 | powerpc/powerpc64 | s390/s390-64 | \
mips/mips64/n64/* )
libc_cv_slibdir="/lib64"
if test "$libdir" = '${exec_prefix}/lib'; then
libdir='${exec_prefix}/lib64';
# Locale data can be shared between 32bit and 64bit libraries
libc_cv_complocaledir='${exec_prefix}/lib/locale'
fi
;;
mips/mips64/n32/* )
libc_cv_slibdir="/lib32"
if test "$libdir" = '${exec_prefix}/lib'; then
libdir='${exec_prefix}/lib32';
# Locale data can be shared between 32bit and 64bit libraries
libc_cv_complocaledir='${exec_prefix}/lib/locale'
fi
;;
*)
libc_cv_slibdir="/lib"
;;
esac
# Allow the user to override the path with --sysconfdir
if test $sysconfdir = '${prefix}/etc'; then
libc_cv_sysconfdir=/etc
else
libc_cv_sysconfdir=$sysconfdir
fi
libc_cv_rootsbindir="/sbin"
;;
esac
# Put exception handling support into libc, so that not every shared
# library needs to include it.
# FIXME: Does not work yet.
libc_cv_gcc_unwind_find_fde=no
# Under kFreeBSD the FBTL add-on should be available.
case $add_ons in
# It is available. Good.
*fbtl*)
fbtl_missing=
;;
*)
fbtl_missing=yes
;;
esac
if test "$fbtl_missing"; then
if test $enable_sanity = yes; then
echo "\
*** On GNU/kFreeBSD systems it is normal to compile GNU libc with the
*** \`fbtl' add-on. Without that, the library will be
*** incompatible with normal GNU/kFreeBSD systems.
*** If you really mean to not use this add-on, run configure again
*** using the extra parameter \`--disable-sanity-checks'."
exit 1
else
echo "\
*** WARNING: Are you sure you do not want to use the \`fbtl'
*** add-on?"
fi
fi
if test "$prefix" = "/usr/local" -o "$prefix" = "/usr/local/" -o "$prefix" = "NONE"; then
if test $enable_sanity = yes; then
echo "\
*** On GNU/kFreeBSD systems the GNU C Library should not be installed into
*** /usr/local since this might make your system totally unusable.
*** We strongly advise to use a different prefix. For details read the FAQ.
*** If you really mean to do this, run configure again using the extra
*** parameter \`--disable-sanity-checks'."
exit 1
else
echo "\
*** WARNING: Do you really want to install the GNU C Library into /usr/local?
*** This might make your system totally unusable, for details read the FAQ."
fi
fi
# One kFreeBSD we use ldconfig.
use_ldconfig=yes
# We need some extensions to the `ldd' script.
case "$machine" in
x86_64*)
ldd_rewrite_script=$dir/x86_64/ldd-rewrite.sed
;;
*)
;;
esac
if test $host = $build; then
# If $prefix/include/{net,scsi} are symlinks, make install will
# clobber what they're linked to (probably a kernel tree).
# test -L ought to work on all Linux boxes.
if test "x$prefix" != xNONE; then
ac_prefix=$prefix
else
ac_prefix=$ac_default_prefix
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for symlinks in ${ac_prefix}/include" >&5
$as_echo_n "checking for symlinks in ${ac_prefix}/include... " >&6; }
ac_message=
if test -L ${ac_prefix}/include/net; then
ac_message="$ac_message
${ac_prefix}/include/net is a symlink"
fi
if test -L ${ac_prefix}/include/scsi; then
ac_message="$ac_message
${ac_prefix}/include/scsi is a symlink"
fi
if test -n "$ac_message"; then
as_fn_error "$ac_message
\`make install' will destroy the target of the link(s).
Delete the links and re-run configure, or better still, move the entire
${ac_prefix}/include directory out of the way." "$LINENO" 5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
$as_echo "ok" >&6; }
fi
fi
# We support internal syscalls.
# It is advertised as inlined syscalls availability ...
$as_echo "#define HAVE_INLINED_SYSCALLS 1" >>confdefs.h

View File

@ -0,0 +1,258 @@
GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
# Local configure fragment for sysdeps/unix/bsd/bsd4.4/kfreebsd.
# The kFreeBSD headers can be found in
# /usr/src/sys/
# Check whether this directory is available.
if test -z "$sysheaders" &&
test "x$cross_compiling" = xno &&
test -d /usr/src/sys/ ; then
sysheaders="/usr/src/sys/"
ccheaders=`$CC -print-file-name=include`
dnl We don't have to use -nostdinc. We just want one more directory
dnl to be used.
SYSINCLUDES="-I $sysheaders"
fi
# Don't bother trying to generate any glue code to be compatible with the
# existing system library, because we are the only system library.
inhibit_glue=yes
define([LIBC_KFREEBSD_VERSION],[8.3.0])dnl
if test -n "$sysheaders"; then
OLD_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $SYSINCLUDES"
fi
define([libc_cv_kfreebsdVER], [libc_cv_kfreebsd]patsubst(LIBC_KFREEBSD_VERSION,[\.]))dnl
AC_CACHE_CHECK(installed kFreeBSD kernel header files, libc_cv_kfreebsdVER, [dnl
AC_EGREP_CPP([eat flaming death], [#include <osreldate.h>
#if !defined(__FreeBSD_kernel_version) && defined(__FreeBSD_version)
#define __FreeBSD_kernel_version __FreeBSD_version
#endif
#if !defined __FreeBSD_kernel_version || __FreeBSD_kernel_version < ]dnl
patsubst(LIBC_KFREEBSD_VERSION,[^\([^.]*\)\.\([^.]*\)\.\([^.]*\)$],dnl
[ (\1 *100000+ \2 *1000+ \3) /* \1.\2.\3 */])[
eat flaming death
#endif],
libc_cv_kfreebsdVER='TOO OLD!',
libc_cv_kfreebsdVER='LIBC_KFREEBSD_VERSION or later')])
if test "$libc_cv_kfreebsdVER" != 'LIBC_KFREEBSD_VERSION or later'; then
AC_MSG_ERROR([GNU libc requires kernel header files from
kFreeBSD LIBC_KFREEBSD_VERSION or later to be installed before configuring.
The kernel header files are found usually in /usr/src/sys/; make sure
these directories use files from kFreeBSD LIBC_KFREEBSD_VERSION or later.
This check uses <osreldate.h>, so
make sure that file was built correctly when installing the kernel header
files. To use kernel headers not from /usr/src/sys/, use the
configure option --with-headers.])
fi
AC_ARG_ENABLE([compatible-utmp],
AC_HELP_STRING([--disable-compatible-utmp],
[use a struct utmp which is the same as struct utmpx, as on kFreeBSD, but incompatible with FreeBSD]),
[enable_utmp_compat=$enableval],
[enable_utmp_compat=no])
if test "$enable_utmp_compat" = no; then
utmp_subdir=utmp-utmpx
else
utmp_subdir=utmp-compat
fi
sysnames="$sysnames sysdeps/unix/bsd/bsd4.4/kfreebsd/$utmp_subdir"
# If the user gave a minimal version number test whether the available
# kernel headers are young enough. Additionally we have minimal
# kernel versions for some architectures. If a previous configure fragment
# set arch_minimum_kernel already, let that override our defaults here.
# Note that we presume such a fragment has set libc_cv_gcc_unwind_find_fde
# if appropriate too.
test -n "$arch_minimum_kernel" ||
case "$machine" in
i386*)
libc_cv_gcc_unwind_find_fde=yes
arch_minimum_kernel=8.3.0
;;
x86_64*)
arch_minimum_kernel=8.3.0
;;
*)
arch_minimum_kernel=8.3.0
;;
esac
if test -n "$minimum_kernel"; then
changequote(,)
user_version=$((`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`))
arch_version=$((`echo "$arch_minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1 \* 65536 + \2 \* 256 + \3/'`))
changequote([,])
if test $user_version -lt $arch_version; then
AC_MSG_WARN([minimum kernel version reset to $arch_minimum_kernel])
minimum_kernel=$arch_minimum_kernel
fi
else
if test $arch_minimum_kernel != '8.3.0'; then
minimum_kernel=$arch_minimum_kernel
fi
fi
if test -n "$minimum_kernel"; then
AC_MSG_CHECKING(for kernel header at least $minimum_kernel)
changequote(,)dnl
hdrnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 100000 + \2 * 1000 + \3)/'`;
decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
changequote([,])dnl
AC_EGREP_CPP([eat flaming death], [#include <osreldate.h>
#if !defined(__FreeBSD_kernel_version) && defined(__FreeBSD_version)
#define __FreeBSD_kernel_version __FreeBSD_version
#endif
#if __FreeBSD_kernel_version < $hdrnum
eat flaming death
#endif], libc_minimum_kernel='too old!', libc_minimum_kernel=ok)
AC_MSG_RESULT($libc_minimum_kernel)
if test "$libc_minimum_kernel" = ok; then
AC_DEFINE_UNQUOTED(__KFREEBSD_KERNEL_VERSION, $decnum)
AC_DEFINE_UNQUOTED(__ABI_TAG_VERSION, $abinum)
else
AC_MSG_ERROR([*** The available kernel headers are older than the requested
*** compatible kernel version])
fi
fi
if test -n "$sysheaders"; then
CPPFLAGS=$OLD_CPPFLAGS
fi
# The Linux filesystem standard prescribes where to place "essential"
# files. I.e., when the installation prefix is "/usr" we have to place
# shared library objects and the configuration files on the root partition
# in /lib and /etc.
case "$prefix" in
/usr | /usr/)
# 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib
case $machine in
sparc/sparc64 | x86_64 | powerpc/powerpc64 | s390/s390-64 | \
mips/mips64/n64/* )
libc_cv_slibdir="/lib64"
if test "$libdir" = '${exec_prefix}/lib'; then
libdir='${exec_prefix}/lib64';
# Locale data can be shared between 32bit and 64bit libraries
libc_cv_localedir='${exec_prefix}/lib/locale'
fi
;;
mips/mips64/n32/* )
libc_cv_slibdir="/lib32"
if test "$libdir" = '${exec_prefix}/lib'; then
libdir='${exec_prefix}/lib32';
# Locale data can be shared between 32bit and 64bit libraries
libc_cv_localedir='${exec_prefix}/lib/locale'
fi
;;
*)
libc_cv_slibdir="/lib"
;;
esac
# Allow the user to override the path with --sysconfdir
if test $sysconfdir = '${prefix}/etc'; then
libc_cv_sysconfdir=/etc
else
libc_cv_sysconfdir=$sysconfdir
fi
libc_cv_rootsbindir="/sbin"
;;
esac
# Put exception handling support into libc, so that not every shared
# library needs to include it.
# FIXME: Does not work yet.
libc_cv_gcc_unwind_find_fde=no
# Under kFreeBSD the FBTL add-on should be available.
case $add_ons in
# It is available. Good.
*fbtl*)
fbtl_missing=
;;
*)
fbtl_missing=yes
;;
esac
if test "$fbtl_missing"; then
if test $enable_sanity = yes; then
echo "\
*** On GNU/kFreeBSD systems it is normal to compile GNU libc with the
*** \`fbtl' add-on. Without that, the library will be
*** incompatible with normal GNU/kFreeBSD systems.
*** If you really mean to not use this add-on, run configure again
*** using the extra parameter \`--disable-sanity-checks'."
exit 1
else
echo "\
*** WARNING: Are you sure you do not want to use the \`fbtl'
*** add-on?"
fi
fi
if test "$prefix" = "/usr/local" -o "$prefix" = "/usr/local/" -o "$prefix" = "NONE"; then
if test $enable_sanity = yes; then
echo "\
*** On GNU/kFreeBSD systems the GNU C Library should not be installed into
*** /usr/local since this might make your system totally unusable.
*** We strongly advise to use a different prefix. For details read the FAQ.
*** If you really mean to do this, run configure again using the extra
*** parameter \`--disable-sanity-checks'."
exit 1
else
echo "\
*** WARNING: Do you really want to install the GNU C Library into /usr/local?
*** This might make your system totally unusable, for details read the FAQ."
fi
fi
# One kFreeBSD we use ldconfig.
use_ldconfig=yes
# We need some extensions to the `ldd' script.
changequote(,)
case "$machine" in
x86_64*)
ldd_rewrite_script=$dir/x86_64/ldd-rewrite.sed
;;
*)
;;
esac
changequote([,])
if test $host = $build; then
# If $prefix/include/{net,scsi} are symlinks, make install will
# clobber what they're linked to (probably a kernel tree).
# test -L ought to work on all Linux boxes.
if test "x$prefix" != xNONE; then
ac_prefix=$prefix
else
ac_prefix=$ac_default_prefix
fi
AC_MSG_CHECKING([for symlinks in ${ac_prefix}/include])
ac_message=
if test -L ${ac_prefix}/include/net; then
ac_message="$ac_message
${ac_prefix}/include/net is a symlink"
fi
if test -L ${ac_prefix}/include/scsi; then
ac_message="$ac_message
${ac_prefix}/include/scsi is a symlink"
fi
if test -n "$ac_message"; then
AC_MSG_ERROR([$ac_message
\`make install' will destroy the target of the link(s).
Delete the links and re-run configure, or better still, move the entire
${ac_prefix}/include directory out of the way.])
else
AC_MSG_RESULT(ok)
fi
fi
# We support internal syscalls.
# It is advertised as inlined syscalls availability ...
AC_DEFINE(HAVE_INLINED_SYSCALLS)

View File

@ -0,0 +1,65 @@
/* Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Aurelien Jarno <aurelien@aurel32.net>, 2005.
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 <sys/socket.h>
#include <sysdep.h>
#include <sysdep-cancel.h>
/* According to POSIX.1-2004 the len argument specifies the length of
the sockaddr structure pointed to by the addrarg argument. However
the FreeBSD kernel waits the actual length of the address stored
there. The code below emulate this behaviour. */
extern int __libc_sa_len (sa_family_t __af);
libc_hidden_proto (__libc_sa_len)
extern int __syscall_connect (int fd, __CONST_SOCKADDR_ARG addr,
socklen_t addrlen);
libc_hidden_proto (__syscall_connect)
/* 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. */
int
__libc_connect (int fd, __CONST_SOCKADDR_ARG addr, socklen_t addrlen)
{
socklen_t new_addrlen;
new_addrlen = __libc_sa_len ((addr.__sockaddr__)->sa_family);
/* Only allow a smaller size, otherwise it could lead to
stack corruption */
if ((new_addrlen != 0) && (new_addrlen < addrlen))
addrlen = new_addrlen;
/* We pass 3 arguments. */
if (SINGLE_THREAD_P)
return INLINE_SYSCALL (connect, 3, fd, addr.__sockaddr__, addrlen);
int oldtype = LIBC_CANCEL_ASYNC ();
int result = INLINE_SYSCALL (connect, 3, fd, addr.__sockaddr__, addrlen);
LIBC_CANCEL_RESET (oldtype);
return result;
}
weak_alias (__libc_connect, __connect)
weak_alias (__libc_connect, connect)
libc_hidden_weak (__connect)

View File

@ -0,0 +1,52 @@
/* Copyright (C) 2013 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. */
/* From <sys/cpuset.h> */
/*
* Valid cpulevel_t values.
*/
#define CPU_LEVEL_ROOT 1 /* All system cpus. */
#define CPU_LEVEL_CPUSET 2 /* Available cpus for which. */
#define CPU_LEVEL_WHICH 3 /* Actual mask/id for which. */
/*
* Valid cpuwhich_t values.
*/
#define CPU_WHICH_TID 1 /* Specifies a thread id. */
#define CPU_WHICH_PID 2 /* Specifies a process id. */
#define CPU_WHICH_CPUSET 3 /* Specifies a set id. */
#define CPU_WHICH_IRQ 4 /* Specifies an irq #. */
#define CPU_WHICH_JAIL 5 /* Specifies a jail id. */
/*
* Reserved cpuset identifiers.
*/
#define CPUSET_INVALID -1
#define CPUSET_DEFAULT 0
extern int __syscall_cpuset_getaffinity(int level, int which, int64_t id,
size_t setsize, cpu_set_t *mask);
libc_hidden_proto(__syscall_cpuset_getaffinity)
extern int __syscall_cpuset_setaffinity(int level, int which, int64_t id,
size_t setsize, const cpu_set_t *mask);
libc_hidden_proto(__syscall_cpuset_setaffinity)

View File

@ -0,0 +1,69 @@
/*
* 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.
*/
#include <stdio.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
char *
__devname_r(__dev_t dev, __mode_t type, char *buf, int len)
{
int i;
size_t j;
const char *r;
if ((type & S_IFMT) == S_IFCHR) {
j = len;
i = __sysctlbyname("kern.devname", buf, &j, &dev, sizeof (dev));
if (i == 0)
return (buf);
}
/* Finally just format it */
if (dev == NODEV)
r = "#NODEV";
else
r = "#%c:%d:0x%x";
__snprintf(buf, len, r,
(type & S_IFMT) == S_IFCHR ? 'C' : 'B', major(dev), minor(dev));
return (buf);
}
char *
__devname(__dev_t dev, __mode_t type)
{
static char buf[SPECNAMELEN + 1];
return(__devname_r(dev, type, buf, sizeof(buf)));
}
weak_alias (__devname_r, devname_r)
weak_alias (__devname, devname)

View File

@ -0,0 +1,58 @@
/* Stack executability handling for GNU dynamic linker. Linux version.
Copyright (C) 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. */
#include <ldsodefs.h>
#include <sys/mman.h>
#include <errno.h>
#include <libintl.h>
#include <stdbool.h>
#include <stackinfo.h>
#include <caller.h>
extern int __stack_prot attribute_relro attribute_hidden;
int
internal_function
_dl_make_stack_executable (void **stack_endp)
{
/* This gives us the highest/lowest page that needs to be changed. */
uintptr_t page = ((uintptr_t) *stack_endp
& -(intptr_t) GLRO(dl_pagesize));
/* Challenge the caller. */
if (__builtin_expect (__check_caller (RETURN_ADDRESS (0),
allow_ldso|allow_libpthread) != 0, 0)
|| __builtin_expect (*stack_endp != __libc_stack_end, 0))
return EPERM;
if (__builtin_expect (__mprotect ((void *) page, GLRO(dl_pagesize),
__stack_prot) != 0, 0))
return errno;
/* Clear the address. */
*stack_endp = NULL;
/* Remember that we changed the permission. */
GL(dl_stack_flags) |= PF_X;
return 0;
}
rtld_hidden_def (_dl_make_stack_executable)

View File

@ -0,0 +1 @@
#include "getcwd.c"

View File

@ -0,0 +1,33 @@
/* Copyright (C) 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gmain.com>, 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, see
<http://www.gnu.org/licenses/>. */
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <sysdep.h>
extern int __syscall_openat (int fd, const char *path, int flag, mode_t mode);
libc_hidden_proto (__syscall_openat)
int
openat64 (int dfd, const char *file, int oflag, ...)
{
assert ((oflag & O_CREAT) == 0);
return INLINE_SYSCALL (openat, 4, dfd, file, oflag, 0);
}

View File

@ -0,0 +1,123 @@
/* Find path of executable.
Copyright (C) 1998, 1999, 2000, 2002, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
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 <assert.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/param.h>
#include <ldsodefs.h>
#include <sysdep.h>
#include <dl-dst.h>
const char *_self_program_name_from_auxv attribute_hidden;
static int
_dl_self_name(char *buf, int buflen)
{
int len, wdlen;
/* try /proc/self/exe symlink. */
len = __readlink("/proc/self/exe", buf, buflen);
if (len > 0 && buf[0] == '/')
return len;
if (!_self_program_name_from_auxv)
return -1;
len = strlen(_self_program_name_from_auxv);
if (len > 0 && _self_program_name_from_auxv[0] == '/')
{
/* absolute file name */
if (len < buflen)
{
strcpy(buf, _self_program_name_from_auxv);
return len;
}
memcpy(buf, _self_program_name_from_auxv, buflen);
buf[buflen - 1] = 0;
return buflen - 1;
};
/* relative file name, do our best */
if (NULL == __getcwd(buf, buflen))
return -1;
wdlen = strlen(buf);
buf[wdlen] = '/';
if ((wdlen + len + 1) < buflen)
{
strcpy(buf + wdlen + 1, _self_program_name_from_auxv);
return wdlen + len + 1;
}
memcpy(buf + wdlen + 1, _self_program_name_from_auxv, buflen - wdlen - 1);
buf[buflen - 1] = 0;
return buflen - 1;
}
const char *
_dl_get_origin (void)
{
char linkval[2*PATH_MAX];
char *result;
int len;
len = _dl_self_name(linkval, sizeof(linkval));
if (len > 0)
{
/* We can use this value. */
while (len > 1 && linkval[len - 1] != '/')
--len;
result = (char *) malloc (len + 1);
if (result == NULL)
result = (char *) -1;
else if (len == 1)
memcpy (result, "/", 2);
else
*((char *) __mempcpy (result, linkval, len - 1)) = '\0';
}
else
{
result = (char *) -1;
/* We use the environment variable LD_ORIGIN_PATH. If it is set make
a copy and strip out trailing slashes. */
if (GLRO(dl_origin_path) != NULL)
{
size_t len = strlen (GLRO(dl_origin_path));
result = (char *) malloc (len + 1);
if (result == NULL)
result = (char *) -1;
else
{
char *cp = __mempcpy (result, GLRO(dl_origin_path), len);
while (cp > result + 1 && cp[-1] == '/')
--cp;
*cp = '\0';
}
}
}
return result;
}

View File

@ -0,0 +1,94 @@
/* Operating system specific code for generic dynamic loader functions.
Copyright (C) 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. */
#include <kernel-features.h>
#include <dl-sysdep.h>
#include <endian.h>
#include <fcntl.h>
#include <stdint.h>
#include <not-cancel.h>
#ifndef MIN
# define MIN(a,b) (((a)<(b))?(a):(b))
#endif
#define DL_SYSDEP_OSCHECK(FATAL) \
do { \
/* Test whether the kernel is new enough. This test is only performed \
if the library is not compiled to run on all kernels. */ \
\
int version = _dl_discover_osversion (); \
if (__builtin_expect (version >= 0, 1)) \
{ \
if (__builtin_expect (GLRO(dl_osversion) == 0, 1) \
|| GLRO(dl_osversion) > version) \
GLRO(dl_osversion) = version; \
\
/* Now we can test with the required version. */ \
if (__KFREEBSD_KERNEL_VERSION > 0 && \
version < __KFREEBSD_KERNEL_VERSION) \
/* Not sufficent. */ \
FATAL ("FATAL: kernel too old\n"); \
} \
else if (__KFREEBSD_KERNEL_VERSION > 0) \
FATAL ("FATAL: cannot determine kernel version\n"); \
} while (0)
static inline uintptr_t __attribute__ ((always_inline))
_dl_setup_stack_chk_guard (void *dl_random)
{
union
{
uintptr_t num;
unsigned char bytes[sizeof (uintptr_t)];
} ret;
{
const size_t filllen = sizeof (ret.bytes) - 1;
ret.num = 0;
# ifdef ENABLE_STACKGUARD_RANDOMIZE
int fd = open_not_cancel_2 ("/dev/urandom", O_RDONLY);
if (fd >= 0)
{
ssize_t reslen = read_not_cancel (fd, ret.bytes + 1, filllen);
close_not_cancel_no_status (fd);
if (reslen == (ssize_t) filllen)
return ret.num;
}
# endif
ret.bytes[filllen] = 255;
ret.bytes[filllen - 1] = '\n';
}
return ret.num;
}
static inline uintptr_t __attribute__ ((always_inline))
_dl_setup_pointer_guard (void *dl_random, uintptr_t stack_chk_guard)
{
uintptr_t ret;
ret = stack_chk_guard;
# ifndef HP_TIMING_NONAVAIL
hp_timing_t now;
HP_TIMING_NOW (now);
ret ^= now;
# endif
return ret;
}

View File

@ -0,0 +1,46 @@
/* Dynamic linker system dependencies for GNU/kFreeBSD.
Copyright (C) 2011 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. */
#include <ldsodefs.h>
#ifdef HAVE_AUX_VECTOR
#include <bits/auxv.h>
int _dl_clktck;
void
internal_function
_dl_aux_init (ElfW(auxv_t) *av)
{
for (; av->a_type != AT_NULL; ++av)
switch (av->a_type)
{
case AT_PAGESZ:
GLRO(dl_pagesize) = av->a_un.a_val;
break;
case AT_PHDR:
GL(dl_phdr) = (void *) av->a_un.a_val;
break;
case AT_PHNUM:
GL(dl_phnum) = av->a_un.a_val;
break;
}
}
#undef HAVE_AUX_VECTOR
#endif
#include <elf/dl-support.c>

View File

@ -0,0 +1,316 @@
/* Operating system support for run-time dynamic linker. GNU/kFreeBSD version.
Copyright (C) 1995-2013 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, see
<http://www.gnu.org/licenses/>. */
/* We conditionalize the whole of this file rather than simply eliding it
from the static build, because other sysdeps/ versions of this file
might define things needed by a static build. */
#include <stdlib.h>
#include <sys/sysctl.h>
#ifdef SHARED
#include <assert.h>
#include <elf.h>
#include <errno.h>
#include <fcntl.h>
#include <libintl.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <ldsodefs.h>
#include <_itoa.h>
#include <fpu_control.h>
#include <entry.h>
#include <dl-machine.h>
#include <dl-procinfo.h>
#include <dl-osinfo.h>
#include <hp-timing.h>
#include <tls.h>
extern char **_environ attribute_hidden;
extern char _end[] attribute_hidden;
/* Protect SUID program against misuse of file descriptors. */
extern void __libc_check_standard_fds (void);
#ifdef NEED_DL_BASE_ADDR
ElfW(Addr) _dl_base_addr;
#endif
int __libc_enable_secure attribute_relro = 0;
rtld_hidden_data_def (__libc_enable_secure)
int __libc_multiple_libcs = 0; /* Defining this here avoids the inclusion
of init-first. */
/* This variable contains the lowest stack address ever used. */
void *__libc_stack_end attribute_relro = NULL;
rtld_hidden_data_def(__libc_stack_end)
void *_dl_random attribute_relro = NULL;
#ifndef DL_FIND_ARG_COMPONENTS
# define DL_FIND_ARG_COMPONENTS(cookie, argc, argv, envp, auxp) \
do { \
void **_tmp; \
(argc) = *(long int *) cookie; \
(argv) = (char **) ((long int *) cookie + 1); \
(envp) = (argv) + (argc) + 1; \
for (_tmp = (void **) (envp); *_tmp; ++_tmp) \
continue; \
(auxp) = (void *) ++_tmp; \
} while (0)
#endif
#ifndef DL_STACK_END
# define DL_STACK_END(cookie) ((void *) (cookie))
#endif
extern const char *_self_program_name_from_auxv attribute_hidden;
ElfW(Addr)
_dl_sysdep_start (void **start_argptr,
void (*dl_main) (const ElfW(Phdr) *phdr, ElfW(Word) phnum,
ElfW(Addr) *user_entry, ElfW(auxv_t) *auxv))
{
const ElfW(Phdr) *phdr = NULL;
ElfW(Word) phnum = 0;
ElfW(Addr) user_entry;
ElfW(auxv_t) *av;
uid_t uid = 0;
gid_t gid = 0;
#ifdef NEED_DL_SYSINFO
uintptr_t new_sysinfo = 0;
#endif
__libc_stack_end = DL_STACK_END (start_argptr);
DL_FIND_ARG_COMPONENTS (start_argptr, _dl_argc, _dl_argv, _environ,
GLRO(dl_auxv));
user_entry = (ElfW(Addr)) ENTRY_POINT;
GLRO(dl_platform) = NULL; /* Default to nothing known about the platform. */
for (av = GLRO(dl_auxv); av->a_type != AT_NULL; av++)
switch (av->a_type)
{
case AT_PHDR:
phdr = (void *) av->a_un.a_val;
break;
case AT_PHNUM:
phnum = av->a_un.a_val;
break;
case AT_PAGESZ:
GLRO(dl_pagesize) = av->a_un.a_val;
break;
case AT_ENTRY:
user_entry = av->a_un.a_val;
break;
case AT_EXECPATH:
_self_program_name_from_auxv = (char *) av->a_un.a_val;
break;
#ifdef NEED_DL_BASE_ADDR
case AT_BASE:
_dl_base_addr = av->a_un.a_val;
break;
#endif
}
{
/* Fill in the values we have not gotten from the kernel through the
auxiliary vector. */
# undef SEE
# define SEE(UID, var, uid) \
var ^= __get##uid ()
SEE (UID, uid, uid);
SEE (EUID, uid, euid);
SEE (GID, gid, gid);
SEE (EGID, gid, egid);
/* If one of the two pairs of IDs does not match this is a setuid
or setgid run. */
__libc_enable_secure = uid | gid;
}
#ifndef HAVE_AUX_PAGESIZE
if (GLRO(dl_pagesize) == 0)
GLRO(dl_pagesize) = __getpagesize ();
#endif
#if defined NEED_DL_SYSINFO
/* Only set the sysinfo value if we also have the vsyscall DSO. */
if (GLRO(dl_sysinfo_dso) != 0 && new_sysinfo)
GLRO(dl_sysinfo) = new_sysinfo;
#endif
#ifdef DL_SYSDEP_INIT
DL_SYSDEP_INIT;
#endif
#ifdef DL_PLATFORM_INIT
DL_PLATFORM_INIT;
#endif
/* Determine the length of the platform name. */
if (GLRO(dl_platform) != NULL)
GLRO(dl_platformlen) = strlen (GLRO(dl_platform));
if (__sbrk (0) == _end)
/* The dynamic linker was run as a program, and so the initial break
starts just after our bss, at &_end. The malloc in dl-minimal.c
will consume the rest of this page, so tell the kernel to move the
break up that far. When the user program examines its break, it
will see this new value and not clobber our data. */
__sbrk (GLRO(dl_pagesize)
- ((_end - (char *) 0) & (GLRO(dl_pagesize) - 1)));
/* If this is a SUID program we make sure that FDs 0, 1, and 2 are
allocated. If necessary we are doing it ourself. If it is not
possible we stop the program. */
if (__builtin_expect (__libc_enable_secure, 0))
__libc_check_standard_fds ();
(*dl_main) (phdr, phnum, &user_entry, GLRO(dl_auxv));
return user_entry;
}
void
internal_function
_dl_show_auxv (void)
{
char buf[64];
ElfW(auxv_t) *av;
/* Terminate string. */
buf[63] = '\0';
/* The following code assumes that the AT_* values are encoded
starting from 0 with AT_NULL, 1 for AT_IGNORE, and all other values
close by (otherwise the array will be too large). In case we have
to support a platform where these requirements are not fulfilled
some alternative implementation has to be used. */
for (av = GLRO(dl_auxv); av->a_type != AT_NULL; ++av)
{
static const struct
{
const char label[17];
enum { unknown = 0, dec, hex, str, ignore } form : 8;
} auxvars[] =
{
[AT_EXECFD - 2] = { "EXECFD: ", dec },
[AT_PHDR - 2] = { "PHDR: 0x", hex },
[AT_PHENT - 2] = { "PHENT: ", dec },
[AT_PHNUM - 2] = { "PHNUM: ", dec },
[AT_PAGESZ - 2] = { "PAGESZ: ", dec },
[AT_BASE - 2] = { "BASE: 0x", hex },
[AT_FLAGS - 2] = { "FLAGS: 0x", hex },
[AT_ENTRY - 2] = { "ENTRY: 0x", hex },
#ifndef __powerpc__
/* For some odd reason these are not in sys/powerpc/include/elf.h. */
[AT_NOTELF - 2] = { "NOTELF: ", hex },
[AT_UID - 2] = { "UID: ", dec },
[AT_EUID - 2] = { "EUID: ", dec },
[AT_GID - 2] = { "GID: ", dec },
[AT_EGID - 2] = { "EGID: ", dec },
#endif
[AT_EXECPATH - 2] = { "EXECPATH: ", str },
[AT_CANARY - 2] = { "CANARY: 0x", hex },
[AT_CANARYLEN - 2] = { "CANARYLEN: ", dec },
[AT_OSRELDATE - 2] = { "OSRELDATE: ", dec },
[AT_NCPUS - 2] = { "NCPUS: ", dec },
[AT_PAGESIZES - 2] = { "PAGESIZES: 0x", hex },
[AT_PAGESIZESLEN - 2] = { "PAGESIZESLEN: ", dec },
[AT_TIMEKEEP - 2] = { "TIMEKEEP: 0x", hex },
[AT_STACKPROT - 2] = { "STACKPROT: 0x", hex },
};
unsigned int idx = (unsigned int) (av->a_type - 2);
if ((unsigned int) av->a_type < 2u || auxvars[idx].form == ignore)
continue;
assert (AT_NULL == 0);
assert (AT_IGNORE == 1);
if (idx < sizeof (auxvars) / sizeof (auxvars[0])
&& auxvars[idx].form != unknown)
{
const char *val = (char *) av->a_un.a_val;
if (__builtin_expect (auxvars[idx].form, dec) == dec)
val = _itoa ((unsigned long int) av->a_un.a_val,
buf + sizeof buf - 1, 10, 0);
else if (__builtin_expect (auxvars[idx].form, hex) == hex)
val = _itoa ((unsigned long int) av->a_un.a_val,
buf + sizeof buf - 1, 16, 0);
_dl_printf ("AT_%s%s\n", auxvars[idx].label, val);
continue;
}
/* Unknown value: print a generic line. */
char buf2[17];
buf2[sizeof (buf2) - 1] = '\0';
const char *val2 = _itoa ((unsigned long int) av->a_un.a_val,
buf2 + sizeof buf2 - 1, 16, 0);
const char *val = _itoa ((unsigned long int) av->a_type,
buf + sizeof buf - 1, 16, 0);
_dl_printf ("AT_??? (0x%s): 0x%s\n", val, val2);
}
}
void
internal_function
_dl_sysdep_start_cleanup (void)
{
}
#endif
int
attribute_hidden
_dl_discover_osversion (void)
{
int request[2] = { CTL_KERN, KERN_OSRELDATE };
size_t len;
int version;
int subrelease;
len = sizeof(version);
if (__sysctl (request, 2, &version, &len, NULL, 0) < 0)
return -1;
/*
* since 8.0 release
* scheme is: <major><two digit minor>Rxx
* 'R' is in the range 0 to 4 if this is a release branch or
* x.0-CURRENT before RELENG_*_0 is created, otherwise 'R' is
* in the range 5 to 9.
*/
/* Convert to the GLIBC versioning system */
subrelease = version % 1000;
if (subrelease >= 500)
subrelease -= 300; /* hopefull 55 values suffice for stable update */
if (subrelease > 255) /* it have to fit into byte */
subrelease = 255;
return ((version / 100000) << 16) /* major */
| (((version % 100000) / 1000) << 8) /* minor 0 - 99 */
| subrelease;
}

View File

@ -0,0 +1,26 @@
/* System-specific settings for dynamic linker code. Linux version.
Copyright (C) 2005, 2008 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. */
#include_next <dl-sysdep.h>
#ifndef __ASSEMBLER__
/* Get version of the OS. */
extern int _dl_discover_osversion (void) attribute_hidden;
# define HAVE_DL_DISCOVER_OSVERSION 1
#endif

View File

@ -0,0 +1,38 @@
/* Message-writing for the dynamic linker.
Copyright (C) 2013 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, see
<http://www.gnu.org/licenses/>. */
#include <sys/uio.h>
#include <sysdep.h>
/* This is used from only one place: dl-misc.c:_dl_debug_vdprintf.
Hence it's in a header with the expectation it will be inlined.
This is writev, but with a constraint added and others loosened:
1. Under RTLD_PRIVATE_ERRNO, it must not clobber the private errno
when another thread holds the dl_load_lock.
2. It is not obliged to detect and report errors at all.
3. It's not really obliged to deliver a single atomic write
(though it may be preferable). */
static inline void
_dl_writev (int fd, const struct iovec *iov, size_t niov)
{
INTERNAL_SYSCALL_DECL (err);
INTERNAL_SYSCALL (writev, err, 3, fd, iov, niov);
}

View File

@ -0,0 +1,64 @@
/* Test for access to file, relative to open directory. Linux version.
Copyright (C) 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. */
#include <errno.h>
#include <fcntl.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/user.h>
#include <kernel-features.h>
#include <sysdep.h>
extern int __syscall_faccessat (int fd, const char *path, int mode, int flag);
libc_hidden_proto (__syscall_faccessat)
/*
The FreeBSD kernel do not test file access correctly when the
process' real user ID is superuser. In particular, they always return
zero when testing execute permissions without regard to whether the
file is executable.
While this behaviour conforms to POSIX.1-2008, it is explicitely
discouraged. This wrapper implements the recommended behaviour.
*/
int
faccessat (int fd, const char *file, int mode, int flag)
{
int result = INLINE_SYSCALL (faccessat, 4, fd, file, mode, flag);
if ((result == 0) && (mode & X_OK))
{
uid_t uid = (flag & AT_EACCESS) ? __geteuid () : __getuid ();
if (uid == 0)
{
struct stat64 stats;
if (fstatat64 (fd, file, &stats, flag & AT_SYMLINK_NOFOLLOW))
return -1;
if ((stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0)
{
__set_errno (EACCES);
return -1;
}
}
}
return result;
}

View File

@ -0,0 +1 @@
pthread

View File

@ -0,0 +1,62 @@
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see
# <http://www.gnu.org/licenses/>.
ifeq ($(subdir),fbtl)
sysdep_routines += register-atfork unregister-atfork libc_pthread_init \
libc_multiple_threads
libpthread-sysdep_routines += pt-fork pthread_mutex_cond_lock
gen-as-const-headers += lowlevelrwlock.sym \
unwindbuf.sym \
structsem.sym
#gen-as-const-headers += lowlevelcond.sym lowlevelrwlock.sym \
# lowlevelbarrier.sym unwindbuf.sym \
# lowlevelrobustlock.sym pthread-pi-defines.sym \
# structsem.sym
endif
ifeq ($(subdir),fbtl)
routines += sys_thr_kill sys_thr_self
routines += sys_sigwaitinfo sys_sigwait sys_sigtimedwait
libpthread-routines += ptw-sys_sigwaitinfo ptw-sys_sigwait ptw-sys_sigtimedwait
libpthread-routines += ptw-sys_sigprocmask ptw-sys_umtx
libpthread-routines += ptw-sys_thr_kill
libpthread-routines += ptw-sys_thr_kill2
libpthread-routines += ptw-sys_thr_new
libpthread-routines += ptw-sys_thr_self
libpthread-routines += ptw-sys_thr_set_name
libpthread-routines += ptw-sys_thr_exit
libpthread-routines += ptw-sigprocmask
libpthread-routines += ptw-ioctl
libpthread-routines += ptw-sys_clock_getcpuclockid2
endif
ifeq ($(subdir),rt)
sysdep_routines += sys_clock_getcpuclockid2
endif
ifeq ($(subdir),posix)
CFLAGS-fork.c = $(libio-mtsafe)
CFLAGS-getpid.o = -fomit-frame-pointer
CFLAGS-getpid.os = -fomit-frame-pointer
endif
# Needed in both the signal and nptl subdir.
CFLAGS-sigaction.c = -DWRAPPER_INCLUDE='<fbtl/sigaction.c>'

View File

@ -0,0 +1,18 @@
libc {
GLIBC_2.3.2 {
__register_atfork;
}
GLIBC_PRIVATE {
__libc_pthread_init;
__libc_current_sigrtmin_private; __libc_current_sigrtmax_private;
__libc_allocate_rtsig_private;
# needed by pthread library
__syscall_sigprocmask;
__syscall_sigwaitinfo;
__syscall_sigsuspend;
__syscall_sigaction;
__syscall__umtx_op;
# needed by librt as INLINE_SYSCALL:
__syscall_clock_getcpuclockid2;
}
}

View File

@ -0,0 +1,65 @@
/* Copyright (C) 2004-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
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, see <http://www.gnu.org/licenses/>. */
#ifndef _AIO_MISC_H
# include_next <aio_misc.h>
# include <limits.h>
# include <pthread.h>
# include <signal.h>
# include <sysdep.h>
# define aio_start_notify_thread __aio_start_notify_thread
# define aio_create_helper_thread __aio_create_helper_thread
extern inline void
__aio_start_notify_thread (void)
{
sigset_t ss;
sigemptyset (&ss);
INLINE_SYSCALL (sigprocmask, 3, SIG_SETMASK, &ss, NULL);
}
extern inline int
__aio_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
void *arg)
{
pthread_attr_t attr;
/* Make sure the thread is created detached. */
pthread_attr_init (&attr);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
/* The helper thread needs only very little resources. */
(void) pthread_attr_setstacksize (&attr, __pthread_get_minstack (&attr));
/* Block all signals in the helper thread. To do this thoroughly we
temporarily have to block all signals here. */
sigset_t ss;
sigset_t oss;
sigfillset (&ss);
INLINE_SYSCALL (sigprocmask, 3, SIG_SETMASK, &ss, &oss);
int ret = pthread_create (threadp, &attr, tf, arg);
/* Restore the signal mask. */
INLINE_SYSCALL (sigprocmask, 3, SIG_SETMASK, &oss, NULL);
(void) pthread_attr_destroy (&attr);
return ret;
}
#endif

View File

@ -0,0 +1,55 @@
/* Copyright (C) 2002-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see
<http://www.gnu.org/licenses/>. */
#include <signal.h>
static int current_rtmin = __SIGRTMIN + 2;
static int current_rtmax = __SIGRTMAX;
/* We reserve __SIGRTMIN for use as the cancelation signal. This
signal is used internally. */
int
__libc_current_sigrtmin (void)
{
return current_rtmin;
}
libc_hidden_def (__libc_current_sigrtmin)
strong_alias (__libc_current_sigrtmin, __libc_current_sigrtmin_private)
int
__libc_current_sigrtmax (void)
{
return current_rtmax;
}
libc_hidden_def (__libc_current_sigrtmax)
strong_alias (__libc_current_sigrtmax, __libc_current_sigrtmax_private)
int
__libc_allocate_rtsig (int high)
{
if (current_rtmin == -1 || current_rtmin > current_rtmax)
/* We don't have anymore signal available. */
return -1;
return high ? current_rtmin++ : current_rtmax--;
}
strong_alias (__libc_allocate_rtsig, __libc_allocate_rtsig_private)

View File

@ -0,0 +1 @@
/* No thread support. */

View File

@ -0,0 +1,51 @@
/* Minimum guaranteed maximum values for system limits. FreeBSD version.
Copyright (C) 1993-1998, 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; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <sys/syslimits.h>
/* 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
/* We have no predefined limit on the number of threads. */
#undef PTHREAD_THREADS_MAX
/* 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 POSIX timers available. */
#define TIMER_MAX 256
/* Maximum number of timer expiration overruns. */
#define DELAYTIMER_MAX 2147483647
/* Maximum value the semaphore can have. */
#define SEM_VALUE_MAX (2147483647)

View File

@ -0,0 +1,203 @@
/* Define POSIX options for FreeBSD.
Copyright (C) 1996-1997, 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; 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 <unistd.h> instead.
*/
#ifndef _BITS_POSIX_OPT_H
#define _BITS_POSIX_OPT_H 1
#include <bits/os-unistd.h>
/* 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 200809L
/* Synchronizing file data is supported. */
#define _POSIX_SYNCHRONIZED_IO 200809L
/* The fsync function is present. */
#define _POSIX_FSYNC 200809L
/* Mapping of files to memory is supported. */
#define _POSIX_MAPPED_FILES 200809L
/* Locking of all memory is supported. */
#define _POSIX_MEMLOCK 200809L
/* Locking of ranges of memory is supported. */
#define _POSIX_MEMLOCK_RANGE 200809L
/* Setting of memory protections is supported. */
#define _POSIX_MEMORY_PROTECTION 200809L
/* 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 ((unsigned char)'\377')
/* Filenames are not silently truncated. */
#define _POSIX_NO_TRUNC 1
/* X/Open realtime support is only partially available. */
#define _XOPEN_REALTIME -1
/* X/Open realtime thread support is only partially available. */
#define _XOPEN_REALTIME_THREADS -1
/* Implementation supports `poll' function. */
#define _POSIX_POLL 1
/* Implementation supports `select' and `pselect' functions. */
#define _POSIX_SELECT 1
/* XPG4.2 shared memory is supported. */
#define _XOPEN_SHM 1
/* Tell we have POSIX threads. */
#define _POSIX_THREADS 200809L
/* We have the reentrant functions described in POSIX. */
#define _POSIX_REENTRANT_FUNCTIONS 1
#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L
/* We provide priority scheduling for threads. */
#define _POSIX_THREAD_PRIORITY_SCHEDULING 200809L
/* We support user-defined stack sizes. */
#define _POSIX_THREAD_ATTR_STACKSIZE 200809L
/* We support user-defined stacks. */
#define _POSIX_THREAD_ATTR_STACKADDR 200809L
/* We do not support priority inheritence. */
#define _POSIX_THREAD_PRIO_INHERIT -1
/* We do not support priority protection */
#define _POSIX_THREAD_PRIO_PROTECT -1
#ifdef __USE_XOPEN2K8
/* We do not support priority inheritence for robust mutexes. */
# define _POSIX_THREAD_ROBUST_PRIO_INHERIT -1
/* We do not support priority protection for robust mutexes. */
# define _POSIX_THREAD_ROBUST_PRIO_PROTECT -1
#endif
/* We support POSIX.1b semaphores. */
#define _POSIX_SEMAPHORES 200809L
/* Real-time signals are available. */
#define _POSIX_REALTIME_SIGNALS 200809L
/* We support asynchronous I/O. */
#define _POSIX_ASYNCHRONOUS_IO 200809L
#define _POSIX_ASYNC_IO 1
/* Alternative name for Unix98. */
#define _LFS_ASYNCHRONOUS_IO 1
/* Support for prioritization is not available. */
#define _POSIX_PRIORITIZED_IO -1
/* The LFS support in asynchronous I/O is also available. */
#define _LFS64_ASYNCHRONOUS_IO 1
/* The rest of the LFS is also available. */
#define _LFS_LARGEFILE 1
#define _LFS64_LARGEFILE 1
#define _LFS64_STDIO 1
/* POSIX shared memory objects are implemented. */
#define _POSIX_SHARED_MEMORY_OBJECTS 200809L
/* CPU-time clocks somewhere supported. */
#define _POSIX_CPUTIME 0
/* We support somewhere the clock also in threads. */
#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 200809L
/* We have a POSIX shell. */
#define _POSIX_SHELL 1
/* We support the Timeouts option. */
#define _POSIX_TIMEOUTS 200809L
/* We support spinlocks. */
#define _POSIX_SPIN_LOCKS 200809L
/* The `spawn' function family is supported. */
#define _POSIX_SPAWN 200809L
/* We have POSIX timers. */
#define _POSIX_TIMERS 200809L
/* The barrier functions are available. */
#define _POSIX_BARRIERS 200809L
/* POSIX message queues are not available. */
#define _POSIX_MESSAGE_PASSING -1
/* Thread process-shared synchronization is supported. */
#define _POSIX_THREAD_PROCESS_SHARED 200809L
/* The monotonic clock is available. */
#define _POSIX_MONOTONIC_CLOCK 200809L
/* The clock selection interfaces are available. */
#define _POSIX_CLOCK_SELECTION 200809L
/* Advisory information interfaces are available. */
#define _POSIX_ADVISORY_INFO 200809L
/* IPv6 support is available. */
#define _POSIX_IPV6 200809L
/* Raw socket support is available. */
#define _POSIX_RAW_SOCKETS 200809L
/* We have at least one terminal. */
#define _POSIX2_CHAR_TERM 200809L
/* 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
#endif /* bits/posix_opt.h */

View File

@ -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; 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 <pthread.h> 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 */

View File

@ -0,0 +1,91 @@
/* bits/typesizes.h -- underlying types for *_t. kFreeBSD version.
Copyright (C) 2002, 2003, 2010 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 <bits/typesizes.h> directly; use <sys/types.h> instead."
#endif
#ifndef _BITS_TYPESIZES_H
#define _BITS_TYPESIZES_H 1
/* See <bits/types.h> for the meaning of these macros. This file exists so
that <bits/types.h> need not vary across different GNU platforms. */
#define __DEV_T_TYPE __U32_TYPE
#define __UID_T_TYPE __U32_TYPE
#define __GID_T_TYPE __U32_TYPE
#define __INO_T_TYPE __U32_TYPE
#define __INO64_T_TYPE __UQUAD_TYPE
#define __MODE_T_TYPE __U16_TYPE
#define __NLINK_T_TYPE __U16_TYPE
#define __OFF_T_TYPE __SQUAD_TYPE
#define __OFF64_T_TYPE __SQUAD_TYPE
#define __PID_T_TYPE __S32_TYPE
#define __RLIM_T_TYPE __SQUAD_TYPE
#define __RLIM64_T_TYPE __SQUAD_TYPE
#define __BLKCNT_T_TYPE __SQUAD_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 __S32_TYPE
#define __FSWORD_T_TYPE __SWORD_TYPE
/*
* This one is a bit tricky. It needs to match the size
* in the sys/${arch}/include/_types.h typedefs.
*
* However, for i386 and amd64 we started with __SLONGWORD_TYPE
* and we need to maintain ABI. Even if size is the same, using
* a different type may affect C++ ABI (this distinction is
* necessary to implement function overload), so it must stay
* with __SLONGWORD_TYPE.
*/
#if defined(__i386__) || defined(__amd64__) || defined(__powerpc__)
#define __TIME_T_TYPE __SLONGWORD_TYPE
#else
#define __TIME_T_TYPE __S64_TYPE
#endif
#define __USECONDS_T_TYPE __U32_TYPE
#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
#define __DADDR_T_TYPE __SQUAD_TYPE
#define __SWBLK_T_TYPE __S32_TYPE
#define __KEY_T_TYPE __SLONGWORD_TYPE
#define __CLOCKID_T_TYPE __S32_TYPE
#define __TIMER_T_TYPE __S32_TYPE
#define __BLKSIZE_T_TYPE __U32_TYPE
#define __FSID_T_TYPE union { int __val[2]; int val[2]; }
#define __SSIZE_T_TYPE __SWORD_TYPE
#define __SNSECONDS_T_TYPE __SLONGWORD_TYPE
#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
/* Tell the libc code that off_t and off64_t are actually the same type
for all ABI purposes, even if possibly expressed as different base types
for C type-checking purposes. */
#define __OFF_T_MATCHES_OFF64_T 1
/* Number of descriptors that can fit in an `fd_set'. */
#define __FD_SETSIZE 1024
#endif /* bits/typesizes.h */

View File

@ -0,0 +1,28 @@
/* Copyright (C) 2013 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, see
<http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <time.h>
#include <unistd.h>
#include <kernel-features.h>
int
__clock_getcpuclockid (pid_t pid, clockid_t *clock_id)
{
return INLINE_SYSCALL(clock_getcpuclockid2, 3, pid, CPUCLOCK_WHICH_PID, clock_id);
}
strong_alias (__clock_getcpuclockid, clock_getcpuclockid)

View File

@ -0,0 +1,60 @@
/* Copyright (C) 2013 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, see
<http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <stdint.h>
#include <time.h>
#include <sys/time.h>
#include <libc-internal.h>
#include <ldsodefs.h>
#include <sysdep.h>
int __syscall_clock_getres(clockid_t clock_id, struct timespec *tp);
libc_hidden_proto (__syscall_clock_getres)
int __syscall_clock_gettime(clockid_t clock_id, struct timespec *tp);
libc_hidden_proto (__syscall_clock_gettime)
/* Get resolution of clock. */
int
__clock_getres (clockid_t clock_id, struct timespec *tp)
{
/* we could try to provide fallback
via ??? for CLOCK_REALTIME
via HP_TIMING for CLOCK_PROCESS_CPUTIME_ID,
CLOCK_THREAD_CPUTIME_ID and related timers
for now just pass it to kernel
*/
/* the negative clock_id means a CPU-timer, the resolution is same for all of them
the kernel returns resolution regardless whether the timer is accessible,
but POSIX/testsuite expects EINVAL
*/
if (clock_id < 0)
{
int rv;
/* we reuse user provided struct timespec */
rv = INLINE_SYSCALL (clock_gettime, 2, clock_id, tp);
if (rv != 0)
return rv;
/* valid, now really get the resolution */
}
return INLINE_SYSCALL (clock_getres, 2, clock_id, tp);
}
strong_alias (__clock_getres, clock_getres)

View File

@ -0,0 +1,43 @@
/* Copyright (C) 2013 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, see
<http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <stdint.h>
#include <time.h>
#include <sys/time.h>
#include <libc-internal.h>
#include <ldsodefs.h>
#include <sysdep.h>
int __syscall_clock_gettime(clockid_t clock_id, struct timespec *tp);
libc_hidden_proto (__syscall_clock_gettime)
/* Get current value of CLOCK and store it in TP. */
int
__clock_gettime (clockid_t clock_id, struct timespec *tp)
{
/* we could try to provide fallback
via gettimeofday for CLOCK_REALTIME
via HP_TIMING for CLOCK_PROCESS_CPUTIME_ID,
CLOCK_THREAD_CPUTIME_ID and related timers
for now just pass it to kernel
*/
return INLINE_SYSCALL (clock_gettime, 2, clock_id, tp);
}
weak_alias (__clock_gettime, clock_gettime)
libc_hidden_def (__clock_gettime)

View File

@ -0,0 +1,99 @@
/* High-resolution sleep with the specified clock.
Copyright (C) 2000-2012 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, see
<http://www.gnu.org/licenses/>. */
#include <assert.h>
#include <errno.h>
#include <time.h>
#include <hp-timing.h>
#include <sysdep-cancel.h>
int __syscall_clock_gettime(clockid_t clock_id, struct timespec *tp);
libc_hidden_proto (__syscall_clock_gettime)
/* This implementation assumes that these is only a `nanosleep' system
call. So we have to remap all other activities. */
int
__clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
struct timespec *rem)
{
struct timespec now;
if (__builtin_expect (req->tv_nsec, 0) < 0
|| __builtin_expect (req->tv_nsec, 0) >= 1000000000)
return EINVAL;
if (clock_id == CLOCK_THREAD_CPUTIME_ID)
return EINVAL; /* POSIX specifies EINVAL for this case. */
switch(clock_id)
{
case CLOCK_REALTIME:
case CLOCK_MONOTONIC:
case CLOCK_UPTIME:
case CLOCK_UPTIME_PRECISE:
case CLOCK_UPTIME_FAST:
case CLOCK_REALTIME_PRECISE:
case CLOCK_REALTIME_FAST:
case CLOCK_MONOTONIC_PRECISE:
case CLOCK_MONOTONIC_FAST:
case CLOCK_SECOND:
/* almost realtime clocks */
break;
default:
/* Not supported. */
return ENOTSUP;
}
/* If we got an absolute time, remap it. */
if (flags == TIMER_ABSTIME)
{
long int nsec;
long int sec;
/* Make sure we use safe data types. */
assert (sizeof (sec) >= sizeof (now.tv_sec));
/* Get the current time for this clock. */
if (__builtin_expect (INLINE_SYSCALL (clock_gettime, 2, clock_id, &now), 0) != 0)
return errno;
/* Compute the difference. */
nsec = req->tv_nsec - now.tv_nsec;
sec = req->tv_sec - now.tv_sec - (nsec < 0);
if (sec < 0)
/* The time has already elapsed. */
return 0;
now.tv_sec = sec;
now.tv_nsec = nsec + (nsec < 0 ? 1000000000 : 0);
/* From now on this is our time. */
req = &now;
/* Make sure we are not modifying the struct pointed to by REM. */
rem = NULL;
}
else if (__builtin_expect (flags, 0) != 0)
return EINVAL;
return __builtin_expect (__nanosleep (req, rem), 0) ? errno : 0;
}
strong_alias (__clock_nanosleep, clock_nanosleep)

View File

@ -0,0 +1,54 @@
/* Copyright (C) 2013 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, see
<http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <stdint.h>
#include <time.h>
#include <sys/time.h>
#include <libc-internal.h>
#include <ldsodefs.h>
#include <sysdep.h>
int __syscall_clock_settime(clockid_t clock_id, const struct timespec *tp);
libc_hidden_proto (__syscall_clock_settime)
/* Set CLOCK to value TP. */
int
__clock_settime (clockid_t clock_id, const struct timespec *tp)
{
switch(clock_id)
{
case CLOCK_MONOTONIC:
case CLOCK_MONOTONIC_PRECISE:
case CLOCK_MONOTONIC_FAST:
/* almost monotonic clocks */
__set_errno (EINVAL); /* per POSIX */
return -1;
break;
default:;
};
/* we could try to provide fallback
via settimeofday for CLOCK_REALTIME
via HP_TIMING for CLOCK_PROCESS_CPUTIME_ID,
CLOCK_THREAD_CPUTIME_ID and related timers
for now just pass it to kernel
*/
return INLINE_SYSCALL (clock_settime, 2, clock_id, tp);
}
strong_alias (__clock_settime, clock_settime)

View File

@ -0,0 +1,24 @@
/* Copyright (C) 2003-2013 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, see
<http://www.gnu.org/licenses/>. */
#include <pthread.h>
/* We have to completely disable cancellation. assert() must not be a
cancellation point but the implementation uses write() etc. */
#define FATAL_PREPARE \
__libc_ptf_call (__pthread_setcancelstate, \
(PTHREAD_CANCEL_DISABLE, NULL), 0)

View File

@ -0,0 +1,228 @@
/* Copyright (C) 2002-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see
<http://www.gnu.org/licenses/>. */
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sysdep.h>
#include <libio/libioP.h>
#include <tls.h>
#include "fork.h"
#include <hp-timing.h>
#include <ldsodefs.h>
#include <stdio-lock.h>
#include <atomic.h>
#include <pthreadP.h>
#include <malloc/malloc-internal.h>
static void
fresetlockfiles (void)
{
_IO_ITER i;
for (i = _IO_iter_begin(); i != _IO_iter_end(); i = _IO_iter_next(i))
_IO_lock_init (*((_IO_lock_t *) _IO_iter_file(i)->_lock));
}
pid_t
__libc_fork (void)
{
pid_t pid;
struct used_handler
{
struct fork_handler *handler;
struct used_handler *next;
} *allp = NULL;
/* Determine if we are running multiple threads. We skip some fork
handlers in the single-thread case, to make fork safer to use in
signal handlers. POSIX requires that fork is async-signal-safe,
but our current fork implementation is not. */
bool multiple_threads = THREAD_GETMEM (THREAD_SELF, header.multiple_threads);
/* Run all the registered preparation handlers. In reverse order.
While doing this we build up a list of all the entries. */
struct fork_handler *runp;
while ((runp = __fork_handlers) != NULL)
{
/* Make sure we read from the current RUNP pointer. */
atomic_full_barrier ();
unsigned int oldval = runp->refcntr;
if (oldval == 0)
/* This means some other thread removed the list just after
the pointer has been loaded. Try again. Either the list
is empty or we can retry it. */
continue;
/* Bump the reference counter. */
if (atomic_compare_and_exchange_bool_acq (&__fork_handlers->refcntr,
oldval + 1, oldval))
/* The value changed, try again. */
continue;
/* We bumped the reference counter for the first entry in the
list. That means that none of the following entries will
just go away. The unloading code works in the order of the
list.
While executing the registered handlers we are building a
list of all the entries so that we can go backward later on. */
while (1)
{
/* Execute the handler if there is one. */
if (runp->prepare_handler != NULL)
runp->prepare_handler ();
/* Create a new element for the list. */
struct used_handler *newp
= (struct used_handler *) alloca (sizeof (*newp));
newp->handler = runp;
newp->next = allp;
allp = newp;
/* Advance to the next handler. */
runp = runp->next;
if (runp == NULL)
break;
/* Bump the reference counter for the next entry. */
atomic_increment (&runp->refcntr);
}
/* We are done. */
break;
}
/* If we are not running multiple threads, we do not have to
preserve lock state. If fork runs from a signal handler, only
async-signal-safe functions can be used in the child. These data
structures are only used by unsafe functions, so their state does
not matter if fork was called from a signal handler. */
if (multiple_threads)
{
_IO_list_lock ();
/* Acquire malloc locks. This needs to come last because fork
handlers may use malloc, and the libio list lock has an
indirect malloc dependency as well (via the getdelim
function). */
call_function_static_weak (__malloc_fork_lock_parent);
}
#ifdef ARCH_FORK
pid = ARCH_FORK ();
#else
# warning "ARCH_FORK must be defined so that the CLONE_SETTID flag is used"
pid = INLINE_SYSCALL (fork, 0);
#endif
if (pid == 0)
{
struct pthread *self = THREAD_SELF;
INLINE_SYSCALL(thr_self, 1, &(self->ktid));
if (__fork_generation_pointer != NULL)
*__fork_generation_pointer += 4;
#if HP_TIMING_AVAIL
/* The CPU clock of the thread and process have to be set to zero. */
hp_timing_t now;
HP_TIMING_NOW (now);
THREAD_SETMEM (self, cpuclock_offset, now);
GL(dl_cpuclock_offset) = now;
#endif
/* Reset the lock state in the multi-threaded case. */
if (multiple_threads)
{
/* Release malloc locks. */
call_function_static_weak (__malloc_fork_unlock_child);
/* Reset the file list. These are recursive mutexes. */
fresetlockfiles ();
/* Reset locks in the I/O code. */
_IO_list_resetlock ();
}
/* Reset the lock the dynamic loader uses to protect its data. */
__rtld_lock_initialize (GL(dl_load_lock));
/* Run the handlers registered for the child. */
while (allp != NULL)
{
if (allp->handler->child_handler != NULL)
allp->handler->child_handler ();
/* Note that we do not have to wake any possible waiter.
This is the only thread in the new process. The count
may have been bumped up by other threads doing a fork.
We reset it to 1, to avoid waiting for non-existing
thread(s) to release the count. */
allp->handler->refcntr = 1;
/* XXX We could at this point look through the object pool
and mark all objects not on the __fork_handlers list as
unused. This is necessary in case the fork() happened
while another thread called dlclose() and that call had
to create a new list. */
allp = allp->next;
}
/* Initialize the fork lock. */
__fork_lock = LLL_LOCK_INITIALIZER;
}
else
{
/* Release acquired locks in the multi-threaded case. */
if (multiple_threads)
{
/* Release malloc locks, parent process variant. */
call_function_static_weak (__malloc_fork_unlock_parent);
/* We execute this even if the 'fork' call failed. */
_IO_list_unlock ();
}
/* Run the handlers registered for the parent. */
while (allp != NULL)
{
if (allp->handler->parent_handler != NULL)
allp->handler->parent_handler ();
if (atomic_decrement_and_test (&allp->handler->refcntr)
&& allp->handler->need_signal)
lll_futex_wake (&allp->handler->refcntr, 1, LLL_PRIVATE);
allp = allp->next;
}
}
return pid;
}
weak_alias (__libc_fork, __fork)
libc_hidden_def (__fork)
weak_alias (__libc_fork, fork)

View File

@ -0,0 +1,59 @@
/* Copyright (C) 2002-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see
<http://www.gnu.org/licenses/>. */
#include <lowlevellock.h>
/* The fork generation counter, defined in libpthread. */
extern unsigned long int __fork_generation attribute_hidden;
/* Pointer to the fork generation counter in the thread library. */
extern unsigned long int *__fork_generation_pointer attribute_hidden;
/* Lock to protect allocation and deallocation of fork handlers. */
extern int __fork_lock attribute_hidden;
/* Elements of the fork handler lists. */
struct fork_handler
{
struct fork_handler *next;
void (*prepare_handler) (void);
void (*parent_handler) (void);
void (*child_handler) (void);
void *dso_handle;
unsigned int refcntr;
int need_signal;
};
/* The single linked list of all currently registered for handlers. */
extern struct fork_handler *__fork_handlers attribute_hidden;
/* Function to call to unregister fork handlers. */
extern void __unregister_atfork (void *dso_handle) attribute_hidden;
#define UNREGISTER_ATFORK(dso_handle) __unregister_atfork (dso_handle)
/* C library side function to register new fork handlers. */
extern int __register_atfork (void (*__prepare) (void),
void (*__parent) (void),
void (*__child) (void),
void *dso_handle);
libc_hidden_proto (__register_atfork)
/* Add a new element to the fork list. */
extern void __linkin_atfork (struct fork_handler *newp) attribute_hidden;

View File

@ -0,0 +1,120 @@
/* Copyright (C) 2006-2013 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, see
<http://www.gnu.org/licenses/>. */
/* We define a special synchronization primitive for AIO. POSIX
conditional variables would be ideal but the pthread_cond_*wait
operations do not return on EINTR. This is a requirement for
correct aio_suspend and lio_listio implementations. */
#include <assert.h>
#include <signal.h>
#include <pthreadP.h>
#include <lowlevellock.h>
#define DONT_NEED_GAI_MISC_COND 1
#define GAI_MISC_NOTIFY(waitlist) \
do { \
if (*waitlist->counterp > 0 && --*waitlist->counterp == 0) \
lll_futex_wake ((unsigned int *) waitlist->counterp, 1, LLL_PRIVATE); \
} while (0)
#warning have to check sign of return values from futex wait calls
#define GAI_MISC_WAIT(result, futex, timeout, cancel) \
do { \
volatile int *futexaddr = &futex; \
int oldval = futex; \
\
if (oldval != 0) \
{ \
pthread_mutex_unlock (&__gai_requests_mutex); \
\
int oldtype; \
if (cancel) \
oldtype = LIBC_CANCEL_ASYNC (); \
\
int status; \
do \
{ \
status = lll_futex_timed_wait ((unsigned int *) futexaddr, oldval,\
timeout, LLL_PRIVATE); \
if (status != EWOULDBLOCK) \
break; \
\
oldval = *futexaddr; \
} \
while (oldval != 0); \
\
if (cancel) \
LIBC_CANCEL_RESET (oldtype); \
\
if (status == EINTR) \
result = EINTR; \
else if (status == ETIMEDOUT) \
result = EAGAIN; \
else \
assert (status == 0 || status == EWOULDBLOCK); \
\
pthread_mutex_lock (&__gai_requests_mutex); \
} \
} while (0)
#define gai_start_notify_thread __gai_start_notify_thread
#define gai_create_helper_thread __gai_create_helper_thread
extern inline void
__gai_start_notify_thread (void)
{
sigset_t ss;
sigemptyset (&ss);
INLINE_SYSCALL (sigprocmask, 3, SIG_SETMASK, &ss, NULL);
}
extern inline int
__gai_create_helper_thread (pthread_t *threadp, void *(*tf) (void *),
void *arg)
{
pthread_attr_t attr;
/* Make sure the thread is created detached. */
pthread_attr_init (&attr);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
/* The helper thread needs only very little resources. */
(void) pthread_attr_setstacksize (&attr,
__pthread_get_minstack (&attr)
+ 4 * PTHREAD_STACK_MIN);
/* Block all signals in the helper thread. To do this thoroughly we
temporarily have to block all signals here. */
sigset_t ss;
sigset_t oss;
sigfillset (&ss);
INLINE_SYSCALL (sigprocmask, 3, SIG_SETMASK, &ss, &oss);
int ret = pthread_create (threadp, &attr, tf, arg);
/* Restore the signal mask. */
INLINE_SYSCALL (sigprocmask, 3, SIG_SETMASK, &oss, NULL);
(void) pthread_attr_destroy (&attr);
return ret;
}
#include <resolv/gai_misc.h>

View File

@ -0,0 +1,169 @@
/* Copyright (C) 2002-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see
<http://www.gnu.org/licenses/>. */
#ifndef _INTERNALTYPES_H
#define _INTERNALTYPES_H 1
#include <stdint.h>
struct pthread_attr
{
/* Scheduler parameters and priority. */
struct sched_param schedparam;
int schedpolicy;
/* Various flags like detachstate, scope, etc. */
int flags;
/* Size of guard area. */
size_t guardsize;
/* Stack handling. */
void *stackaddr;
size_t stacksize;
/* Affinity map. */
cpu_set_t *cpuset;
size_t cpusetsize;
};
#define ATTR_FLAG_DETACHSTATE 0x0001
#define ATTR_FLAG_NOTINHERITSCHED 0x0002
#define ATTR_FLAG_SCOPEPROCESS 0x0004
#define ATTR_FLAG_STACKADDR 0x0008
#define ATTR_FLAG_OLDATTR 0x0010
#define ATTR_FLAG_SCHED_SET 0x0020
#define ATTR_FLAG_POLICY_SET 0x0040
/* Mutex attribute data structure. */
struct pthread_mutexattr
{
/* Identifier for the kind of mutex.
Bit 31 is set if the mutex is to be shared between processes.
Bit 0 to 30 contain one of the PTHREAD_MUTEX_ values to identify
the type of the mutex. */
int mutexkind;
};
/* Conditional variable attribute data structure. */
struct pthread_condattr
{
/* Combination of values:
Bit 0 : flag whether coditional variable will be shareable between
processes.
Bit 1-7: clock ID. */
int value;
};
/* The __NWAITERS field is used as a counter and to house the number
of bits for other purposes. COND_CLOCK_BITS is the number
of bits needed to represent the ID of the clock. COND_NWAITERS_SHIFT
is the number of bits reserved for other purposes like the clock. */
/* Under FreeBSD:
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 4
we therefore need at least 3 bits
*/
#define COND_CLOCK_BITS 4
#define COND_NWAITERS_SHIFT (COND_CLOCK_BITS)
/* Read-write lock variable attribute data structure. */
struct pthread_rwlockattr
{
int lockkind;
int pshared;
};
/* Barrier data structure. */
struct pthread_barrier
{
unsigned int curr_event;
int lock;
unsigned int left;
unsigned int init_count;
int private;
};
/* Barrier variable attribute data structure. */
struct pthread_barrierattr
{
int pshared;
};
/* Thread-local data handling. */
struct pthread_key_struct
{
/* Sequence numbers. Even numbers indicated vacant entries. Note
that zero is even. We use uintptr_t to not require padding on
32- and 64-bit machines. On 64-bit machines it helps to avoid
wrapping, too. */
uintptr_t seq;
/* Destructor for the data. */
void (*destr) (void *);
};
/* Check whether an entry is unused. */
#define KEY_UNUSED(p) (((p) & 1) == 0)
/* Check whether a key is usable. We cannot reuse an allocated key if
the sequence counter would overflow after the next destroy call.
This would mean that we potentially free memory for a key with the
same sequence. This is *very* unlikely to happen, A program would
have to create and destroy a key 2^31 times (on 32-bit platforms,
on 64-bit platforms that would be 2^63). If it should happen we
simply don't use this specific key anymore. */
#define KEY_USABLE(p) (((uintptr_t) (p)) < ((uintptr_t) ((p) + 2)))
/* Handling of read-write lock data. */
// XXX For now there is only one flag. Maybe more in future.
#define RWLOCK_RECURSIVE(rwlock) ((rwlock)->__data.__flags != 0)
/* Semaphore variable structure. */
struct new_sem
{
unsigned int value;
int private;
unsigned long int nwaiters;
};
struct old_sem
{
unsigned int value;
};
/* Compatibility type for old conditional variable interfaces. */
typedef struct
{
pthread_cond_t *cond;
} pthread_cond_2_0_t;
#endif /* internaltypes.h */

View File

@ -0,0 +1,38 @@
/* Clean up stack frames unwound by longjmp. Linux version.
Copyright (C) 1995-2013 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, see
<http://www.gnu.org/licenses/>. */
#include <setjmp.h>
#include <stddef.h>
#include <pthreadP.h>
extern void __pthread_cleanup_upto (__jmp_buf env, char *targetframe);
#pragma weak __pthread_cleanup_upto
void
_longjmp_unwind (jmp_buf env, int val)
{
#ifdef SHARED
if (__libc_pthread_functions_init)
PTHFCT_CALL (ptr___pthread_cleanup_upto, (env->__jmpbuf,
CURRENT_STACK_FRAME));
#else
if (__pthread_cleanup_upto != NULL)
__pthread_cleanup_upto (env->__jmpbuf, CURRENT_STACK_FRAME);
#endif
}

View File

@ -0,0 +1,138 @@
/* Copyright (C) 2003, 2007, 2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 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; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <pthread.h>
#include <setjmp.h>
#include <signal.h>
#include <sys/types.h>
/* Nonzero if the system calls are not available. */
extern int __no_posix_timers attribute_hidden;
/* Callback to start helper thread. */
extern void __start_helper_thread (void) attribute_hidden;
/* Control variable for helper thread creation. */
extern pthread_once_t __helper_once attribute_hidden;
/* TID of the helper thread. */
extern pid_t __helper_tid attribute_hidden;
/* List of active SIGEV_THREAD timers. */
extern struct timer *__active_timer_sigev_thread attribute_hidden;
/* Lock for the __active_timer_sigev_thread. */
extern pthread_mutex_t __active_timer_sigev_thread_lock attribute_hidden;
/* Type of timers in the kernel. */
typedef int kernel_timer_t;
/* Internal representation of timer. */
struct timer
{
/* Notification mechanism. */
int sigev_notify;
/* Timer ID returned by the kernel. */
kernel_timer_t ktimerid;
/* All new elements must be added after ktimerid. And if the thrfunc
element is not the third element anymore the memory allocation in
timer_create needs to be changed. */
/* Parameters for the thread to be started for SIGEV_THREAD. */
void (*thrfunc) (sigval_t);
sigval_t sival;
pthread_attr_t attr;
/* Next element in list of active SIGEV_THREAD timers. */
struct timer *next;
};
extern struct timer *__all_timers[TIMER_MAX];
static inline struct timer *
__kfreebsd_timer_alloc (void)
{
unsigned int i;
struct timer *timer = malloc (sizeof (struct timer));
if (timer == NULL)
goto fail;
/* Find a free slot (and reserve it atomically). */
for (i = 0; i < TIMER_MAX; i++)
if (atomic_compare_and_exchange_val_acq (&__all_timers[i],
timer, NULL) == NULL)
return timer;
free (timer);
fail:
errno = EAGAIN;
return NULL;
}
static inline struct timer *
__kfreebsd_timer_id2ptr (timer_t id)
{
void *ret = NULL;
if (id >= 0 && id < TIMER_MAX)
ret = __all_timers[id];
if (! ret)
errno = EINVAL;
return ret;
}
static inline timer_t
__kfreebsd_timer_ptr2id (struct timer *ptr)
{
unsigned int i;
for (i = 0; i < TIMER_MAX; i++)
if (__all_timers[i] == ptr)
return i;
return -1;
}
void static inline
__kfreebsd_timer_free (struct timer *ptr)
{
__all_timers[__kfreebsd_timer_ptr2id (ptr)] = NULL;
free (ptr);
}
/* used syscalls */
int __syscall_ktimer_create (clockid_t clockid, struct sigevent *evp, kernel_timer_t *timerid);
int __syscall_ktimer_delete (kernel_timer_t timerid);
int __syscall_ktimer_getoverrun (kernel_timer_t timerid);
int __syscall_ktimer_gettime (kernel_timer_t timerid, struct itimerspec *value);
int __syscall_ktimer_settime (kernel_timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue);
libc_hidden_proto (__syscall_ktimer_create)
libc_hidden_proto (__syscall_ktimer_delete)
libc_hidden_proto (__syscall_ktimer_getoverrun)
libc_hidden_proto (__syscall_ktimer_gettime)
libc_hidden_proto (__syscall_ktimer_settime)

View File

@ -0,0 +1,20 @@
/* Copyright (C) 2003-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Paul Mackerras <paulus@au.ibm.com>, 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, see
<http://www.gnu.org/licenses/>. */
/* No difference to lowlevellock.c, except we lose a couple of functions. */
#include <lowlevellock.c>

View File

@ -0,0 +1,28 @@
/* Copyright (C) 2002-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see
<http://www.gnu.org/licenses/>. */
#include <pthreadP.h>
#if IS_IN (libc)
# ifndef TLS_MULTIPLE_THREADS_IN_TCB
/* Variable set to a nonzero value either if more than one thread runs or ran,
or if a single-threaded process is trying to cancel itself. See
nptl/descr.h for more context on the single-threaded process case. */
int __libc_multiple_threads attribute_hidden;
# endif
#endif

View File

@ -0,0 +1,88 @@
/* Copyright (C) 2002-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see
<http://www.gnu.org/licenses/>. */
#include <unistd.h>
#include <list.h>
#include <fork.h>
#include <dl-sysdep.h>
#include <tls.h>
#include <string.h>
#include <pthreadP.h>
#include <libc-lock.h>
#include <sysdep.h>
#include <ldsodefs.h>
unsigned long int *__fork_generation_pointer;
#ifdef TLS_MULTIPLE_THREADS_IN_TCB
void
#else
extern int __libc_multiple_threads attribute_hidden;
int *
#endif
internal_function
__libc_pthread_init (unsigned long int *ptr, void (*reclaim) (void),
const struct pthread_functions *functions)
{
/* Remember the pointer to the generation counter in libpthread. */
__fork_generation_pointer = ptr;
/* Called by a child after fork. */
__register_atfork (NULL, NULL, reclaim, NULL);
#ifdef SHARED
/* Copy the function pointers into an array in libc. This enables
access with just one memory reference but moreso, it prevents
hijacking the function pointers with just one pointer change. We
"encrypt" the function pointers since we cannot write-protect the
array easily enough. */
union ptrhack
{
struct pthread_functions pf;
# define NPTRS (sizeof (struct pthread_functions) / sizeof (void *))
void *parr[NPTRS];
} __attribute__ ((may_alias)) const *src;
union ptrhack *dest;
src = (const void *) functions;
dest = (void *) &__libc_pthread_functions;
for (size_t cnt = 0; cnt < NPTRS; ++cnt)
{
void *p = src->parr[cnt];
PTR_MANGLE (p);
dest->parr[cnt] = p;
}
__libc_pthread_functions_init = 1;
#endif
#ifndef TLS_MULTIPLE_THREADS_IN_TCB
return &__libc_multiple_threads;
#endif
}
#ifdef SHARED
libc_freeres_fn (freeres_libptread)
{
if (__libc_pthread_functions_init)
PTHFCT_CALL (ptr_freeres, ());
}
#endif

View File

@ -0,0 +1,129 @@
/* low level locking for pthread library. Generic futex-using version.
Copyright (C) 2003-2013 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, see
<http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <sysdep.h>
#include <lowlevellock.h>
#include <sys/time.h>
void
__lll_lock_wait_private (int *futex)
{
do
{
int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
if (oldval != 0)
lll_futex_wait (futex, 2, LLL_PRIVATE);
}
while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
}
/* These functions don't get included in libc.so */
#if IS_IN (libpthread)
void
__lll_lock_wait_shared (int *futex)
{
do
{
int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
if (oldval != 0)
lll_futex_wait (futex, 2, LLL_SHARED);
}
while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
}
int
__lll_timedlock_wait (int *futex, const struct timespec *abstime, int private)
{
struct timespec rt;
/* Reject invalid timeouts. */
if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
return EINVAL;
/* Upgrade the lock. */
if (atomic_exchange_acq (futex, 2) == 0)
return 0;
do
{
struct timeval tv;
/* Get the current time. */
(void) __gettimeofday (&tv, NULL);
/* Compute relative timeout. */
rt.tv_sec = abstime->tv_sec - tv.tv_sec;
rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
if (rt.tv_nsec < 0)
{
rt.tv_nsec += 1000000000;
--rt.tv_sec;
}
/* Already timed out? */
if (rt.tv_sec < 0)
return ETIMEDOUT;
// XYZ: Lost the lock to check whether it was private.
lll_futex_timed_wait (futex, 2, &rt, private);
}
while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
return 0;
}
int
__lll_timedwait_tid (long *tidp, const struct timespec *abstime)
{
long tid;
if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
return EINVAL;
/* Repeat until thread terminated. */
while ((tid = *tidp) != KTID_TERMINATED)
{
struct timeval tv;
struct timespec rt;
/* Get the current time. */
(void) __gettimeofday (&tv, NULL);
/* Compute relative timeout. */
rt.tv_sec = abstime->tv_sec - tv.tv_sec;
rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
if (rt.tv_nsec < 0)
{
rt.tv_nsec += 1000000000;
--rt.tv_sec;
}
/* Already timed out? */
if (rt.tv_sec < 0)
return ETIMEDOUT;
/* Wait until thread terminates. */
lll_umtx_long_wait_shared (tidp, tid, &rt);
}
return 0;
}
#endif

View File

@ -0,0 +1,168 @@
/* Copyright (C) 2002-2013 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, see
<http://www.gnu.org/licenses/>. */
#ifndef _LOWLEVELLOCK_H
#define _LOWLEVELLOCK_H 1
/* Values for 'private' parameter of locking macros. Yes, the
definition seems to be backwards. But it is not.
They are the same as linux one's
*/
#define FUTEX_PRIVATE_FLAG 128
#define LLL_PRIVATE 0
#define LLL_SHARED FUTEX_PRIVATE_FLAG
#define KTID_TERMINATED 1
#include <stap-probe.h>
#ifndef __ASSEMBLER__
#include <time.h>
#include <sys/param.h>
#include <bits/pthreadtypes.h>
#include <kernel-features.h>
#include <tcb-offsets.h>
#include <atomic.h>
#include <lowlevelumtx.h>
/* Initializer for lock. */
#define LLL_LOCK_INITIALIZER (0)
#define LLL_LOCK_INITIALIZER_LOCKED (1)
#define LLL_LOCK_INITIALIZER_WAITERS (2)
#define lll_futex_wait(futex, val, private) \
lll_futex_timed_wait(futex, val, NULL, private)
#define lll_futex_timed_wait(futex, val, timeout, private) \
({ \
int __status; \
if ((private) == LLL_PRIVATE) \
__status = lll_umtx_int_wait_private (futex, val, timeout); \
else \
__status = lll_umtx_int_wait_shared (futex, val, timeout); \
__status; \
})
#define lll_futex_wake(futex, nr, private) \
({ \
int __status; \
if ((private) == LLL_PRIVATE) \
__status = lll_umtx_int_wake_private (futex, nr); \
else \
__status = lll_umtx_int_wake_shared (futex, nr); \
__status; \
})
#define lll_trylock(lock) \
atomic_compare_and_exchange_val_acq(&(lock), 1, 0)
#define lll_cond_trylock(lock) \
atomic_compare_and_exchange_val_acq(&(lock), 2, 0)
extern void __lll_lock_wait_private (int *futex) attribute_hidden;
extern void __lll_lock_wait_shared (int *futex) attribute_hidden;
#define __lll_lock_wait(futex, private) \
((void) ({ \
if ((private) == LLL_PRIVATE) \
__lll_lock_wait_private (futex); \
else \
__lll_lock_wait_shared (futex); \
}))
#define __lll_lock(futex, private) \
((void) ({ \
int *__futex = (futex); \
if (__builtin_expect (atomic_compare_and_exchange_val_acq (__futex, \
1, 0), 0)) \
{ \
__lll_lock_wait (__futex, private); \
} \
}))
#define lll_lock(futex, private) __lll_lock (&(futex), private)
#define __lll_cond_lock(futex, private) \
((void) ({ \
int *__futex = (futex); \
if (__builtin_expect (atomic_exchange_acq (__futex, 2), 0)) \
__lll_lock_wait (__futex, private); \
}))
#define lll_cond_lock(futex, private) __lll_cond_lock (&(futex), private)
extern int __lll_timedlock_wait (int *futex, const struct timespec *,
int private) attribute_hidden;
#define __lll_timedlock(futex, abstime, private) \
({ \
int *__futex = (futex); \
int __val = 0; \
\
if (__builtin_expect (atomic_exchange_acq (__futex, 1), 0)) \
__val = __lll_timedlock_wait (__futex, abstime, private); \
__val; \
})
#define lll_timedlock(futex, abstime, private) \
__lll_timedlock (&(futex), abstime, private)
#define __lll_unlock(futex, private) \
(void) \
({ int *__futex = (futex); \
int __private = (private); \
int __oldval = atomic_exchange_rel (__futex, 0); \
if (__builtin_expect (__oldval > 1, 0)) \
lll_futex_wake (__futex, 1, __private); \
})
#define lll_unlock(futex, private) __lll_unlock(&(futex), private)
#define lll_islocked(futex) \
(futex != 0)
/* The kernel notifies a process which uses CLONE_CHILD_CLEARTID via futex
wakeup when the clone terminates. The memory location contains the
thread ID while the clone is running and is reset to one (not zero as on linux)
afterwards. */
#define lll_wait_tid(tid) \
do { \
__typeof (tid) __tid; \
while ((__tid = (tid)) != KTID_TERMINATED) \
lll_umtx_long_wait_shared (&(tid), __tid, NULL);\
} while (0)
extern int __lll_timedwait_tid (long *, const struct timespec *)
attribute_hidden;
#define lll_timedwait_tid(tid, abstime) \
({ \
int __res = 0; \
if ((tid) != KTID_TERMINATED) \
__res = __lll_timedwait_tid (&(tid), (abstime)); \
__res; \
})
#endif /* !__ASSEMBLER__ */
#endif /* lowlevellock.h */

View File

@ -0,0 +1,16 @@
#include <stddef.h>
#include <stdio.h>
#include <bits/pthreadtypes.h>
#include <bits/wordsize.h>
--
MUTEX offsetof (pthread_rwlock_t, __data.__lock)
NR_READERS offsetof (pthread_rwlock_t, __data.__nr_readers)
READERS_WAKEUP offsetof (pthread_rwlock_t, __data.__readers_wakeup)
WRITERS_WAKEUP offsetof (pthread_rwlock_t, __data.__writer_wakeup)
READERS_QUEUED offsetof (pthread_rwlock_t, __data.__nr_readers_queued)
WRITERS_QUEUED offsetof (pthread_rwlock_t, __data.__nr_writers_queued)
FLAGS offsetof (pthread_rwlock_t, __data.__flags)
WRITER offsetof (pthread_rwlock_t, __data.__writer)
PSHARED offsetof (pthread_rwlock_t, __data.__shared)

View File

@ -0,0 +1,27 @@
/* Copyright (C) 2002-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see
<http://www.gnu.org/licenses/>. */
#include <unistd.h>
pid_t
__fork (void)
{
return __libc_fork ();
}
strong_alias (__fork, fork)

View File

@ -0,0 +1 @@
#include <sysdeps/unix/bsd/bsd4.4/kfreebsd/fbtl/raise.c>

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