Commit Graph

56 Commits

Author SHA1 Message Date
Tim J. Robbins
8995b2315b Remove outdated comments. 2004-06-20 10:01:30 +00:00
Tim J. Robbins
84bb9aaa02 Bring back the macro versions of getwc(), getwchar(), putwc() and
putwchar(), but this time avoid redundantly declaring __stdinp and
__stdoutp when source files include both <stdio.h> and <wchar.h>.
2004-05-27 10:08:44 +00:00
Tim J. Robbins
257982eb0f Parenthesize function names in masking macros for getc() etc. for the
benefit of obsolete C preprocessors.
2004-03-20 11:45:52 +00:00
Tim J. Robbins
567d74a5ec Re-add macro versions of getc(), getchar(), putc(), putchar(), feof(),
ferror(), fileno() and clearerr(), using the value of __isthreaded to
decide between the fast inline single-threaded code and the more
general function equivalent. This gives most of the performance
benefits of the old unsafe macros while preserving thread safety.
2004-03-17 01:43:08 +00:00
Marcel Moolenaar
12eb46c8bb Change the definition of NULL on ia64 (for LP64 compilations) from
an int constant to a long constant. This change improves consistency
in the following two ways:
1. The first 8 arguments are always passed in registers on ia64, which
   by virtue of the generated code implicitly widens ints to longs and
   allows the use of an 32-bit integral type for 64-bit arguments.
   Subsequent arguments are passed onto the memory stack, which does
   not exhibit the same behaviour and consequently do not allow this.
   In practice this means that variadic functions taking pointers
   and given NULL (without cast) work as long as the NULL is passed
   in one of the first 8 arguments. A SIGSEGV is more likely the
   result if such would be done for stack-based arguments. This is
   due to the fact that the upper 4 bytes remain undefined.
2. All 64-bit platforms that FreeBSD supports, with the obvious
   exception of ia64, allow 32-bit integral types (specifically NULL)
   when 64-bit pointers are expected in variadic functions by way of
   how the compiler generates code. As such, code that works correctly
   (whether rightfully so or not) on any platform other than ia64, may
   fail on ia64.

To more easily allow tweaking of the definition of NULL, this commit
removes the 12 definitions in the various headers and puts it in a
new header that can be included whenever NULL is to be made visible.

This commit fixes GNOME, emacs, xemacs and a whole bunch of ports
that I don't particularly care about at this time...
2003-12-07 21:10:06 +00:00
Tim J. Robbins
e8065dc491 Add prototypes for the non-standard _unlocked functions. 2003-01-13 08:41:47 +00:00
Tim J. Robbins
af1c9c0e4d Use a weak reference instead of a macro to make vfscanf an alias
for __vfscanf.
2002-10-14 11:18:21 +00:00
Mike Barcroft
54e4e385de Add restrict type-qualifier. 2002-10-12 16:13:41 +00:00
Peter Wemm
74a4ba21f7 Zap the early-adopter transition aid before we get into serious
5.0-R territory, as threatened.  This only affects antique 5.0
systems that have not had a 'make world' done for well over a year.
2002-10-11 22:38:17 +00:00
Mike Barcroft
5dfca833cf o Move location of the fpos_t typedef to be closer to other typedefs.
o Add typedef for va_list.
o Add comment about missing restrict type-qualifiers.
o Move vscanf(), vsscanf() and vfscanf() to the C99-visible block.
o Add note about missing backing function for vfscanf().
o Restrict L_cuserid to only older versions of POSIX, and BSD
  namespaces.
o Conditionalize some BSD-specific foo_unlock() macros.
2002-10-06 22:16:12 +00:00
Tim J. Robbins
58d38e2520 Style: One space between "restrict" qualifier and "*". 2002-09-06 11:24:06 +00:00
Mike Barcroft
abbd890233 o Merge <machine/ansi.h> and <machine/types.h> into a new header
called <machine/_types.h>.
o <machine/ansi.h> will continue to live so it can define MD clock
  macros, which are only MD because of gratuitous differences between
  architectures.
