[PATCH] uml: cleanup byte order macros for COW driver

After restoring the existing code, make it work also when included in
kernelspace code (which isn't currently the case, but at least this will prevent
people from "fixing" it as just happened).
Whitespace is fixed in next patch - it cluttered the diff too much.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Paolo 'Blaisorblade' Giarrusso and committed by Linus Torvalds 028c0cc1 855ec613

+26 -2
+26 -1
arch/um/drivers/cow.h
··· 3 4 #include <asm/types.h> 5 6 #if __BYTE_ORDER == __BIG_ENDIAN 7 # define ntohll(x) (x) 8 # define htonll(x) (x) ··· 30 # define ntohll(x) bswap_64(x) 31 # define htonll(x) bswap_64(x) 32 #else 33 - #error "__BYTE_ORDER not defined" 34 #endif 35 36 extern int init_cow_file(int fd, char *cow_file, char *backing_file, 37 int sectorsize, int alignment, int *bitmap_offset_out,
··· 3 4 #include <asm/types.h> 5 6 + #if defined(__KERNEL__) 7 + 8 + # include <asm/byteorder.h> 9 + 10 + # if defined(__BIG_ENDIAN) 11 + # define ntohll(x) (x) 12 + # define htonll(x) (x) 13 + # elif defined(__LITTLE_ENDIAN) 14 + # define ntohll(x) be64_to_cpu(x) 15 + # define htonll(x) cpu_to_be64(x) 16 + # else 17 + # error "Could not determine byte order" 18 + # endif 19 + 20 + #else 21 + /* For the definition of ntohl, htonl and __BYTE_ORDER */ 22 + #include <endian.h> 23 + #include <netinet/in.h> 24 + #if defined(__BYTE_ORDER) 25 + 26 #if __BYTE_ORDER == __BIG_ENDIAN 27 # define ntohll(x) (x) 28 # define htonll(x) (x) ··· 10 # define ntohll(x) bswap_64(x) 11 # define htonll(x) bswap_64(x) 12 #else 13 + # error "Could not determine byte order: __BYTE_ORDER uncorrectly defined" 14 #endif 15 + 16 + #else /* ! defined(__BYTE_ORDER) */ 17 + # error "Could not determine byte order: __BYTE_ORDER not defined" 18 + #endif 19 + #endif /* ! defined(__KERNEL__) */ 20 21 extern int init_cow_file(int fd, char *cow_file, char *backing_file, 22 int sectorsize, int alignment, int *bitmap_offset_out,
-1
arch/um/drivers/cow_user.c
··· 9 #include <sys/time.h> 10 #include <sys/param.h> 11 #include <sys/user.h> 12 - #include <netinet/in.h> 13 14 #include "os.h" 15
··· 9 #include <sys/time.h> 10 #include <sys/param.h> 11 #include <sys/user.h> 12 13 #include "os.h" 14