On Sun, 9 Apr 2006, Michael Krufky wrote: > Trent Piepho wrote: > > BTW, this patch would have been about half the work if compat.h would just: > > #define mutex semaphore > > for pre-mutex kernels. As long as no one tries to export a variable or > > function named mutex, and no one does, it's not going to mess anything up. > > apply this. Please try out the method using compat.h as you've > described above. The current drivers already containing the semaphore > to mutex compat-hack could be altered as well. Here is the patch to do this. All kernel version checks to declare something struct semaphore vs struct mutex are removed. All variables or structure members named 'mutex' are re-named to something else. This renaming isn't strictly necessary, everything will compile with out it. But the #define effecting variables is an unintended side-effect, and it better to avoid any confusion. The renaming also makes it easier to grep the code for a certain lock, with getting piles of false positives that also use the string 'mutex'. I'm also attaching a perl script that I used to help check that I found everything.
#!/usr/bin/perl while(<>) { if(eof) { %mutex = {}; $has_compat = 0; $. = 0; } if(/^#if 0/) { while(<>) { last if(/^#endif/ || eof); } redo if eof; } $has_compat = 1 if(/#\s*include.*compat\.h/); if(/#\s*include.*mutex\.h/) { print "$ARGV:$.: mutex.h included before compat.h\n" unless($has_compat); } if(/struct\s+mutex/) { /struct\s+mutex\s+(\*?\w+)/; if(exists $mutex{$1} && $mutex{$1} != 1) { print "$ARGV:$.: Mutex and semaphore defined for $1\n"; } $mutex{$1} = 1; } if(/struct\s+semaphore/) { /struct\s+semaphore\s+(\*?\w+)/; print "$ARGV:$.: Semaphore defined $1\n"; if(exists $mutex{$1} && $mutex{$1} != 2) { print "$ARGV:$.: Mutex and semaphore defined for $1\n"; } $mutex{$1} = 2; } }
Attachment:
compat_mutex.patch.gz
Description: Binary data
_______________________________________________ linux-dvb@xxxxxxxxxxx http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb