This is the mail archive of the
mailing list for the glibc project.
guidelines for code reuse vs. one-function-per-file?
- From: Torvald Riegel <triegel at redhat dot com>
- To: GLIBC Devel <libc-alpha at sourceware dot org>
- Date: Wed, 07 May 2014 12:43:26 +0200
- Subject: guidelines for code reuse vs. one-function-per-file?
- Authentication-results: sourceware.org; auth=none
I'd like to know what the guidelines are around the
one-function-per-file rule / preference. I'm looking at rwlock, and the
various functions there (e.g., trywrlock, wrlock, timedwrlock) are all
just variations of the same thing. If we keep each function in its own
file, there's going to be code duplication, and it won't help with
maintainability. I suppose the one-function-per-file rule is for
reducing size when linking statically, so what is one allowed to do to
avoid code duplication?
* Can one put related functions into one file? For example:
* Put trywrlock, wrlock, timedwrlock into one file?
* Put all rdlock/wrlock functions and unlock into one file?
* Can one use a source file (or header?) containing all the code and
include it in all the per-function files, using always_inline etc.?