diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 3c0069d66..68c311eb4 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,16 @@ +2002-07-19 Jeff Johnston + + * libc/include/sys/config.h[__i386__][__linux__]: Define + _LARGE64FILE_SOURCE to 1. + * libc/sys/linux/Makefile.am: Add getrlimit64.c and setrlimit64.c. + * libc/sys/linux/Makefile.in: Regenerated. + * libc/sys/linux/resource.c: Add __getrlimit and __setrlimit aliases. + * libc/sys/linux/sys/linux_time.h: Protect struct timeval definition. + * libc/sys/linux/sys/resource.h: Include instead + of . + * libc/sys/linux/getrlimit64.c: New file. + * libc/sys/linux/setrlimit64.c: Ditto. + 2002-07-19 Thomas Fitzsimmons * libc/argz/argz_replace.c: Include buf_findstr.h. diff --git a/newlib/libc/include/sys/config.h b/newlib/libc/include/sys/config.h index e49238d3a..883993ffb 100644 --- a/newlib/libc/include/sys/config.h +++ b/newlib/libc/include/sys/config.h @@ -49,6 +49,8 @@ #define _HAVE_SYSTYPES #define _READ_WRITE_RETURN_TYPE _ssize_t #define __LARGE64_FILES 1 +/* we use some glibc header files so turn on glibc large file feature */ +#define _LARGEFILE64_SOURCE 1 #endif #endif diff --git a/newlib/libc/sys/linux/Makefile.am b/newlib/libc/sys/linux/Makefile.am index 6221d273b..7c162b7a5 100644 --- a/newlib/libc/sys/linux/Makefile.am +++ b/newlib/libc/sys/linux/Makefile.am @@ -29,6 +29,7 @@ LIB_SOURCES = \ gethostname.c \ getoptlong.c \ getreent.c \ + getrlimit64.c \ ids.c \ inode.c \ io.c \ @@ -73,6 +74,7 @@ LIB_SOURCES = \ select.c \ seteuid.c \ sethostname.c \ + setrlimit64.c \ shm_open.c \ shm_unlink.c \ sig.c \ diff --git a/newlib/libc/sys/linux/Makefile.in b/newlib/libc/sys/linux/Makefile.in index bea564e8a..5260ff068 100644 --- a/newlib/libc/sys/linux/Makefile.in +++ b/newlib/libc/sys/linux/Makefile.in @@ -126,6 +126,7 @@ LIB_SOURCES = \ gethostname.c \ getoptlong.c \ getreent.c \ + getrlimit64.c \ ids.c \ inode.c \ io.c \ @@ -170,6 +171,7 @@ LIB_SOURCES = \ select.c \ seteuid.c \ sethostname.c \ + setrlimit64.c \ shm_open.c \ shm_unlink.c \ sig.c \ @@ -242,9 +244,10 @@ LIBS = @LIBS@ @USE_LIBTOOL_FALSE@ftok.$(OBJEXT) funlockfile.$(OBJEXT) \ @USE_LIBTOOL_FALSE@getdate.$(OBJEXT) getdate_err.$(OBJEXT) \ @USE_LIBTOOL_FALSE@gethostname.$(OBJEXT) getoptlong.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@getreent.$(OBJEXT) ids.$(OBJEXT) inode.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@io.$(OBJEXT) io64.$(OBJEXT) ipc.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@linux.$(OBJEXT) malign.$(OBJEXT) malignr.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@getreent.$(OBJEXT) getrlimit64.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@ids.$(OBJEXT) inode.$(OBJEXT) io.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@io64.$(OBJEXT) ipc.$(OBJEXT) linux.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@malign.$(OBJEXT) malignr.$(OBJEXT) \ @USE_LIBTOOL_FALSE@mallinfor.$(OBJEXT) mallocr.$(OBJEXT) \ @USE_LIBTOOL_FALSE@malloptr.$(OBJEXT) mallstatsr.$(OBJEXT) \ @USE_LIBTOOL_FALSE@mmap.$(OBJEXT) mq_close.$(OBJEXT) \ @@ -261,8 +264,9 @@ LIBS = @LIBS@ @USE_LIBTOOL_FALSE@realpath.$(OBJEXT) rename.$(OBJEXT) \ @USE_LIBTOOL_FALSE@resource.$(OBJEXT) sched.$(OBJEXT) select.$(OBJEXT) \ @USE_LIBTOOL_FALSE@seteuid.$(OBJEXT) sethostname.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@shm_open.$(OBJEXT) shm_unlink.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@sig.$(OBJEXT) sigaction.$(OBJEXT) sigqueue.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@setrlimit64.$(OBJEXT) shm_open.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@shm_unlink.$(OBJEXT) sig.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@sigaction.$(OBJEXT) sigqueue.$(OBJEXT) \ @USE_LIBTOOL_FALSE@signal.$(OBJEXT) siglongjmp.$(OBJEXT) \ @USE_LIBTOOL_FALSE@sigset.$(OBJEXT) sigwait.$(OBJEXT) socket.$(OBJEXT) \ @USE_LIBTOOL_FALSE@sleep.$(OBJEXT) stack.$(OBJEXT) strsignal.$(OBJEXT) \ @@ -278,21 +282,23 @@ LTLIBRARIES = $(noinst_LTLIBRARIES) @USE_LIBTOOL_TRUE@clock_gettime.lo clock_settime.lo flockfile.lo \ @USE_LIBTOOL_TRUE@free.lo freer.lo ftok.lo funlockfile.lo getdate.lo \ @USE_LIBTOOL_TRUE@getdate_err.lo gethostname.lo getoptlong.lo \ -@USE_LIBTOOL_TRUE@getreent.lo ids.lo inode.lo io.lo io64.lo ipc.lo \ -@USE_LIBTOOL_TRUE@linux.lo malign.lo malignr.lo mallinfor.lo mallocr.lo \ -@USE_LIBTOOL_TRUE@malloptr.lo mallstatsr.lo mmap.lo mq_close.lo \ -@USE_LIBTOOL_TRUE@mq_getattr.lo mq_notify.lo mq_open.lo mq_receive.lo \ -@USE_LIBTOOL_TRUE@mq_send.lo mq_setattr.lo mq_unlink.lo msize.lo \ -@USE_LIBTOOL_TRUE@msizer.lo mstats.lo mtrim.lo mtrimr.lo ntp_gettime.lo \ -@USE_LIBTOOL_TRUE@pread.lo pread64.lo process.lo psignal.lo pvallocr.lo \ -@USE_LIBTOOL_TRUE@pwrite.lo pwrite64.lo raise.lo realloc.lo reallocr.lo \ +@USE_LIBTOOL_TRUE@getreent.lo getrlimit64.lo ids.lo inode.lo io.lo \ +@USE_LIBTOOL_TRUE@io64.lo ipc.lo linux.lo malign.lo malignr.lo \ +@USE_LIBTOOL_TRUE@mallinfor.lo mallocr.lo malloptr.lo mallstatsr.lo \ +@USE_LIBTOOL_TRUE@mmap.lo mq_close.lo mq_getattr.lo mq_notify.lo \ +@USE_LIBTOOL_TRUE@mq_open.lo mq_receive.lo mq_send.lo mq_setattr.lo \ +@USE_LIBTOOL_TRUE@mq_unlink.lo msize.lo msizer.lo mstats.lo mtrim.lo \ +@USE_LIBTOOL_TRUE@mtrimr.lo ntp_gettime.lo pread.lo pread64.lo \ +@USE_LIBTOOL_TRUE@process.lo psignal.lo pvallocr.lo pwrite.lo \ +@USE_LIBTOOL_TRUE@pwrite64.lo raise.lo realloc.lo reallocr.lo \ @USE_LIBTOOL_TRUE@realpath.lo rename.lo resource.lo sched.lo select.lo \ -@USE_LIBTOOL_TRUE@seteuid.lo sethostname.lo shm_open.lo shm_unlink.lo \ -@USE_LIBTOOL_TRUE@sig.lo sigaction.lo sigqueue.lo signal.lo \ -@USE_LIBTOOL_TRUE@siglongjmp.lo sigset.lo sigwait.lo socket.lo sleep.lo \ -@USE_LIBTOOL_TRUE@stack.lo strsignal.lo sysconf.lo sysctl.lo systat.lo \ -@USE_LIBTOOL_TRUE@system.lo tcdrain.lo tcsendbrk.lo termios.lo time.lo \ -@USE_LIBTOOL_TRUE@usleep.lo utimes.lo vallocr.lo wait.lo +@USE_LIBTOOL_TRUE@seteuid.lo sethostname.lo setrlimit64.lo shm_open.lo \ +@USE_LIBTOOL_TRUE@shm_unlink.lo sig.lo sigaction.lo sigqueue.lo \ +@USE_LIBTOOL_TRUE@signal.lo siglongjmp.lo sigset.lo sigwait.lo \ +@USE_LIBTOOL_TRUE@socket.lo sleep.lo stack.lo strsignal.lo sysconf.lo \ +@USE_LIBTOOL_TRUE@sysctl.lo systat.lo system.lo tcdrain.lo tcsendbrk.lo \ +@USE_LIBTOOL_TRUE@termios.lo time.lo usleep.lo utimes.lo vallocr.lo \ +@USE_LIBTOOL_TRUE@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) diff --git a/newlib/libc/sys/linux/getrlimit64.c b/newlib/libc/sys/linux/getrlimit64.c new file mode 100644 index 000000000..dcd67cf56 --- /dev/null +++ b/newlib/libc/sys/linux/getrlimit64.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1991, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +/* Put the soft and hard limits for RESOURCE in *RLIMITS. + Returns 0 if successful, -1 if not (and sets errno). */ +int +getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits) +{ + struct rlimit rlimits32; + + if (__getrlimit (resource, &rlimits32) < 0) + return -1; + + if (rlimits32.rlim_cur == RLIM_INFINITY) + rlimits->rlim_cur = RLIM64_INFINITY; + else + rlimits->rlim_cur = rlimits32.rlim_cur; + if (rlimits32.rlim_max == RLIM_INFINITY) + rlimits->rlim_max = RLIM64_INFINITY; + else + rlimits->rlim_max = rlimits32.rlim_max; + + return 0; +} diff --git a/newlib/libc/sys/linux/resource.c b/newlib/libc/sys/linux/resource.c index 4a80bbfce..66f9c0578 100644 --- a/newlib/libc/sys/linux/resource.c +++ b/newlib/libc/sys/linux/resource.c @@ -8,3 +8,6 @@ _syscall2(int,getrusage,int,who,struct rusage *,r_usage) _syscall2(int,getrlimit,int,resource,struct rlimit *,rlp) _syscall2(int,setrlimit,int,resource,const struct rlimit *,rlp) + +weak_alias(__libc_getrlimit,__getrlimit) +weak_alias(__libc_setrlimit,__setrlimit) diff --git a/newlib/libc/sys/linux/setrlimit64.c b/newlib/libc/sys/linux/setrlimit64.c new file mode 100644 index 000000000..d4b4bfce0 --- /dev/null +++ b/newlib/libc/sys/linux/setrlimit64.c @@ -0,0 +1,43 @@ +/* Copyright (C) 1991,1995,1996,1997,1998,2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + +/* Set the soft and hard limits for RESOURCE to *RLIMITS. + Only the super-user can increase hard limits. + Return 0 if successful, -1 if not (and sets errno). */ +int +setrlimit64 (resource, rlimits) + enum __rlimit_resource resource; + const struct rlimit64 *rlimits; +{ + struct rlimit rlimits32; + + if (rlimits->rlim_cur >= RLIM_INFINITY) + rlimits32.rlim_cur = RLIM_INFINITY; + else + rlimits32.rlim_cur = rlimits->rlim_cur; + if (rlimits->rlim_max >= RLIM_INFINITY) + rlimits32.rlim_max = RLIM_INFINITY; + else + rlimits32.rlim_max = rlimits->rlim_max; + + return __setrlimit (resource, &rlimits32); +} diff --git a/newlib/libc/sys/linux/sys/linux_time.h b/newlib/libc/sys/linux/sys/linux_time.h index 9328aec58..e71f70bba 100644 --- a/newlib/libc/sys/linux/sys/linux_time.h +++ b/newlib/libc/sys/linux/sys/linux_time.h @@ -46,10 +46,13 @@ jiffies_to_timespec(unsigned long jiffies, struct timespec *value) value->tv_sec = jiffies / HZ; } +#ifndef _STRUCT_TIMEVAL +#define _STRUCT_TIMEVAL struct timeval { time_t tv_sec; /* seconds */ suseconds_t tv_usec; /* microseconds */ }; +#endif struct timezone { int tz_minuteswest; /* minutes west of Greenwich */ diff --git a/newlib/libc/sys/linux/sys/resource.h b/newlib/libc/sys/linux/sys/resource.h index 660ec799c..f804731f9 100644 --- a/newlib/libc/sys/linux/sys/resource.h +++ b/newlib/libc/sys/linux/sys/resource.h @@ -7,6 +7,6 @@ #define _SYS_RESOURCE_H #include -#include +#include #endif