* [PATCH] save errno around ugetrlimit
@ 2000-01-17 1:45 Jakub Jelinek
2000-01-17 4:04 ` Andreas Schwab
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2000-01-17 1:45 UTC (permalink / raw)
To: libc-hacker
Hi!
I think we should save errno around ugetrlimit calls if we are not sure it
exists.
2000-01-17 Jakub Jelinek <jakub@redhat.com>
* sysdeps/unix/sysv/linux/i386/setrlimit.c (__new_setrlimit): Save
errno if testing whether ugetrlimit exists.
* sysdeps/unix/sysv/linux/i386/getrlimit.c (__new_getrlimit): Likewise.
--- libc/sysdeps/unix/sysv/linux/i386/setrlimit.c.jj Sun Dec 19 00:42:59 1999
+++ libc/sysdeps/unix/sysv/linux/i386/setrlimit.c Mon Jan 17 10:32:54 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -50,13 +50,17 @@ __new_setrlimit (enum __rlimit_resource
/* Check if the new ugetrlimit syscall exists. We must do this
first because older kernels don't reject negative rlimit
values in setrlimit. */
- int result = INLINE_SYSCALL (ugetrlimit, 2, resource, &rlimits_small);
+ int saved_errno = errno, result;
+
+ result = INLINE_SYSCALL (ugetrlimit, 2, resource, &rlimits_small);
if (result != -1 || errno != ENOSYS)
/* The syscall exists. */
__have_no_new_getrlimit = -1;
else
/* The syscall does not exist. */
__have_no_new_getrlimit = 1;
+
+ __set_errno (saved_errno);
}
if (__have_no_new_getrlimit < 0)
return INLINE_SYSCALL (setrlimit, 2, resource, rlimits);
--- libc/sysdeps/unix/sysv/linux/i386/getrlimit.c.jj Sat Dec 18 20:41:48 1999
+++ libc/sysdeps/unix/sysv/linux/i386/getrlimit.c Mon Jan 17 10:35:29 2000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 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
@@ -45,6 +45,7 @@ __new_getrlimit (enum __rlimit_resource
# ifdef __NR_ugetrlimit
if (__have_no_new_getrlimit <= 0)
{
+ int saved_errno = errno;
result = INLINE_SYSCALL (ugetrlimit, 2, resource, rlimits);
/* If the system call is available remember this fact and return. */
@@ -56,6 +57,7 @@ __new_getrlimit (enum __rlimit_resource
/* Remember that the system call is not available. */
__have_no_new_getrlimit = 1;
+ __set_errno (saved_errno);
}
# endif
Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jakub@redhat.com | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.39 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] save errno around ugetrlimit
2000-01-17 1:45 [PATCH] save errno around ugetrlimit Jakub Jelinek
@ 2000-01-17 4:04 ` Andreas Schwab
0 siblings, 0 replies; 2+ messages in thread
From: Andreas Schwab @ 2000-01-17 4:04 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: libc-hacker
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 434 bytes --]
Jakub Jelinek <jakub@redhat.com> writes:
|> Hi!
|>
|> I think we should save errno around ugetrlimit calls if we are not sure it
|> exists.
I don't think so, a sucessfull syscall may modify errno anyway.
Andreas.
--
Andreas Schwab "And now for something
SuSE Labs completely different."
schwab@suse.de
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-01-17 4:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-17 1:45 [PATCH] save errno around ugetrlimit Jakub Jelinek
2000-01-17 4:04 ` Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).