o Change all headers to make use of this.  This mainly involves
  changing:
    #ifdef _BSD_FOO_T_
    typedef	_BSD_FOO_T_	foo_t;
    #undef _BSD_FOO_T_
    #endif
  to:
    #ifndef _FOO_T_DECLARED
    typedef	__foo_t	foo_t;
    #define	_FOO_T_DECLARED
    #endif

Concept by:	bde
Reviewed by:	jake, obrien
2002-08-21 16:20:02 +00:00
Robert Drehmel
f8418db73e - For compliance with IEEE Std 1003.1-2001, add the 'restrict'
qualifier to function prototypes and definitions where
   appropriate using the '__restrict' macro.
 - Update the manual page.
2002-08-15 10:28:52 +00:00
Robert Drehmel
71a00a449f - Introduce the 'restrict' qualifier to function prototypes and
definitions to comply with IEEE Std 1003.1-2001.
 - Update the manual pages.
2002-08-15 09:47:10 +00:00
Robert Drehmel
3248d0a517 - Add the 'restrict' qualifier to the function definitions and
public prototypes of setbuf(3) and setvbuf(3) using the
   '__restrict' macro from <sys/cdefs.h> to be compliant with
   IEEE Std 1003.1-2001.
 - Replace the K&R with ANSI-C function definitions.
 - Bring the manual page up-to-date.
2002-08-14 23:45:42 +00:00
Garrett Wollman
702b2a722b Clean up some of the rather strange structure and ordering of this
file.  Correct visibility conditions and order blocks of declarations
in order of increasing inclusiveness.  Note that [v]snprintf() is now
in ISO C and f{seek,tell}o() are now in POSIX.  Deprecated getw() and
putw() are no longer visible in XSH6 namespace (and should probably
be removed from BSD namespace as well).
2002-07-15 19:38:45 +00:00
Warner Losh
bb28f3c29b Breath deep and take __P out of the system include files.
# This appears to not break X11, but I'm having problems compiling the
# glide part of the server with or without this patch, so I can't tell
# for sure.
2002-03-23 17:24:55 +00:00
David E. O'Brien
3d7f57bc69 An extra #ifdef crept in with rev 1.38. 2001-12-05 04:16:33 +00:00
David E. O'Brien
1bd6873376 Turn back on fmtcheck's attribute checks, guarded for non-GCC compilers.
Submitted by:	bde
2001-12-04 21:30:23 +00:00
David E. O'Brien
38f54953b3 Remove the GCC'ism "__attribute__" from the 'fmtcheck' prototype.
I leave it up to someone else to fix this breakage properly.
2001-12-04 01:24:10 +00:00
Peter Wemm
d02cf26a56 Now that the compat4x libc.so.4 binary has been updated, we can finally
switch over to using a future-proof stdin/out/err.

