spidev: fix hang when transfer_one_message fails

2014-01-05 Thread danielfsantos
This corrects a problem in spi_pump_messages() that leads to an spi message hanging forever when a call to transfer_one_message() fails. This failure occurs in my MCP2210 driver when the cs_change bit is set on the last transfer in a message, an operation which the hardware does not support. Ratio

[PATCH 4/5] lib: Add strerror and strerror_name functions

2013-09-17 Thread danielfsantos
Signed-off-by: Daniel Santos --- include/linux/string.h | 8 +++ lib/string.c | 60 ++ 2 files changed, 68 insertions(+) diff --git a/include/linux/string.h b/include/linux/string.h index ac889c5..76ce2ff 100644 --- a/include/linux/s

[PATCH 3/5] Makefile: Generate error_strings.h

2013-09-17 Thread danielfsantos
This is an initial attempt and needs improvement. Ideally, error_strings.h should only be generated when STRERROR or STRERROR_NAME are enabled. This implementation also fails to remake error_strings.h when arch-specific dependencies change. Also, I've noticed that this implementation fails to out

[PATCH 5/5] lib: Add error string support to printks

2013-09-17 Thread danielfsantos
This adds an extension for the integral format specifier suffix of 'e', so that the format %[duxXo]e will result in printing an number (as before) in addition to a name and descrption for an error code, if such support is enabled and a name and descrption is found. My initial thought was to use th

[PATCH 1/5] scripts: Add mkstrerror.sh

2013-09-17 Thread danielfsantos
This is a simple bash script that parses our errno*.h files and formats them into the error_strings.h header that our strerror and strerror_name functions will use later. First it looks at $ARCH and examines the errno.h files and figures out which to use. Then, it parses their error definitions in

[PATCH 0/5] Preliminary: Add error names & descrptions to printks

2013-09-17 Thread danielfsantos
This is a preliminary patch set as the root Makefile changes are not yet correct. Summary Typically, we don't care about error messages or names in the kernel because userspace will manage that. But sometimes we need to output an error number to printks and that creates a situation where a user

[PATCH 2/5] lib: Add .config options for error strings in printks

2013-09-17 Thread danielfsantos
This adds to lib/Kconfig.debug the options for printk messages to display either error number only (the current behavior), number and error name or number, name and description. These options in turn select STRERROR_NAME and STRERROR as needed, so I'm not adding any direct options to enable those,

[PATCH] gpiolib: Fix crash when exporting non-existant gpio

2013-08-24 Thread danielfsantos
I got this on an RPi and I can't find anything specific to that. Besides, it's clearly wrong to try to access desc->chip when we have just tested that it may be NULL at drivers/gpio/gpiolib.c:1409: chip = desc->chip; if (chip == NULL) goto done; done:

[PATCH] gpiolib: Fix crash when exporting non-existant gpio

2013-08-24 Thread danielfsantos
I got this on an RPi and I can't find anything specific to that. Besides, it's clearly wrong to try to access desc->chip when we have just tested that it may be NULL at drivers/gpio/gpiolib.c:1409: chip = desc->chip; if (chip == NULL) goto done; done:

[PATCH v8 2/9] compiler-gcc.h: Add gcc-recommended GCC_VERSION macro

2013-01-01 Thread danielfsantos
Throughout compiler*.h, many version checks are made. These can be simplified by using the macro that gcc's documentation recommends. However, my primary reason for adding this is that I need bug-check macros that are enabled at certain gcc versions and it's cleaner to use this macro than the trad

[PATCH v8 3/9] compiler-gcc{3,4}.h: Use GCC_VERSION macro

2013-01-01 Thread danielfsantos
Using GCC_VERSION reduces complexity, is easier to read and is GCC's recommended mechanism for doing version checks. (Just don't ask me why they didn't define it in the first place.) This also makes it easy to merge compiler-gcc{,3,4}.h should somebody want to. Signed-off-by: Daniel Santos Acked

[PATCH v8 0/9] Cleanup & new features for compiler*.h and bug.h

