Commit Graph

6235 Commits

Author SHA1 Message Date
David Xu
41e160536a Return SEM_FAILED instead of NULL, though there are same, but the
SEM_FAILED is more suitable name.
In function, sem_close(), always set errno on error.
2010-01-13 08:53:23 +00:00
Christian Brueffer
a47698f8d6 Miscellaneous mdoc, spelling and inconsistency fixes.
PR:		142573, 142576 (mostly)
Submitted by:	brucec
MFC after:	1 week
2010-01-12 21:45:03 +00:00
David Xu
7bf27b2dde Update manuals of sem_open and sem_init.
Submitted by:	ru
2010-01-12 01:30:05 +00:00
Colin Percival
c6a96a8441 Give a less silly response to a silly request.
Prior to this commit, fread/fwrite calls with size * nmemb > SIZE_MAX
were handled by reading or writing (size_t)(size * nmemb) bytes; for
example, on 32-bit platforms, fread(ptr, 641, 6700417, f) would read 1
byte and indicate that the requested 6700417 blocks had been read.

This commit adds a check for such integer overflows, and treats them as
if an overly large request was passed to read/write; i.e., it sets errno
to EINVAL, sets the error indicator on the file, and returns a short
object count (0, to be specific).

The overflow check involves an integer division, so as a performance
optimization we check first to see if both size and nmemb are less than
2^16; if they are, no overflow is possible and we avoid the division.
We assume here that size_t is at least 32 bits; this appears to be true
on all platforms FreeBSD supports.

Although this commit fixes an integer overflow, it is not likely to have
any security implications, since any program which would be affected by
this bug fix is quite clearly already very confused.

Reviewed by:	kib
MFC after:	1 month
2010-01-10 14:30:30 +00:00
Brooks Davis
9d8e1a8300 Use the correct types to store uids and gids in the credential cache. 2010-01-09 23:36:51 +00:00
Xin LI
777f8cebf3 Add a set of manual pages for pthread[_attr]_[sg]etaffinity(3).
Reviewed by:	davidxu
MFC after:	2 weeks
2010-01-09 12:31:11 +00:00
David Xu
a455039e3a Update manual for sem_init and sem_open, restrictions of shared semaphore
and 14 characters in name length no longer exist.

Reviewed by:	deischen@
2010-01-09 05:40:46 +00:00
Warner Losh
52e0ea7a0d Merge r195030 from project/mips to head by hand
r195030 | gonzo | 2009-06-25 19:27:31 -0600 (Thu, 25 Jun 2009) | 4 lines
- Switch to libc softfloat from libgcc implementation. The problem
    with latter is that it is not complete, fpsetXXX/fpgetXXX
    functions are missing.
2010-01-09 00:01:35 +00:00
Warner Losh
87e925fb53 Merge r197800 from projects/mips to head by hand:
r197800 | gonzo | 2009-10-06 00:35:52 -0600 (Tue, 06 Oct 2009) | 3 lines
- curbrk variable for sbrk and brk should be the same
- Add correct variable names to Symbol.map
2010-01-08 23:59:04 +00:00
Warner Losh
9cd8780a69 Merge r195025 from projects/mips to head by hand:
r195025 | gonzo | 2009-06-25 19:01:50 -0600 (Thu, 25 Jun 2009) | 4 lines
- Move fpgetXXX.c/fpsetXXX.c sources to hardfloat subdir/
    to prevenmt them from being mixed up with lib/libc/softfloat
    files with the same names
2010-01-08 23:50:39 +00:00
Christian Brueffer
37dc3d28cb Remove unnecessary quoting and markup, add missing punctuation.
PR:		140494
Submitted by:	Jeremy Huddleston <jeremyhu@apple.com>, bde
MFC after:	1 week
2010-01-08 22:02:42 +00:00
Konstantin Belousov
4319da1319 Further fix grammar.
Suggested by:	alc
MFC after:	3 days
2010-01-07 21:14:46 +00:00
Christian Brueffer
44640a5251 Fix a typo and bump date for the previous commit. 2010-01-07 21:08:22 +00:00
Edward Tomasz Napierala
10302b1ade Remove BUGS section that no longer applies after recent changes to semaphore
code.

OK-ed by:	davidxu
2010-01-07 16:52:00 +00:00
Konstantin Belousov
0b56296772 Give some information on SF_MNOWAIT flag.
MFC after:	3 days
2010-01-07 13:31:00 +00:00
David Xu
323d80a0a7 Don't forget to use fourth argument if O_CREAT is set in argument oflag.
The fourth specifies initial value for the semaphore.
2010-01-07 04:15:49 +00:00
John Baldwin
8feb1ea45e Use _pthread_once() rather than _once() for localtime() and gmtime(). These
methods are only invoked when __isthreaded is true at which point it is safe
to use _pthread_once() directly.

