* libc/sys/linux/sys/cdefs.h: Add __weak_reference macros.

* libc/sys/linux/sys/time.h: Add conversion macros.
	* libc/sys/linux/sys/types.h: Add FD_ macros.  Include <bits/types.h>.
	* libc/sys/linux/ids.c: Add setresuid and syslog syscalls.
	* libc/sys/linux/gethostname.c: New file.
	* libc/sys/linux/seteuid.c: New file.
	* libc/sys/linux/sysctl.c: New file.
This commit is contained in:
Thomas Fitzsimmons 2002-05-24 18:50:29 +00:00
parent 908f9b653b
commit 9a29238544
12 changed files with 351 additions and 23 deletions

View File

@ -1,3 +1,13 @@
2002-05-24 Thomas Fitzsimmons <fitzsim@redhat.com>
* libc/sys/linux/sys/cdefs.h: Add __weak_reference macros.
* libc/sys/linux/sys/time.h: Add conversion macros.
* libc/sys/linux/sys/types.h: Add FD_ macros. Include <bits/types.h>.
* libc/sys/linux/ids.c: Add setresuid and syslog syscalls.
* libc/sys/linux/gethostname.c: New file.
* libc/sys/linux/seteuid.c: New file.
* libc/sys/linux/sysctl.c: New file.
2002-05-23 Jeff Johnston <jjohnstn@redhat.com>
* libc/string/Makefile.am: Add support for strsep.c.

View File

@ -6,15 +6,16 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
SUBDIRS = machine \
.
SUBLIBS = $(LINUX_MACH_LIB)
SUBLIBS = \
$(LINUX_MACH_LIB)
LIB_SOURCES = \
brk.c flockfile.c funlockfile.c getoptlong.c getreent.c ids.c \
brk.c flockfile.c funlockfile.c gethostname.c getoptlong.c getreent.c ids.c \
inode.c io.c io64.c linux.c mmap.c \
pread.c pread64.c process.c pwrite.c pwrite64.c raise.c realpath.c \
resource.c sched.c select.c shm_open.c shm_unlink.c signal.c \
resource.c sched.c select.c shm_open.c shm_unlink.c seteuid.c signal.c \
siglongjmp.c socket.c sleep.c stack.c \
sysconf.c systat.c system.c tcdrain.c termios.c time.c \
sysconf.c sysctl.c systat.c system.c tcdrain.c termios.c time.c \
usleep.c wait.c
# This will handle both /usr/src/linux-2.4/include/asm/signal.h (in Red Hat Linux 7.1)

View File

@ -96,15 +96,17 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
SUBDIRS = machine \
.
SUBLIBS = $(LINUX_MACH_LIB)
SUBLIBS = \
$(LINUX_MACH_LIB)
LIB_SOURCES = \
brk.c flockfile.c funlockfile.c getoptlong.c getreent.c ids.c \
brk.c flockfile.c funlockfile.c gethostname.c getoptlong.c getreent.c ids.c \
inode.c io.c io64.c linux.c mmap.c \
pread.c pread64.c process.c pwrite.c pwrite64.c raise.c realpath.c \
resource.c sched.c select.c shm_open.c shm_unlink.c signal.c \
resource.c sched.c select.c shm_open.c shm_unlink.c seteuid.c signal.c \
siglongjmp.c socket.c sleep.c stack.c \
sysconf.c systat.c system.c tcdrain.c termios.c time.c \
sysconf.c sysctl.c systat.c system.c tcdrain.c termios.c time.c \
usleep.c wait.c
@ -136,25 +138,25 @@ DEFS = @DEFS@ -I. -I$(srcdir)
CPPFLAGS = @CPPFLAGS@
LIBS = @LIBS@
@USE_LIBTOOL_FALSE@lib_a_OBJECTS = brk.o flockfile.o funlockfile.o \
@USE_LIBTOOL_FALSE@getoptlong.o getreent.o ids.o inode.o io.o io64.o \
@USE_LIBTOOL_FALSE@linux.o mmap.o pread.o pread64.o process.o pwrite.o \
@USE_LIBTOOL_FALSE@pwrite64.o raise.o realpath.o resource.o sched.o \
@USE_LIBTOOL_FALSE@select.o shm_open.o shm_unlink.o signal.o \
@USE_LIBTOOL_FALSE@siglongjmp.o socket.o sleep.o stack.o sysconf.o \
@USE_LIBTOOL_FALSE@systat.o system.o tcdrain.o termios.o time.o \
@USE_LIBTOOL_FALSE@usleep.o wait.o
@USE_LIBTOOL_FALSE@gethostname.o getoptlong.o getreent.o ids.o inode.o \
@USE_LIBTOOL_FALSE@io.o io64.o linux.o mmap.o pread.o pread64.o \
@USE_LIBTOOL_FALSE@process.o pwrite.o pwrite64.o raise.o realpath.o \
@USE_LIBTOOL_FALSE@resource.o sched.o select.o shm_open.o shm_unlink.o \
@USE_LIBTOOL_FALSE@seteuid.o signal.o siglongjmp.o socket.o sleep.o \
@USE_LIBTOOL_FALSE@stack.o sysconf.o sysctl.o systat.o system.o \
@USE_LIBTOOL_FALSE@tcdrain.o termios.o time.o usleep.o wait.o
LTLIBRARIES = $(noinst_LTLIBRARIES)
@USE_LIBTOOL_TRUE@liblinux_la_DEPENDENCIES =
@USE_LIBTOOL_TRUE@liblinux_la_OBJECTS = brk.lo flockfile.lo \
@USE_LIBTOOL_TRUE@funlockfile.lo getoptlong.lo getreent.lo ids.lo \
@USE_LIBTOOL_TRUE@inode.lo io.lo io64.lo linux.lo mmap.lo pread.lo \
@USE_LIBTOOL_TRUE@pread64.lo process.lo pwrite.lo pwrite64.lo raise.lo \
@USE_LIBTOOL_TRUE@realpath.lo resource.lo sched.lo select.lo \
@USE_LIBTOOL_TRUE@shm_open.lo shm_unlink.lo signal.lo siglongjmp.lo \
@USE_LIBTOOL_TRUE@socket.lo sleep.lo stack.lo sysconf.lo systat.lo \
@USE_LIBTOOL_TRUE@system.lo tcdrain.lo termios.lo time.lo usleep.lo \
@USE_LIBTOOL_TRUE@wait.lo
@USE_LIBTOOL_TRUE@funlockfile.lo gethostname.lo getoptlong.lo \
@USE_LIBTOOL_TRUE@getreent.lo ids.lo inode.lo io.lo io64.lo linux.lo \
@USE_LIBTOOL_TRUE@mmap.lo pread.lo pread64.lo process.lo pwrite.lo \
@USE_LIBTOOL_TRUE@pwrite64.lo raise.lo realpath.lo resource.lo sched.lo \
@USE_LIBTOOL_TRUE@select.lo shm_open.lo shm_unlink.lo seteuid.lo \
@USE_LIBTOOL_TRUE@signal.lo siglongjmp.lo socket.lo sleep.lo stack.lo \
@USE_LIBTOOL_TRUE@sysconf.lo sysctl.lo systat.lo system.lo tcdrain.lo \
@USE_LIBTOOL_TRUE@termios.lo time.lo usleep.lo wait.lo
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)

