nvidia-x11-legacy{340,304}: fix build with linux-3.18

Close #9218.
It's our default kernel (now and for the upcoming release).
- 304 won't build with 4.1,
- 173 didn't even build with 3.14 due to other issues (3.12 is OK ATM)
- all legacy drivers are up-to-date with upstream releases.

+4 -2
+2
pkgs/os-specific/linux/nvidia-x11/legacy304.nix
··· 15 15 16 16 builder = ./builder-legacy304.sh; 17 17 18 + patches = [ ./nvidia-340.76-kernel-4.0.patch ]; 19 + 18 20 src = 19 21 if stdenv.system == "i686-linux" then 20 22 fetchurl {
+2 -2
pkgs/os-specific/linux/nvidia-x11/nvidia-340.76-kernel-4.0.patch
··· 4 4 unsigned long cr0 = read_cr0(); 5 5 write_cr0(((cr0 & (0xdfffffff)) | 0x40000000)); 6 6 wbinvd(); 7 - +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0) 7 + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0) 8 8 *cr4 = read_cr4(); 9 9 if (*cr4 & 0x80) write_cr4(*cr4 & ~0x80); 10 10 +#else ··· 18 18 wbinvd(); 19 19 __flush_tlb(); 20 20 write_cr0((cr0 & 0x9fffffff)); 21 - +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0) 21 + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0) 22 22 if (cr4 & 0x80) write_cr4(cr4); 23 23 +#else 24 24 + if (cr4 & 0x80) __write_cr4(cr4);