2013-01-01 Thread danielfsantos
Well, it looks like my new version of git properly handles the --in-reply-to switch now, so this patch set shouldn't be oddly threaded like the last version. include/linux/bug.h | 47 ++-- include/linux/compiler-gcc.h |3 ++ include/linux/comp

[PATCH v8 6/9] bug.h: Prevent double evaulation of in BUILD_BUG_ON

2013-01-01 Thread danielfsantos
When calling BUILD_BUG_ON in an optimized build using gcc 4.3 and later, the condition will be evaulated twice, possibily with side-effects. This patch eliminates that error. Signed-off-by: Daniel Santos --- include/linux/bug.h |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff

[PATCH v8 8/9] compiler.h, bug.h: Prevent double error messages with BUILD_BUG{,_ON}

2013-01-01 Thread danielfsantos
Prior to the introduction of __attribute__((error("msg"))) in gcc 4.3, creating compile-time errors required a little trickery. BUILD_BUG{,_ON} uses this attribute when available to generate compile-time errors, but also uses the negative-sized array trick for older compilers, resulting in two erro

[PATCH v8 4/9] compiler{,-gcc4}.h, bug.h: Remove duplicate macros

2013-01-01 Thread danielfsantos
__linktime_error() does the same thing as __compiletime_error() and is only used in bug.h. Since the macro defines a function attribute that will cause a failure at compile-time (not link-time), it makes more sense to keep __compiletime_error(), which is also neatly mated with __compiletime_warnin

[PATCH v8 9/9] bug.h, compiler.h: Introduce compiletime_assert & BUILD_BUG_ON_MSG

2013-01-01 Thread danielfsantos
Introduce compiletime_assert to compiler.h, which moves the details of how to break a build and emit an error message for a specific compiler to the headers where these details should be. Following in the tradition of the POSIX assert macro, compiletime_assert creates a build-time error when the su

[PATCH v8 5/9] bug.h: Fix BUILD_BUG_ON macro in __CHECKER__

2013-01-01 Thread danielfsantos
When __CHECKER__ is defined, we disable all of the BUILD_BUG.* macros. However, both BUILD_BUG_ON_NOT_POWER_OF_2 and BUILD_BUG_ON was evaluating to nothing in this case, and we want (0) since this is a function-like macro that will be followed by a semicolon. Signed-off-by: Daniel Santos Acked-by

[PATCH v8 7/9] bug.h: Make BUILD_BUG_ON generate compile-time error

2013-01-01 Thread danielfsantos
Negative sized arrays wont create a compile-time error in some cases starting with gcc 4.4 (e.g., inlined functions), but gcc 4.3 introduced the error function attribute that will. This patch modifies BUILD_BUG_ON to behave like BUILD_BUG already does, using the error function attribute so that yo

[PATCH v8 1/9] compiler-gcc4.h: Reorder macros based upon gcc ver

2013-01-01 Thread danielfsantos
This helps to keep the file from getting confusing, removes one duplicate version check and should encourage future editors to put new macros where they belong. Signed-off-by: Daniel Santos Acked-by: David Rientjes Acked-by: Borislav Petkov --- include/linux/compiler-gcc4.h | 20 +++-

[PATCH v7 3/9] compiler-gcc{3,4}.h: Use GCC_VERSION macro

2013-01-01 Thread danielfsantos
Using GCC_VERSION reduces complexity, is easier to read and is GCC's recommended mechanism for doing version checks. (Just don't ask me why they didn't define it in the first place.) This also makes it easy to merge compiler-gcc{,3,4}.h should somebody want to. Signed-off-by: Daniel Santos Acked

[PATCH v7 2/9] compiler-gcc.h: Add gcc-recommended GCC_VERSION macro

2013-01-01 Thread danielfsantos
Throughout compiler*.h, many version checks are made. These can be simplified by using the macro that gcc's documentation recommends. However, my primary reason for adding this is that I need bug-check macros that are enabled at certain gcc versions and it's cleaner to use this macro than the trad

[PATCH v7 6/9] bug.h: Prevent double evaulation of in BUILD_BUG_ON