View File

@ -2369,6 +2369,7 @@ if test -n "${machine_dir}"; then
fi
subdirs="machine $EXTRA_DIRS"

View File

@ -29,6 +29,7 @@ if test -n "${machine_dir}"; then
fi
AC_SUBST(LINUX_MACH_LIB)
AC_CONFIG_SUBDIRS(machine $EXTRA_DIRS)
AC_OUTPUT(Makefile)

View File

@ -0,0 +1,30 @@
/* Copyright 2002, Red Hat Inc. */
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/utsname.h>
int
gethostname (char *name, size_t len)
{
struct utsname nodebuf;
size_t nodelen;
if (uname (&nodebuf))
return -1;
nodelen = strlen (nodebuf.nodename) + 1;
if (len < nodelen)
memcpy (name, nodebuf.nodename, len);
else
memcpy (name, nodebuf.nodename, nodelen);
if (nodelen > len)
{
errno = ENAMETOOLONG;
return -1;
}
return 0;
}

View File

@ -16,4 +16,6 @@ _syscall1(int,setfsgid,gid_t,gid)
_syscall0(gid_t,getgid)
_syscall0(uid_t,geteuid)
_syscall0(gid_t,getegid)
_syscall3(int,setresuid,uid_t,ruid,uid_t,euid,uid_t,suid)
_syscall2(int,getgroups,int,size,gid_t *,list)
_syscall3(int,syslog,int,type,char *,bufp,int,len)

View File

@ -0,0 +1,18 @@
/* Copyright 2002, Red Hat Inc. */
#include <errno.h>
#include <unistd.h>
int
seteuid (uid_t uid)
{
int result;
if (uid == (uid_t) ~0)
{
errno = (EINVAL);
return -1;
}
return setresuid (-1, uid, -1);
}

View File

