| List: | Commits | « Previous MessageNext Message » | |
| From: | Davi Arnaut | Date: | June 5 2008 5:26am |
| Subject: | Re: commit into mysql-6.0-wtf:mysql-6.0-wtf branch (vvaintroub:2653) Bug#24509, WL#3049 [ifdefery] | ||
| View as plain text | |||
Hi Joerg, Joerg Bruehe wrote: > Hi Vlad, all ! > Vladislav Vaintroub wrote: >> Hi all, >> what Davi describes is a sane approach, that if consistently applied can >> result into high quality library, like Apache Portable Runtime. Hence , it >> is not applicable for us ;) >> Seriously, we do need a top-level mapper functions. The reason is that many >> mysys IO functions include large chunks of code shared on all OS (error >> handling, messing up with my_file_info array) and it does not make sense to >> replicate those chunks for every OS. What could make sense for Windows is to >> create win_file_io.c with ANSI/Posix wrappers. Then, use these wrappers in >> the mysys function. >> >> To illustrate, this approach would make piece of code like this [..] > > I am perfectly ok with this style. > It means that there will be only one place where "my_open()" is > implemented (using conditional compiling around pieces of code which are > quite small, so remain easily readable), > and it would (on Windows) call "my_win_fdopen()". > > In the same file, you could then have > > #ifdef __WIN__ > static inline int my_win_fdopen(...) { > ... > } > #endif > > which is not interrupted by conditional compiling, and thus reading and > maintaining the code is easy. > > If you put that into a different file, it is "extern", but that should > not matter much. > (IMNSHO, any system call will be so expensive that we need not worry too > much about one more function call in the chain.) I invite you (add all colleagues that haven't seen this paper) to take some time to read a 1992 USENIX paper about ifdef abuse: http://www.chris-lott.org/resources/cstyle/ifdefs.pdf H. Spencer and G. Collyer, "#ifdef Considered Harmful, or Portability Experience with C News," in Proceedings of the Summer USENIX Conference, (San Antonio, Texas), June 1992. Regards, -- Davi Arnaut