Note that if you run 4.x binaries on your system, you will certainly
want to update /usr/lib/compat/libc.so.4.  The easiest way is to
add "COMPAT4X= yes" in your /etc/make.conf.
2001-09-20 08:47:41 +00:00
Peter Wemm
2b618987fe Rip out the old __stdin/out/err stuff. It was completely 100% useless. :-(
It was foiled because of dynamic copy relocations that caused compile-time
space to be reserved in .bss and at run time a blob of data was copied to
that space and everything used the .bss version..  The problem is that
the space is reserved at compile time, not runtime... So we *still* could
not change the size of FILE.  Sigh.  :-(

Replace it with something that does actually work and really does let us
make 'FILE' extendable.  It also happens to be the same as Linux does in
glibc, but has the slight cost of a pointer.  Note that this is the
same cost that 'fp = fopen(), fprintf(fp, ...); fclose(fp);' has.
Fortunately, actual references to stdin/out/err are not all that common
since we have implicit stdin/out/err-using versions of functions
(printf() vs. fprintf()).
2001-08-13 21:48:44 +00:00
David E. O'Brien
ea88c01d6e Style(9) fixes:
* get rid of space (0x20) before tab (^I)
* indent with ^I, not 0x20
* continuation line for prototypes is for 0x20's past function's name col.
* etc.
2001-04-22 01:56:09 +00:00
Kris Kennaway
2b77cdeac1 I think this was supposed to be __const like in NetBSD: I have no idea
why I changed it to const.

Noticed by:	David Wolfskill <david@catwhisker.org>
2001-04-17 18:16:46 +00:00
Kris Kennaway
3d09054934 Add fmtcheck(), a function for checking consistency of format string
arguments where the format string is obtained from user data, or
otherwise difficult to verify statically.

Example usage:

printf(fmtcheck(user_format, standard_format), arg1, arg2);

checks the format string user_format for consistency (same number/order/
type of format operators) with standard_format.  If they differ,
standard_format is used instead to avoid potential crashes or security
violations.

Obtained from:  NetBSD
Reviewed by:    -arch
2001-04-17 07:59:52 +00:00
Daniel Eischen
45d8008748 Hide the definition of struct __sFILEX and add the needed
lock definitions to it.  flockfile state is now allocated
along with the rest of FILE.  This eliminates the need for a
separate allocation of flockfile state as well as eliminating
the mutex/lock used to serialize its allocation.
2001-03-01 05:22:14 +00:00
Warner Losh
91e1be28dc Fix the current libc breakage in current:
o Back out the __std* stuff.  Can't figure out how to do this right now,
  so we'll save it for late.
o use _up as a pointer for extra fields that we need to access.
o back out the libc major version bump.

Submitted by: green
reviewed by: peter, imp, green, obrien (to varying degrees).

We'll fix the "how do we stop encoding sizeof(FILE) in binaries" part
later.
2001-02-16 06:11:22 +00:00
Peter Wemm
ff9dc074b5 Commit a libc fix going by the current state of the version numbering
bikeshed in -arch.  It isn't quite over, but it has been well established
that this can be adjusted or refined.  But we do seem to have consensis
on a major bump of some sort.  After this, it should reasonably safe
to build world again.

This change is to get rid of __sF[] and use seperate __stdin/out/err
handles.  This means we can pad on extra bits onto the end of FILE
at will without going through this all over again.  __sF[] was evil
because it compiled the sizeof(FILE) into every stdio using program.

Asbestos suit on: check!
Peril sensitive sunglasses on: check!
*gulp!*
2001-02-14 05:00:20 +00:00
Peter Wemm
56f98998e9 It sounded like a good idea at the time. The previous change breaks
FILE *buffer = stdout;
so back it out for now.
2001-02-12 03:31:23 +00:00
Peter Wemm
9b8ff47f40 Take advantage of the current libc sizeof(FILE) breakage (__sF[]) and
try a hopefully more robust stdin/stdout/stderr.  This costs an indirect
pointer fetch, but saves us from changes in 'FILE'.  The __stdin stuff
is there to not pollute application name space if the application does
not use <stdio.h> and also in case something depended on the current
behavior where stdin etc was a #define.

Reviewed by:	eischen, dillon
2001-02-12 02:50:30 +00:00
Daniel Eischen
5b62961a49 libc MT-safety, part 2.
Add a lock to FILE and define an additional flag.
2001-02-11 22:04:18 +00:00
Daniel Eischen
f9447cd112 Add a lock to DIR to make telldir and friends MT-safe.
Clean up stdio.h a bit and remove _THREAD_SAFE.  Some of the
usual macros getc, putc, getchar, putchar are no longer macros.

Approved by:	-arch
2001-01-24 13:01:47 +00:00
Bruce Evans
de7067ac25 Fixed missing declaration of ctermid_r(3). 1999-12-23 16:33:12 +00:00
Peter Wemm
a4add9a9b1 $Id$ -> $FreeBSD$ 1999-08-27 23:45:13 +00:00
Dmitrij Tejblum
7307d07db6 Added functions fseeko() and ftello() (from susv2).
Fixed fgetpos() and fsetpos() for offsets > 2GB.

PR:		8637
Submitted by:	 Dan Nelson <dnelson@emsphone.com> (adjusted by me a little)
1999-02-08 21:32:38 +00:00
Dmitrij Tejblum
c1b7af8ac3 Make this protototype of mmap return void *, like two other copies. 1998-12-14 19:23:16 +00:00
Bruce Evans
748993b899 Added macros __printflike() and __scanflike() to <sys/cdefs.h>.
Use them to `make gcc -Wformat' check formats for all printf-like
and scanf-like functions in /usr/src except for the err()/warn()
family.  err() isn't quite printf-like since its format arg can
legitimately be NULL.  syslog() isn't quite printf-like, but gcc
already accepts %m, even for plain printf() when it shouldn't.
1998-07-13 06:45:23 +00:00
Peter Wemm
b5fe8fabda New flag for internal stdio use to enable dynamic string allocation for
asprintf() implementation.

Obtained from: Todd Miller <Todd.Miller@courtesan.com> via OpenBSD
1998-07-08 00:52:40 +00:00
Bruce Evans
ed9c039078 Complete the switch to using gcc-2.4 features to declare fpos_t ,
as threatened in the 4-5 year old comment.  Most of the change is
in <machine/ansi.h>; this commit just removes cruft for the strict
ANSI case.  64-bit types couldn't actually be defined using
__attribute__(()) in gcc-2.4, since attribute names in the
implementation namespace only became available in gcc-2.7.  I've
probably just broken gcc-2.6 support by using the gcc-2.7 names
unconditionally.
1998-06-14 16:04:20 +00:00
John Birrell
351c800a5e I have a long list of issues to address here, mostly related to
namespace and revision levels of ANSI and POSIX. This change only
removes the leading underscrore from the FILE locking functions
that POSIX defines.
1998-05-05 21:59:19 +00:00
John Birrell
297263b079 Format changes in an attempt to address some of Bruce's comments
about spaces and tabs.

The externs in the static inline functions remain 'cause (a) they're
required; and (b) I can't find any gcc -W* cases where they generate
warnings.
1998-04-12 20:29:24 +00:00
John Birrell
7d0026cd9f Add *_unlocked() macros according to POSIX. In the _THREAD_SAFE case,
test for __isthreaded before calling the lock/unlock functions to
try to save some performance. The _THREAD_SAFE case should become the
default, but since it tests for a global variable in libc, people won't
be able to build -current on pre-3.0 systems unless the default leaves
it out. Such is life.
1998-04-11 07:33:46 +00:00
Alexander Langer
de17eb59b4 Added missing caddr_t --> void * conversions for sys/mman.h functions.
Submitted by:	bde
1998-01-01 17:07:46 +00:00
Bruce Evans
15aa51b01c Removed nonstandard #include of <sys/types.h>.
Use _BSD_OFF_T_ instead of off_t so that we're still self-sufficent.

Copied the ftruncate/lseek()/mmap()/truncate() redeclaration hacks
from <sys/types.h> so that things depending on them don't break.
1997-04-13 15:50:07 +00:00
Peter Wemm
161f948dd3 Merge Lite2 changes
(Just version number)
1997-03-11 11:16:27 +00:00
Andrey A. Chernov
3b96d4d951 increase L_cuserid because UT_NAMESIZE increased 1997-03-02 13:41:23 +00:00
Peter Wemm
79403fe300 Revert $FreeBSD$ to $Id$ 1997-02-23 09:21:14 +00:00
Jordan K. Hubbard
1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
Wolfram Schneider
8c372bd8a2 improve comments for UT_NAMESIZE 1996-10-27 18:13:35 +00:00
Wolfram Schneider
ad7076c992 remove zopen, zopen is not part of libc. 1996-07-02 23:04:50 +00:00