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
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.Jan 18 2016, 1:10 PM
mmokhi updated this object.
mmokhi edited the test plan for this revision. (Show Details)
mmokhi added a reviewer: theraven.
mmokhi added subscribers: mmokhi, theraven.
mmokhi updated this revision to Diff 12415.
theraven added inline comments.Jan 18 2016, 1:16 PM
include/stdio.h
310

inline should be __inline in FreeBSD headers.

313

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.

339

Do you mean C89?

554

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

565

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.

82

This is redundant.

mmokhi updated this revision to Diff 12421.Jan 18 2016, 3:15 PM

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

theraven added inline comments.Jan 18 2016, 3:21 PM
include/stdio.h
498

This is still an infinite loop.

imp added inline comments.Jan 18 2016, 3:49 PM
include/stdio.h
506

unlocked functions don't you mean?

mmokhi marked 5 inline comments as done.Jan 19 2016, 11:23 AM
mmokhi updated this revision to Diff 12462.

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

Trying to solve infinite recursion for multithread call of fileno

mmokhi updated this revision to Diff 12465.Jan 19 2016, 12:26 PM

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.Jan 21 2016, 5:35 PM
mmokhi updated this revision to Diff 12558.
This comment was removed by mmokhi.
mmokhi updated this revision to Diff 12566.Jan 21 2016, 5:39 PM

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
506

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.Jan 24 2016, 2:05 PM
mmokhi updated this revision to Diff 12637.

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.

mmokhi updated this revision to Diff 12676.Jan 25 2016, 8:03 AM

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
koobs added a subscriber: koobs.Jan 25 2016, 9:51 AM
mmokhi updated this revision to Diff 12961.Feb 2 2016, 8:07 PM

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

Changed getc macro-wrapper to static __inline function too.