Page MenuHomeFreeBSD

Avoid C++ namespace pollution from POSIX headers
Needs ReviewPublic

Authored by mmokhi on Jan 18 2016, 1:10 PM.

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 OK
Unit
No Unit Test Coverage
Build Status
Buildable 2364
Build 2380: 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
309

inline should be __inline in FreeBSD headers.

312

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.

338

Do you mean C89?

553

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

564

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

lib/libc/stdio/fileno.c
39

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

81

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
497

This is still an infinite loop.

include/stdio.h
505

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
505

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.