Page MenuHomeFreeBSD

Avoid C++ namespace pollution from POSIX headers
Needs ReviewPublic

Authored by mmokhi on Jan 18 2016, 1:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 4:06 AM
Unknown Object (File)
Mon, Nov 18, 3:20 PM
Unknown Object (File)
Thu, Oct 24, 9:43 PM
Unknown Object (File)
Oct 19 2024, 3:56 PM
Unknown Object (File)
Oct 5 2024, 12:15 PM
Unknown Object (File)
Oct 1 2024, 7:02 PM
Unknown Object (File)
Oct 1 2024, 2:15 AM
Unknown Object (File)
Sep 27 2024, 5:05 AM

Details

Reviewers
theraven
Summary

This patch uses header-guards and static-inline functions

	 instead of macro-wrappers inside stdio.h
Test Plan

replace fileno macro-wrapper with an static-inline function

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 2171
Build 2180: arc lint + arc unit

Event Timeline

mmokhi retitled this revision from to Avoid C++ namespace pollution from POSIX headers.
mmokhi updated this object.
mmokhi edited the test plan for this revision. (Show Details)
mmokhi added a reviewer: theraven.
mmokhi added subscribers: mmokhi, theraven.
include/stdio.h
308

inline should be __inline in FreeBSD headers.

311

Don't put smilies in comments.

We should perhaps abstract inline / static inline away in cdefs.h a bit, to avoid all of these #ifdefs.

335

Do you mean C89?

531

This will now recursively all itself until you run out of stack space in a multithreaded program.

543

This function is not public and should not be part of the public implementation.

lib/libc/stdio/fileno.c
40

FILENO_C is not in a reserved namepsace. Programs are free to define this and expect it not to break system headers.

66

This is redundant.

Updating D4980: Avoid C++ namespace pollution from POSIX headers

Editing patches respecting comments
Changed inline to inline, this helps us not #ifdef(s) for controlling C/C++ version
Changed FILENO_C to
FILENO_C

include/stdio.h
494

This is still an infinite loop.

include/stdio.h
502

unlocked functions don't you mean?

mmokhi marked 5 inline comments as done.

Updating D4980: Avoid C++ namespace pollution from POSIX headers

Trying to solve infinite recursion for multithread call of fileno

Updating D4980: Avoid C++ namespace pollution from POSIX headers

Defined an extern wrapper for original fileno() to avoid infinite-recursion on mutithread cases
Inserted comments into source code for clarifying new codes

mmokhi marked 2 inline comments as done.
This comment was removed by mmokhi.

Organizing comments about __fileno_mt() inside stdio.h and fileno.c
After fixing infinite loop.

@theraven:

AFAIK, turning these macro-wrappers into functions, makes CC resolve symbols in compile/link-time.

This means; unlike macros that not processed till be used by user, these functions (and symbols/functions inside'em) should be resolved at first and so every program that uses stdio.h should use -lc flag.

Is this okay from your side ?

include/stdio.h
502

yes, is there problem with'em? or with this comment (i just copy/pasted this comment from previous version ;D)

mmokhi marked 3 inline comments as done.

Updating D4980: Avoid C++ namespace pollution from POSIX headers

manythings basically changed as i used symbol versioning.
BTW, it's considered pre-alpha from my side (though i've successfully rebuilt world [and libc++ in buildenv])
I'll put comment inside it after i became sure of its style.

Updating D4980: Avoid C++ namespace pollution from POSIX headers

This revision contains important changes.

  1. Reduce(and revert, when needed) HUGE changes i've made on Symbols.map in more reasonable way.
  2. Use symbol aliasing (Only when supported by platform).
  3. Add better in-code comments explaining why using what :D

Updating D4980: Avoid C++ namespace pollution from POSIX headers

Changed getc macro-wrapper to static __inline function too.