MFC after:	1 week
2010-01-06 20:43:40 +00:00
Konstantin Belousov
f5636f881b Do not rely on behaviour undefined by ANSI C, use thunks to adapt
alphasort-like interface to the comparision function required by
qsort() and qsort_r().

For opendir() thunk and alphasort(), comment on why we deviated from
POSIX by using strcmp() instead of strcoll().

Requested and reviewed by:	bde
MFC after:	2 weeks
2010-01-05 20:20:31 +00:00
Christian Brueffer
7b331f63c5 Fix a double free().
PR:		142339
Submitted by:	Henning Petersen <henning.petersen@t-online.de>
MFC after:	2 weeks
2010-01-05 20:18:41 +00:00
David Xu
523a738f77 More cleanup, remove _libc prefix because libthr no longer has stubs
referencing them.
2010-01-05 06:40:27 +00:00
David Xu
3e18aa9869 forgot to remove SYM_FBP10. ;-) 2010-01-05 05:47:18 +00:00
David Xu
79aaab046d Remove unused macros. 2010-01-05 05:44:52 +00:00
David Xu
d802aa25d2 Don't check has_waiters twice, inline some small functions.
performance result on my machine:
	mutex     Elapsed: 902115 us; per iteration: 90 ns.
	semaphore Elapsed: 958780 us; per iteration: 95 ns.
2010-01-05 03:39:31 +00:00
David Xu
9b0f1823b5 Use umtx to implement process sharable semaphore, to make this work,
now type sema_t is a structure which can be put in a shared memory area,
and multiple processes can operate it concurrently.
User can either use mmap(MAP_SHARED) + sem_init(pshared=1) or use sem_open()
to initialize a shared semaphore.
Named semaphore uses file system and is located in /tmp directory, and its
file name is prefixed with 'SEMD', so now it is chroot or jail friendly.
In simplist cases, both for named and un-named semaphore, userland code
does not have to enter kernel to reduce/increase semaphore's count.
The semaphore is designed to be crash-safe, it means even if an application
is crashed in the middle of operating semaphore, the semaphore state is
still safely recovered by later use, there is no waiter counter maintained
by userland code.
The main semaphore code is in libc and libthr only has some necessary stubs,
this makes it possible that a non-threaded application can use semaphore
without linking to thread library.
Old semaphore implementation is kept libc to maintain binary compatibility.
The kernel ksem API is no longer used in the new implemenation.

Discussed on: threads@
2010-01-05 02:37:59 +00:00
Konstantin Belousov
4176dd5267 Modernize scandir(3) and alphasort(3) interfaces according to the IEEE
Std 1003.1-2008. Both Linux and Solaris conforms to the new definitions,
so we better follow too (older glibc used old BSDish alphasort prototype
and corresponding type of the comparision function for scandir). While
there, change the definitions of the functions to ANSI C and fix several
style issues nearby.

Remove requirement for "sys/types.h" include for functions from manpage.

POSIX also requires that alphasort(3) sorts as if strcoll(3) was used,
but leave the strcmp(3) call in the function for now.

Adapt in-tree callers of scandir(3) to new declaration. The fact that
select_sections() from catman(1) could modify supplied struct dirent is
a bug.

PR:	standards/142255
MFC after:	2 weeks
2010-01-04 15:40:17 +00:00
Ed Schouten
442aea92f6 Don't forget to clean up the file copied from the kernel sources.
MFC after:	1 week
2010-01-02 20:27:14 +00:00
Brooks Davis
a6fffd6cb0 The devices that supported EVFILT_NETDEV kqueue filters were removed in
r195175.  Remove all definitions, documentation, and usage.

fifo_misc.c:
	Remove all kqueue tests as fifo_io.c performs all those that
	would have remained.

Reviewed by:	rwatson
MFC after:	3 weeks
X-MFC note:	don't change vlan_link_state() function signature
2009-12-31 20:29:58 +00:00
John Baldwin
bac2c9636c Use _once() to initialize the pthread key for thread-local storage to hold
the results of gmtime() instead of using a pthread mutex directly.

MFC after:	1 week
2009-12-30 19:06:16 +00:00
Konstantin Belousov
d439b6c223 Document _FAST and _PRECISE clocks.
Submitted by:	Valentin Nechayev <netch segfault kiev ua>
MFC after:	3 days
2009-12-29 15:58:10 +00:00
Konstantin Belousov
5d2874abdd Document CLOCK_SECOND, add cross-reference from time(3) to clock_gettime(2).
Based on submission by:	pluknet gmail com
MFC after:	3 days
2009-12-29 14:29:08 +00:00
Konstantin Belousov
358ed16f75 Use clock_gettime(CLOCK_SECOND) instead of gettimeofday(2) for
implementation of time(3). CLOCK_SECOND is much faster.