2013-01-01 Thread danielfsantos
When calling BUILD_BUG_ON in an optimized build using gcc 4.3 and later, the condition will be evaulated twice, possibily with side-effects. This patch eliminates that error. Signed-off-by: Daniel Santos --- include/linux/bug.h |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff

[PATCH v7 9/9] bug.h, compiler.h: Introduce compiletime_assert & BUILD_BUG_ON_MSG

2013-01-01 Thread danielfsantos
Introduce compiletime_assert to compiler.h, which moves the details of how to break a build and emit an error message for a specific compiler to the headers where these details should be. Following in the tradition of the POSIX assert macro, compiletime_assert creates a build-time error when the su

[PATCH v7 4/9] compiler{,-gcc4}.h, bug.h: Remove duplicate macros

2013-01-01 Thread danielfsantos
__linktime_error() does the same thing as __compiletime_error() and is only used in bug.h. Since the macro defines a function attribute that will cause a failure at compile-time (not link-time), it makes more sense to keep __compiletime_error(), which is also neatly mated with __compiletime_warnin

[PATCH v7 7/9] bug.h: Make BUILD_BUG_ON generate compile-time error

2013-01-01 Thread danielfsantos
Negative sized arrays wont create a compile-time error in some cases starting with gcc 4.4 (e.g., inlined functions), but gcc 4.3 introduced the error function attribute that will. This patch modifies BUILD_BUG_ON to behave like BUILD_BUG already does, using the error function attribute so that yo

[PATCH v7 8/9] compiler.h, bug.h: Prevent double error messages with BUILD_BUG{,_ON}

2013-01-01 Thread danielfsantos
Prior to the introduction of __attribute__((error("msg"))) in gcc 4.3, creating compile-time errors required a little trickery. BUILD_BUG{,_ON} uses this attribute when available to generate compile-time errors, but also uses the negative-sized array trick for older compilers, resulting in two erro

[PATCH v7 5/9] bug.h: Fix BUILD_BUG_ON macro in __CHECKER__

2013-01-01 Thread danielfsantos
When __CHECKER__ is defined, we disable all of the BUILD_BUG.* macros. However, both BUILD_BUG_ON_NOT_POWER_OF_2 and BUILD_BUG_ON was evaluating to nothing in this case, and we want (0) since this is a function-like macro that will be followed by a semicolon. Signed-off-by: Daniel Santos Acked-by

[PATCH v7 1/9] compiler-gcc4.h: Reorder macros based upon gcc ver

2013-01-01 Thread danielfsantos
This helps to keep the file from getting confusing, removes one duplicate version check and should encourage future editors to put new macros where they belong. Signed-off-by: Daniel Santos Acked-by: David Rientjes Acked-by: Borislav Petkov --- include/linux/compiler-gcc4.h | 26

[PATCH v7 0/9] Cleanup & new features for compiler*.h and bug.h

2013-01-01 Thread danielfsantos
include/linux/bug.h | 47 ++-- include/linux/compiler-gcc.h |3 ++ include/linux/compiler-gcc3.h |8 +++--- include/linux/compiler-gcc4.h | 36 +++--- include/linux/compiler.h | 32 +-

[PATCH v6 7/9] bug.h: Make BUILD_BUG_ON generate compile-time error

2012-11-20 Thread danielfsantos
Negative sized arrays wont create a compile-time error in some cases starting with gcc 4.4 (e.g., inlined functions), but gcc 4.3 introduced the error function attribute that will. This patch modifies BUILD_BUG_ON to behave like BUILD_BUG already does, using the error function attribute so that yo

[PATCH v6 3/9] compiler-gcc{3,4}.h: Use GCC_VERSION macro

2012-11-20 Thread danielfsantos
Using GCC_VERSION reduces complexity, is easier to read and is GCC's recommended mechanism for doing version checks. (Just don't ask me why they didn't define it in the first place.) This also makes it easy to merge compiler-gcc{,3,4}.h should somebody want to. Signed-off-by: Daniel Santos Acked

[PATCH v6 4/9] compiler{,-gcc4}.h, bug.h: Remove duplicate macros

