[linux-dvb] [PATCH] Put mutex -> semaphore in compat.h

Trent Piepho xyzzy at speakeasy.org
Wed Apr 12 03:54:57 CEST 2006

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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mutex_check.pl
Type: text/x-perl
Size: 827 bytes
Url : http://www.linuxtv.org/pipermail/linux-dvb/attachments/20060411/3588f09b/mutex_check-0001.pl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compat_mutex.patch.gz
Type: application/octet-stream
Size: 12846 bytes
Url : http://www.linuxtv.org/pipermail/linux-dvb/attachments/20060411/3588f09b/compat_mutex.patch-0001.obj

More information about the linux-dvb mailing list