No objections from:	phk
Submitted by:	Valentin Nechayev <netch segfault kiev ua>
MFC after:	1 week
2009-12-29 12:47:47 +00:00
Antoine Brodin
13e403fdea (S)LIST_HEAD_INITIALIZER takes a (S)LIST_HEAD as an argument.
Fix some wrong usages.
Note: this does not affect generated binaries as this argument is not used.

PR:		137213
Submitted by:	Eygene Ryabinkin (initial version)
MFC after:	1 month
2009-12-28 22:56:30 +00:00
Markus Brueffer
78da985f4e Use a local copy of entry_d for finding matches. Otherwise, if entry_d pointed
to an entry of 'acl', all ACL entries starting with entry_d would be deleted.

Reviewed by:	trasz
Approved by:	emax (mentor)
MFC after:	3 days
2009-12-25 18:05:06 +00:00
Edwin Groothuis
1993d7fb07 MFV of tzdata2009t, r200831
zic:
- Fix URL / reference to Calendrical Calculations: Third Edition

libc/stdtime:
- Fix typo in tzfile.5 (no changes in our part)

MFC after:	1 week
2009-12-22 11:17:10 +00:00
Xin LI
280101b76e Use vsprintf instead of rolling our own.
PR:		bin/140496
Submitted by:	Jeremy Huddleston <jeremyhu apple.com>
MFC after:	1 month
2009-12-21 19:59:38 +00:00
Xin LI
d22fecc5e6 Use vsscanf instead of rolling our own.
PR:		bin/140530
Submitted by:	Jeremy Huddleston <jeremyhu apple.com>
MFC after:	1 month
2009-12-21 19:56:03 +00:00
Xin LI
c19ee5a0fb K&R -> ANSI prototype.
MFC after:	1 month
2009-12-21 19:55:05 +00:00
John Baldwin
a3102e9870 Use _once() to initialize the pthread key for thread-local storage to hold
the results of localtime() instead of using a pthread mutex directly.

MFC after:	1 week
2009-12-21 19:43:23 +00:00
Matteo Riondato
5d26f10fbb 2009-12-16 04:19:23 +00:00
Jilles Tjoelker
d32b247049 cpuset(2): fix a typo and a markup error in the man page
MFC after:	1 week
2009-12-15 21:02:29 +00:00
Jason Evans
5f2b1ed91b Simplify arena_run_reg_dalloc(), and remove a bug that was due to incorrect
initialization of ssize_invs.
2009-12-10 02:51:40 +00:00
Jason Evans
2354bdcf94 Fix the posix_memalign() changes in r196861 to actually return a NULL pointer
as intended.

PR:		standards/138307
2009-12-10 00:16:11 +00:00
Jilles Tjoelker
461e296c49 sem_init(3): document process shared semaphores and their restrictions 2009-12-08 20:48:06 +00:00
Sean Farley
f959b43fd0 Revert behavior change to setenv(), unsetenv() and putenv() until a more
thorough security review has been completed.
2009-12-07 00:22:10 +00:00
Sean Farley
ef6ccfb52a Update the getenv(3) man page to reflect the recent change to the behavior
of setenv(), putenv() and unsetenv() when dealing with corrupt entries in
environ.  They now output a warning and complete their task without error.

MFC after:	1 week
2009-12-06 23:51:27 +00:00
Sean Farley
ca7520fe57 Change the behavior of setenv(), putenv() and unsetenv() to continue parsing
instead of returning an error if a corrupt (not a "name=value" string) entry
in the environ array is detected when (re)-building the internal
environment.  This should prevent applications or libraries from
experiencing issues arising from the expectation that these calls will
complete even with corrupt entries.  The behavior is now as it was prior to
7.0.

Reviewed by:	jilles
MFC after:	1 week
2009-12-06 23:27:24 +00:00
Sean Farley
6da7f71cd4 Improve the comment within getenv() explaining the search order it takes to
find a variable.  Include a note that it must not cause the internal
environment to be generated since malloc() depends upon getenv().  To call
malloc() would create a circular dependency.

Recommended by:	green
Approved by:	jilles
MFC after:	1 week
2009-12-06 23:05:17 +00:00
Ed Schouten
2c201a9afe Fix many "function declaration isn't a prototype" warnings in libc.
I've only fixed code that seems to be written by `us'. There are still
many warnings like this present in resolv/, rpc/, stdtime/ and yp/.
2009-12-05 19:31:38 +00:00
Ed Schouten
dc29acd1a9 Don't let the C library depend on <utmp.h>.
The maximum length of a username has nothing to do with the size of the
username in the utmp files. Use MAXLOGNAME, which is defined as 17
(UT_USERSIZE + 1).
2009-12-05 19:04:21 +00:00
Ed Schouten
bbbe3054ff Remove warnings from exec.c.
The entries in the argv array are not const themselves, but sometimes we
want to fill in const values. Just make the array const and use
__DECONST() to make it const for the execve()-call itself.

Also convert the only K&R prototype to ANSI.
2009-12-05 18:55:16 +00:00