2012-11-20 Thread danielfsantos
__linktime_error() does the same thing as __compiletime_error() and is only used in bug.h. Since the macro defines a function attribute that will cause a failure at compile-time (not link-time), it makes more sense to keep __compiletime_error(), which is also neatly mated with __compiletime_warnin

[PATCH v6 8/9] compiler.h, bug.h: Prevent double error messages with BUILD_BUG{,_ON}

2012-11-20 Thread danielfsantos
Prior to the introduction of __attribute__((error("msg"))) in gcc 4.3, creating compile-time errors required a little trickery. BUILD_BUG{,_ON} uses this attribute when available to generate compile-time errors, but also uses the negative-sized array trick for older compilers, resulting in two erro

[PATCH v6 1/9] compiler-gcc4.h: Reorder macros based upon gcc ver

2012-11-20 Thread danielfsantos
This helps to keep the file from getting confusing, removes one duplicate version check and should encourage future editors to put new macros where they belong. Signed-off-by: Daniel Santos Acked-by: David Rientjes Acked-by: Borislav Petkov --- include/linux/compiler-gcc4.h | 20 +++-

[PATCH v6 9/9] bug.h, compiler.h: Introduce compiletime_assert & BUILD_BUG_ON_MSG

2012-11-20 Thread danielfsantos
Introduce compiletime_assert to compiler.h, which moves the details of how to break a build and emit an error message for a specific compiler to the headers where these details should be. Following in the tradition of the POSIX assert macro, compiletime_assert creates a build-time error when the su

[PATCH v6 5/9] bug.h: Fix BUILD_BUG_ON macro in __CHECKER__

2012-11-20 Thread danielfsantos
When __CHECKER__ is defined, we disable all of the BUILD_BUG.* macros. However, both BUILD_BUG_ON_NOT_POWER_OF_2 and BUILD_BUG_ON was evaluating to nothing in this case, and we want (0) since this is a function-like macro that will be followed by a semicolon. Signed-off-by: Daniel Santos Acked-by

[PATCH v6 6/9] bug.h: Prevent double evaulation of in BUILD_BUG_ON

2012-11-20 Thread danielfsantos
When calling BUILD_BUG_ON in an optimized build using gcc 4.3 and later, the condition will be evaulated twice, possibily with side-effects. This patch eliminates that error. Signed-off-by: Daniel Santos --- include/linux/bug.h |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff

[PATCH v6 2/9] compiler-gcc.h: Add gcc-recommended GCC_VERSION macro

2012-11-20 Thread danielfsantos
Throughout compiler*.h, many version checks are made. These can be simplified by using the macro that gcc's documentation recommends. However, my primary reason for adding this is that I need bug-check macros that are enabled at certain gcc versions and it's cleaner to use this macro than the trad

[PATCH v6 0/9] Cleanup & new features for compiler*.h and bug.h

2012-11-20 Thread danielfsantos
include/linux/bug.h | 47 ++-- include/linux/compiler-gcc.h |3 ++ include/linux/compiler-gcc3.h |8 +++--- include/linux/compiler-gcc4.h | 28 include/linux/compiler.h | 32 +-- 5 f

[PATCH v5 2/9] compiler-gcc.h: Add gcc-recommended GCC_VERSION macro

2012-11-13 Thread danielfsantos
Throughout compiler*.h, many version checks are made. These can be simplified by using the macro that gcc's documentation recommends. However, my primary reason for adding this is that I need bug-check macros that are enabled at certain gcc versions and it's cleaner to use this macro than the trad

[PATCH v5 4/9] compiler{,-gcc4}.h, bug.h: Remove duplicate macros

2012-11-13 Thread danielfsantos
__linktime_error() does the same thing as __compiletime_error() and is only used in bug.h. Since the macro defines a function attribute that will cause a failure at compile-time (not link-time), it makes more sense to keep __compiletime_error(), which is also neatly mated with __compiletime_warnin

[PATCH v5 5/9] bug.h: Fix BUILD_BUG_ON macro in __CHECKER__

