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.

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.

[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 ---

[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

[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

[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

[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

[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 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

[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 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

[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

[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

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

2013-09-17 Thread danielfsantos
Signed-off-by: Daniel Santos daniel.san...@pobox.com --- 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

[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] 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

[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

[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 ++

[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(-)

[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

[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

[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

[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

[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

[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

[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

[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(-)

[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

[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

[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

[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

[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

[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 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 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 daniel.san...@pobox.com Acked-by: David Rientjes rient...@google.com Acked-by: Borislav Petkov

[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

[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

[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 error

[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

[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

[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 daniel.san...@pobox.com --- include/linux/bug.h |5 +++-- 1 files changed, 3

[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

[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

[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 daniel.san...@pobox.com Acked-by: David Rientjes rient...@google.com Acked-by: Borislav Petkov

[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

[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

[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

[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

[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 daniel.san...@pobox.com --- include/linux/bug.h |5 +++-- 1 files changed, 3

[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 error

[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 ++

[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

[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

[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

[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

[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

[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

[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

[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

[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(-)

[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

[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

[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

[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

[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 daniel.san...@pobox.com --- include/linux/bug.h |5 +++-- 1 files changed, 3

[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

[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

[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 daniel.san...@pobox.com Acked-by: David Rientjes rient...@google.com Acked-by: Borislav Petkov

[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 error

[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

[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

[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

[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

[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

[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 ---

[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

[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

[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

[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(-)

[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

[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

[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

[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

[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 daniel.san...@pobox.com --- include/linux/bug.h |5 +++-- 1 files changed, 3

[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

[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

[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 error

[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 daniel.san...@pobox.com Acked-by: David Rientjes rient...@google.com Acked-by: Borislav Petkov

[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

[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

[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

[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

[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

  1   2   >