@ -2,6 +2,44 @@
/* Written 2000 by Werner Almesberger */
/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Berkeley Software Design, 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 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.
*
* @(#)cdefs.h 8.8 (Berkeley) 1/9/95
* $FreeBSD: src/sys/sys/cdefs.h,v 1.54 2002/05/11 03:58:24 alfred Exp $
*/
#ifndef _SYS_CDEFS_H
#define _SYS_CDEFS_H
@ -41,4 +79,44 @@
# define __ptrvalue /* nothing */
#endif
#ifdef __GNUC__
#define __strong_reference(sym,aliassym) \
extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
#ifdef __ELF__
#ifdef __STDC__
#define __weak_reference(sym,alias) \
__asm__(".weak " #alias); \
__asm__(".equ " #alias ", " #sym)
#define __warn_references(sym,msg) \
__asm__(".section .gnu.warning." #sym); \
__asm__(".asciz \"" msg "\""); \
__asm__(".previous")
#else
#define __weak_reference(sym,alias) \
__asm__(".weak alias"); \
__asm__(".equ alias, sym")
#define __warn_references(sym,msg) \
__asm__(".section .gnu.warning.sym"); \
__asm__(".asciz \"msg\""); \
__asm__(".previous")
#endif /* __STDC__ */
#else /* !__ELF__ */
#ifdef __STDC__
#define __weak_reference(sym,alias) \
__asm__(".stabs \"_" #alias "\",11,0,0,0"); \
__asm__(".stabs \"_" #sym "\",1,0,0,0")
#define __warn_references(sym,msg) \
__asm__(".stabs \"" msg "\",30,0,0,0"); \
__asm__(".stabs \"_" #sym "\",1,0,0,0")
#else
#define __weak_reference(sym,alias) \
__asm__(".stabs \"_/**/alias\",11,0,0,0"); \
__asm__(".stabs \"_/**/sym\",1,0,0,0")
#define __warn_references(sym,msg) \
__asm__(".stabs msg,30,0,0,0"); \
__asm__(".stabs \"_/**/sym\",1,0,0,0")
#endif /* __STDC__ */
#endif /* __ELF__ */
#endif /* __GNUC__ */
#endif /* _SYS_CDEFS_H */

View File

@ -2,6 +2,41 @@
/* Written 2000 by Werner Almesberger */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 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.
*
* @(#)time.h 8.5 (Berkeley) 5/4/95
* $FreeBSD: src/sys/sys/time.h,v 1.56 2002/05/05 04:33:09 bde Exp $
*/
#ifndef _SYS_TIME_H
#define _SYS_TIME_H
@ -9,6 +44,43 @@
#include <sys/types.h>
#include <linux/time.h>
/* Macros for converting between `struct timeval' and `struct timespec'. */
# define TIMEVAL_TO_TIMESPEC(tv, ts) { \
(ts)->tv_sec = (tv)->tv_sec; \
(ts)->tv_nsec = (tv)->tv_usec * 1000; \
}
# define TIMESPEC_TO_TIMEVAL(tv, ts) { \
(tv)->tv_sec = (ts)->tv_sec; \
(tv)->tv_usec = (ts)->tv_nsec / 1000; \
}
/* Convenience macros for operations on timevals.
NOTE: `timercmp' does not work for >= or <=. */
# define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
# define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
# define timercmp(a, b, CMP) \
(((a)->tv_sec == (b)->tv_sec) ? \
((a)->tv_usec CMP (b)->tv_usec) : \
((a)->tv_sec CMP (b)->tv_sec))
# define timeradd(a, b, result) \
do { \
(result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
if ((result)->tv_usec >= 1000000) \
{ \
++(result)->tv_sec; \
(result)->tv_usec -= 1000000; \
} \
} while (0)
# define timersub(a, b, result) \
do { \
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
if ((result)->tv_usec < 0) { \
--(result)->tv_sec; \
(result)->tv_usec += 1000000; \
} \
} while (0)
/* --- redundant stuff below --- */
#include <_ansi.h>

View File

@ -2,6 +2,46 @@
/* Written 2000 by Werner Almesberger */
/*-
* Copyright (c) 1982, 1986, 1991, 1993, 1994
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 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.
*
* @(#)types.h 8.6 (Berkeley) 2/19/95
* $FreeBSD: src/sys/sys/types.h,v 1.60 2002/04/10 15:58:13 mike Exp $
*/
#ifndef _SYS_TYPES_H
#define _SYS_TYPES_H
@ -77,7 +117,38 @@ struct timespec {
};
#endif /* !_STRUCT_TIMESPEC */
# define _SYS_TYPES_FD_SET
# define NBBY 8 /* number of bits in a byte */
/*
* Select uses bit masks of file descriptors in longs.
* These macros manipulate such bit fields (the filesystem macros use chars).
* FD_SETSIZE may be defined by the user, but the default here
* should be >= NOFILE (param.h).
*/
# ifndef FD_SETSIZE
# define FD_SETSIZE 64
# endif
typedef long fd_mask;
# define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
# ifndef howmany
# define howmany(x,y) (((x)+((y)-1))/(y))
# endif
#define fd_set _types_fd_set
# define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
# define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
# define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
# define FD_ZERO(p) (__extension__ (void)({ \
size_t __i; \
char *__tmp = (char *)p; \
for (__i = 0; __i < sizeof (*(p)); ++__i) \
*__tmp++ = 0; \
}))
#include <linux/types.h>
#include <bits/types.h>
#define __mode_t_defined
#endif

View File

@ -0,0 +1,42 @@
/* Read or write system information. Linux version.
Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <errno.h>
#include <sys/sysctl.h>
#include <machine/syscall.h>
static _syscall1(int,_sysctl,struct __sysctl_args *,args)
int
__sysctl (int *name, int nlen, void *oldval, size_t *oldlenp,
void *newval, size_t newlen)
{
struct __sysctl_args args =
{
name: name,
nlen: nlen,
oldval: oldval,
oldlenp: oldlenp,
newval: newval,
newlen: newlen
};
return _sysctl(&args);
}