2012-11-13 Thread danielfsantos
When __CHECKER__ is defined, we disable all of the BUILD_BUG.* macros. However, both BUILD_BUG_ON_NOT_POWER_OF_2 and BUILD_BUG_ON was evaluating to nothing in this case, and we want (0) since this is a function-like macro that will be followed by a semicolon. Signed-off-by: Daniel Santos --- inc

[PATCH v5 1/9] compiler-gcc4.h: Reorder macros based upon gcc ver

2012-11-13 Thread danielfsantos
This helps to keep the file from getting confusing, removes one duplicate version check and should encourage future editors to put new macros where they belong. Signed-off-by: Daniel Santos Acked-by: David Rientjes Acked-by: Borislav Petkov --- include/linux/compiler-gcc4.h | 20 +++-

[PATCH v5 8/9] compiler.h, bug.h: Prevent double error messages with BUILD_BUG{,_ON}

2012-11-13 Thread danielfsantos
Prior to the introduction of __attribute__((error("msg"))) in gcc 4.3, creating compile-time errors required a little trickery. BUILD_BUG{,_ON} uses this attribute when available to generate compile-time errors, but also uses the negative-sized array trick for older compilers, resulting in two erro

[PATCH v5 9/9] bug.h, compiler.h: Introduce compiletime_assert & BUILD_BUG_ON_MSG

2012-11-13 Thread danielfsantos
Introduce compiletime_assert to compiler.h, which moves the details of how to break a build and emit an error message for a specific compiler to the headers where these details should be. Following the tradition of the POSIX assert macro, compiletime_assert creates a build-time error when the suppl

[PATCH v5 7/9] bug.h: Make BUILD_BUG_ON generate compile-time error

2012-11-13 Thread danielfsantos
Negative sized arrays wont create a compile-time error in some cases starting with gcc 4.4 (e.g., inlined functions), but gcc 4.3 introduced the error function attribute that will. This patch modifies BUILD_BUG_ON to behave like BUILD_BUG already does, using the error function attribute so that yo

[PATCH v5 6/9] bug.h: Prevent double evaulation of in BUILD_BUG_ON

2012-11-13 Thread danielfsantos
When calling BUILD_BUG_ON in an optimized build using gcc 4.3 and later, the condition will be evaulated twice, possibily with side-effects. This patch eliminates that error. Signed-off-by: Daniel Santos --- include/linux/bug.h |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff

[PATCH v5 3/9] compiler-gcc{3,4}.h: Use GCC_VERSION macro

2012-11-13 Thread danielfsantos
Using GCC_VERSION reduces complexity, is easier to read and is GCC's recommended mechanism for doing version checks. (Just don't ask me why they didn't define it in the first place.) This also makes it easy to merge compiler-gcc{,3,4}.h should somebody want to. Signed-off-by: Daniel Santos Acked

[PATCH v5 0/9] Cleanup & new features for compiler*.h and bug.h

2012-11-13 Thread danielfsantos
include/linux/bug.h | 47 ++-- include/linux/compiler-gcc.h |3 ++ include/linux/compiler-gcc3.h |8 +++--- include/linux/compiler-gcc4.h | 28 include/linux/compiler.h | 32 +-- 5 f

[PATCH v4 2/9] compiler-gcc.h: Add gcc-recommended GCC_VERSION macro

2012-10-28 Thread danielfsantos
Throughout compiler*.h, many version checks are made. These can be simplified by using the macro that gcc's documentation recommends. However, my primary reason for adding this is that I need bug-check macros that are enabled at certain gcc versions and it's cleaner to use this macro than the trad

[PATCH v4 4/9] compiler{,-gcc4}.h, bug.h: Remove duplicate macros

2012-10-28 Thread danielfsantos
__linktime_error() does the same thing as __compiletime_error() and is only used in bug.h. Since the macro defines a function attribute that will cause a failure at compile-time (not link-time), it makes more sense to keep __compiletime_error(), which is also neatly mated with __compiletime_warnin

[PATCH v4 5/9] bug.h: Make BUILD_BUG_ON generate compile-time error

2012-10-28 Thread danielfsantos
Negative sized arrays wont create a compile-time error in some cases starting with gcc 4.4 (e.g., inlined functions), but gcc 4.3 introduced the error function attribute that will. This patch modifies BUILD_BUG_ON to behave like BUILD_BUG already does, using the error function attribute so that yo

[PATCH v4 7/9] bug.h: Fix BUILD_BUG_ON macro in __CHECKER__

2012-10-28 Thread danielfsantos
When __CHECKER__ is defined, we disable all of the BUILD_BUG.* macros. However, BUILD_BUG_ON was evaluating to nothing in this case, and we want (0) since this is a function-like macro that will be followed by a semicolon. Signed-off-by: Daniel Santos --- include/linux/bug.h |2 +- 1 files c

[PATCH v4 3/9] compiler-gcc{3,4}.h: Use GCC_VERSION macro

2012-10-28 Thread danielfsantos
Using GCC_VERSION reduces complexity, is easier to read and is GCC's recommended mechanism for doing version checks. (Just don't ask me why they didn't define it in the first place.) This also makes it easy to merge compiler-gcc{,3,4}.h should somebody want to. Signed-off-by: Daniel Santos Acked

[PATCH v4 8/9] bug.h: Add BUILD_BUG_ON_MSG & _BUILD_BUG_INTERNAL

2012-10-28 Thread danielfsantos
Add BUILD_BUG_ON_MSG which behaves like BUILD_BUG_ON (with optimizations enabled), except that it allows you to specify the error message you want emitted as the third parameter. Under the hood, this relies on _BUILD_BUG_INTERNAL, which does the actual work and is pretty-much identical to BUILD_BU

[PATCH v4 9/9] bug.h: Convert BUILD_BUG{,_ON} to use BUILD_BUG_ON_MSG

2012-10-28 Thread danielfsantos
Remove duplicate code by converting BUILD_BUG and BUILD_BUG_ON to just call BUILD_BUG_ON_MSG. This not only reduces source code bloat, but also prevents the possibility of code being changed for one macro and not for the other (which was previously the case for BUILD_BUG and BUILD_BUG_ON). Signed

[PATCH v4 6/9] compiler.h, bug.h: Prevent double error messages with BUILD_BUG{,_ON}

2012-10-28 Thread danielfsantos
Prior to the introduction of __attribute__((error("msg"))) in gcc 4.3, creating compile-time errors required a little trickery. BUILD_BUG{,_ON} uses this attribute when available to generate compile-time errors, but also uses the negative-sized array trick for older compilers, resulting in two erro

[PATCH v4 1/9] compiler-gcc4.h: Reorder macros based upon gcc ver

2012-10-28 Thread danielfsantos
This helps to keep the file from getting confusing, removes one duplicate version check and should encourage future editors to put new macros where they belong. Signed-off-by: Daniel Santos Acked-by: David Rientjes --- include/linux/compiler-gcc4.h | 20 +++- 1 files changed,

[PATCH v4 0/10] Cleanup & new features for compiler*.h and bug.h

2012-10-28 Thread danielfsantos
include/linux/bug.h | 59 ++-- include/linux/compiler-gcc.h |3 ++ include/linux/compiler-gcc3.h |8 +++--- include/linux/compiler-gcc4.h | 28 +- include/linux/compiler.h |8 - 5 files changed, 65 insertions(

[PATCH v3 06/10] bug.h: Make BUILD_BUG_ON generate compile-time error

2012-10-24 Thread danielfsantos
Negative sized arrays wont create a compile-time error in some cases starting with gcc 4.4 (e.g., inlined functions), but gcc 4.3 introduced the error function attribute that will. This patch modifies BUILD_BUG_ON to behave like BUILD_BUG already does, using the error function attribute so that yo

[PATCH v3 02/10] compiler-gcc.h: Add gcc-recommended GCC_VERSION macro

2012-10-24 Thread danielfsantos
Throughout compiler*.h, many version checks are made. These can be simplified by using the macro that gcc's documentation recommends. However, my primary reason for adding this is that I need bug-check macros that are enabled at certain gcc versions and it's cleaner to use this macro than the trad

[PATCH v3 09/10] bug.h: Add BUILD_BUG_ON_MSG & _BUILD_BUG_INTERNAL

2012-10-24 Thread danielfsantos
Add BUILD_BUG_ON_MSG which behaves like BUILD_BUG_ON (with optimizations enabled), except that it allows you to specify the error message you want emitted as the third parameter. Under the hood, this relies on _BUILD_BUG_INTERNAL, which does the actual work and is pretty-much identical to BUILD_BU

[PATCH v3 01/10] compiler-gcc4.h: Reorder macros based upon gcc ver

2012-10-24 Thread danielfsantos
This helps to keep the file from getting confusing, removes one duplicate version check and should encourage future editors to put new macros where they belong. Signed-off-by: Daniel Santos Acked-by: David Rientjes --- include/linux/compiler-gcc4.h | 20 +++- 1 files changed,

[PATCH v3 04/10] bug.h: directly include linux/compiler.h

2012-10-24 Thread danielfsantos
Currently, we are only including asm/bug.h and then expecting that linux/compiler.h will eventually be included to define __linktime_error (used in BUILD_BUG_ON). This patch includes it directly for clarity and to avoid the possibility of changes in /*/include/asm/bug.h being changed or not includi

[PATCH v3 07/10] compiler.h, bug.h: Prevent double error messages with BUILD_BUG{,_ON}

2012-10-24 Thread danielfsantos
Prior to the introduction of __attribute__((error("msg"))) in gcc 4.3, creating compile-time errors required a little trickery. BUILD_BUG{,_ON} uses this attribute when available to generate compile-time errors, but also uses the negative-sized array trick for older compilers, resulting in two erro

[PATCH v3 10/10] bug.h: Convert BUILD_BUG{,_ON} to use BUILD_BUG_ON_MSG

2012-10-24 Thread danielfsantos
Remove duplicate code by converting BUILD_BUG and BUILD_BUG_ON to just call BUILD_BUG_ON_MSG. This not only reduces source code bloat, but also prevents the possibility of code being changed for one macro and not for the other (which was previously the case for BUILD_BUG and BUILD_BUG_ON). Signed

[PATCH v3 08/10] bug.h: Fix BUILD_BUG_ON macro in __CHECKER__

2012-10-24 Thread danielfsantos
When __CHECKER__ is defined, we disable all of the BUILD_BUG.* macros. However, BUILD_BUG_ON was evaluating to nothing in this case, and we want (0) since this is a function-like macro that will be followed by a semicolon. Signed-off-by: Daniel Santos --- include/linux/bug.h |2 +- 1 files c

[PATCH v3 03/10] compiler-gcc{3,4}.h: Use GCC_VERSION macro

2012-10-24 Thread danielfsantos
Using GCC_VERSION reduces complexity, is easier to read and is GCC's recommended mechanism for doing version checks. (Just don't ask me why they didn't define it in the first place.) This also makes it easy to merge compiler-gcc{,3,4}.h should somebody want to. Signed-off-by: Daniel Santos Acked

[PATCH v3 05/10] compiler{,-gcc4}.h, bug.h: Remove duplicate macros

2012-10-24 Thread danielfsantos
__linktime_error() does the same thing as __compiletime_error() and is only used in bug.h. Since the macro defines a function attribute that will cause a failure at compile-time (not link-time), it makes more sense to keep __compiletime_error(), which is also neatly mated with __compiletime_warnin

[PATCH v3 0/10] Cleanup & new features for compiler*.h and bug.h

2012-10-24 Thread danielfsantos
This patch set is a dependency of the generic red-black tree patch set, which I have now split up into three smaller sets and is based off of linux-next. The major aim of this patch set is to cleanup compiler-gcc*.h and improve the manageability of of compiler features at various versions (when t

[PATCH v2 05/10] compiler{,-gcc4}.h, bug.h: Remove duplicate macros

2012-10-05 Thread danielfsantos
__linktime_error() does the same thing as __compiletime_error() and is only used in bug.h. Since the macro defines a function attribute that will cause a failure at compile-time (not link-time), it makes more sense to keep __compiletime_error(), which is also neatly mated with __compiletime_warnin

[PATCH v2 07/10] compiler.h, bug.h: Prevent double error messages with BUILD_BUG{,_ON}

2012-10-05 Thread danielfsantos
Prior to the introduction of __attribute__((error("msg"))) in gcc 4.3, creating compile-time errors required a little trickery. BUILD_BUG{,_ON} uses this attribute when available to generate compile-time errors, but also uses the negative-sized array trick for older compilers, resulting in two erro

[PATCH v2 10/10] bug.h: Convert BUILD_BUG{,_ON} to use BUILD_BUG_ON_MSG

2012-10-05 Thread danielfsantos
Remove duplicate code by converting BUILD_BUG and BUILD_BUG_ON to just call BUILD_BUG_ON_MSG. This not only reduces source code bloat, but also prevents the possibility of code being changed for one macro and not for the other (which was previously the case for BUILD_BUG and BUILD_BUG_ON). Signed

[PATCH v2 09/10] bug.h: Add BUILD_BUG_ON_MSG & BUILD_BUG_INTERNAL{,2}

2012-10-05 Thread danielfsantos
Add BUILD_BUG_ON_MSG which behaves like BUILD_BUG_ON (with optimizations turned enabled), except that it allows you to specify the error message you want emitted as the third parameter. Under the hood, this relies on BUILD_BUG_INTERNAL{,2}, which does the actual work and is pretty-much identical t

[PATCH v2 08/10] bug.h: Fix BUILD_BUG_ON macro in __CHECKER__

2012-10-05 Thread danielfsantos
When __CHECKER__ is defined, we disable all of the BUILD_BUG.* macros. However, BUILD_BUG_ON was evaluating to nothing in this case, and we want (0) since this is a function-like macro that will be followed by a semicolon. Signed-off-by: Daniel Santos --- include/linux/bug.h |2 +- 1 files c

[PATCH v2 06/10] bug.h: Make BUILD_BUG_ON generate compile-time error

2012-10-05 Thread danielfsantos
Negative sized arrays wont create a compile-time error in some cases starting with gcc 4.4 (e.g., inlined functions), but gcc 4.3 introduced the error function attribute that will. This patch modifies BUILD_BUG_ON to behave like BUILD_BUG already does, using the error function attribute so that yo

[PATCH v2 04/10] bug.h: directly include linux/compiler.h

2012-10-05 Thread danielfsantos
We are just including asm/bug.h and expecting that linux/compiler.h will eventually be included to define __linktime_error (used in BUILD_BUG_ON). This patch includes it directly for clarity and to avoid the possibility of changes in /*/include/asm/bug.h being changed or not including linux/compile

[PATCH v2 02/10] compiler-gcc.h: Add gcc-recommended GCC_VERSION macro

2012-10-05 Thread danielfsantos
Throughout compiler*.h, many version checks are made. These can be simplified by using the macro that gcc's documentation recommends. However, my primary reason for adding this is that I need bug-check macros that are enabled at certain gcc versions and it's cleaner to use this macro than the trad

[PATCH v2 03/10] compiler-gcc{3,4}.h: Use GCC_VERSION macro

2012-10-05 Thread danielfsantos
Using GCC_VERSION reduces complexity, is easier to read and is GCC's recommended mechanism for doing version checks. (Just don't ask me why they didn't define it in the first place.) This also makes it easy to merge compiler-gcc{,3,4}.h should somebody want to. Signed-off-by: Daniel Santos Acked

[PATCH v2 01/10] compiler-gcc4.h: Reorder macros based upon gcc ver

2012-10-05 Thread danielfsantos
This helps to keep the file from getting confusing, removes one duplicate version check and should encourage future editors to put new macros where they belong. Signed-off-by: Daniel Santos Acked-by: David Rientjes --- include/linux/compiler-gcc4.h | 20 +++- 1 files changed,

[PATCH v2 0/10] Cleanup & new features for compiler*.h and bug.h

2012-10-05 Thread danielfsantos
This patch set is a dependency of the generic red-black tree patch set, which I have now split up into three smaller sets. The major aim of this patch set is to cleanup compiler-gcc*.h and improve the manageability of of compiler features at various versions (when they are broken, etc.), and to c