* [PATCH 0/1] Use macros from compiler.h instead of gcc specific attributes
@ 2014-03-01 16:02 Gideon Israel Dsouza
2014-03-01 16:02 ` [PATCH 1/1] mm: use macros from compiler.h instead of __attribute__((...)) Gideon Israel Dsouza
0 siblings, 1 reply; 6+ messages in thread
From: Gideon Israel Dsouza @ 2014-03-01 16:02 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, linux-kernel, geert, Gideon Israel Dsouza
To increase compiler portability there is <linux/compiler.h> which
provides convenience macros for various gcc constructs. Eg: __weak for
__attribute__((weak)).
I've taken up the job of cleaning these attributes all over the kernel.
Currently my patches for cleanup of all files under /kernel and /block
are already done and in the linux-next tree.
In the following patch I've replaced all aforementioned instances under
the /mm directory in the kernel source.
Gideon Israel Dsouza (1):
mm: use macros from compiler.h instead of __attribute__((...))
mm/hugetlb.c | 3 ++-
mm/nommu.c | 3 ++-
mm/sparse.c | 6 ++++--
mm/util.c | 5 +++--
mm/vmalloc.c | 4 +++-
5 files changed, 14 insertions(+), 7 deletions(-)
--
1.8.5.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/1] mm: use macros from compiler.h instead of __attribute__((...))
2014-03-01 16:02 [PATCH 0/1] Use macros from compiler.h instead of gcc specific attributes Gideon Israel Dsouza
@ 2014-03-01 16:02 ` Gideon Israel Dsouza
2014-03-01 17:38 ` Geert Uytterhoeven
0 siblings, 1 reply; 6+ messages in thread
From: Gideon Israel Dsouza @ 2014-03-01 16:02 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, linux-kernel, geert, Gideon Israel Dsouza
To increase compiler portability there is <linux/compiler.h> which
provides convenience macros for various gcc constructs. Eg: __weak for
__attribute__((weak)). I've replaced all instances of gcc attributes with
the right macro in the memory management (/mm) subsystem.
Signed-off-by: Gideon Israel Dsouza <gidisrael@gmail.com>
---
mm/hugetlb.c | 3 ++-
mm/nommu.c | 3 ++-
mm/sparse.c | 6 ++++--
mm/util.c | 5 +++--
mm/vmalloc.c | 4 +++-
5 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index c01cb9f..9a51286 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -22,6 +22,7 @@
#include <linux/swap.h>
#include <linux/swapops.h>
#include <linux/page-isolation.h>
+#include <linux/compiler.h>
#include <asm/page.h>
#include <asm/pgtable.h>
@@ -3446,7 +3447,7 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
#else /* !CONFIG_ARCH_WANT_GENERAL_HUGETLB */
/* Can be overriden by architectures */
-__attribute__((weak)) struct page *
+__weak struct page *
follow_huge_pud(struct mm_struct *mm, unsigned long address,
pud_t *pud, int write)
{
diff --git a/mm/nommu.c b/mm/nommu.c
index 8740213..9f823ce 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -30,6 +30,7 @@
#include <linux/syscalls.h>
#include <linux/audit.h>
#include <linux/sched/sysctl.h>
+#include <linux/compiler.h>
#include <asm/uaccess.h>
#include <asm/tlb.h>
@@ -459,7 +460,7 @@ EXPORT_SYMBOL_GPL(vm_unmap_aliases);
* Implement a stub for vmalloc_sync_all() if the architecture chose not to
* have one.
*/
-void __attribute__((weak)) vmalloc_sync_all(void)
+void __weak vmalloc_sync_all(void)
{
}
diff --git a/mm/sparse.c b/mm/sparse.c
index 63c3ea5..8cb4bad 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -9,6 +9,8 @@
#include <linux/export.h>
#include <linux/spinlock.h>
#include <linux/vmalloc.h>
+#include <linux/compiler.h>
+
#include "internal.h"
#include <asm/dma.h>
#include <asm/pgalloc.h>
@@ -459,9 +461,9 @@ static struct page __init *sparse_early_mem_map_alloc(unsigned long pnum)
ms->section_mem_map = 0;
return NULL;
}
-#endif
+endif
-void __attribute__((weak)) __meminit vmemmap_populate_print_last(void)
+void __weak __meminit vmemmap_populate_print_last(void)
{
}
diff --git a/mm/util.c b/mm/util.c
index a24aa22..992b7d4 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -9,6 +9,7 @@
#include <linux/swapops.h>
#include <linux/mman.h>
#include <linux/hugetlb.h>
+#include <linux/compiler.h>
#include <asm/uaccess.h>
@@ -307,7 +308,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
* If the architecture not support this function, simply return with no
* page pinned
*/
-int __attribute__((weak)) __get_user_pages_fast(unsigned long start,
+int __weak __get_user_pages_fast(unsigned long start,
int nr_pages, int write, struct page **pages)
{
return 0;
@@ -338,7 +339,7 @@ EXPORT_SYMBOL_GPL(__get_user_pages_fast);
* callers need to carefully consider what to use. On many architectures,
* get_user_pages_fast simply falls back to get_user_pages.
*/
-int __attribute__((weak)) get_user_pages_fast(unsigned long start,
+int __weak get_user_pages_fast(unsigned long start,
int nr_pages, int write, struct page **pages)
{
struct mm_struct *mm = current->mm;
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 0fdf968..7be0a1a 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -28,6 +28,8 @@
#include <linux/kmemleak.h>
#include <linux/atomic.h>
#include <linux/llist.h>
+#include <linux/compiler.h>
+
#include <asm/uaccess.h>
#include <asm/tlbflush.h>
#include <asm/shmparam.h>
@@ -2181,7 +2183,7 @@ EXPORT_SYMBOL(remap_vmalloc_range);
* Implement a stub for vmalloc_sync_all() if the architecture chose not to
* have one.
*/
-void __attribute__((weak)) vmalloc_sync_all(void)
+void __weak vmalloc_sync_all(void)
{
}
--
1.8.5.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] mm: use macros from compiler.h instead of __attribute__((...))
2014-03-01 16:02 ` [PATCH 1/1] mm: use macros from compiler.h instead of __attribute__((...)) Gideon Israel Dsouza
@ 2014-03-01 17:38 ` Geert Uytterhoeven
0 siblings, 0 replies; 6+ messages in thread
From: Geert Uytterhoeven @ 2014-03-01 17:38 UTC (permalink / raw)
To: Gideon Israel Dsouza; +Cc: Andrew Morton, Linux MM, linux-kernel
On Sat, Mar 1, 2014 at 5:02 PM, Gideon Israel Dsouza
<gidisrael@gmail.com> wrote:
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -9,6 +9,8 @@
> #include <linux/export.h>
> #include <linux/spinlock.h>
> #include <linux/vmalloc.h>
> +#include <linux/compiler.h>
Please try to insert new includes in alphabetical order, to avoid
merge conflicts.
It's no always easy, as lots of include lists are not sorted at all.
> +
> #include "internal.h"
> #include <asm/dma.h>
> #include <asm/pgalloc.h>
> @@ -459,9 +461,9 @@ static struct page __init *sparse_early_mem_map_alloc(unsigned long pnum)
> ms->section_mem_map = 0;
> return NULL;
> }
> -#endif
> +endif
Woops, this won't compile?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] mm: use macros from compiler.h instead of __attribute__((...))
2014-03-04 21:26 ` Andrew Morton
@ 2014-03-04 23:27 ` Stephen Rothwell
0 siblings, 0 replies; 6+ messages in thread
From: Stephen Rothwell @ 2014-03-04 23:27 UTC (permalink / raw)
To: Andrew Morton; +Cc: Gideon Israel Dsouza, linux-mm, linux-kernel, geert
[-- Attachment #1: Type: text/plain, Size: 963 bytes --]
Hi Andrew,
On Tue, 4 Mar 2014 13:26:04 -0800 Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Sun, 2 Mar 2014 19:09:58 +0530 Gideon Israel Dsouza <gidisrael@gmail.com> wrote:
>
> > To increase compiler portability there is <linux/compiler.h> which
> > provides convenience macros for various gcc constructs. Eg: __weak
> > for __attribute__((weak)). I've replaced all instances of gcc
> > attributes with the right macro in the memory management
> > (/mm) subsystem.
> >
> > ...
> >
> > --- a/mm/hugetlb.c
> > +++ b/mm/hugetlb.c
> > @@ -13,6 +13,7 @@
> > #include <linux/nodemask.h>
> > #include <linux/pagemap.h>
> > #include <linux/mempolicy.h>
> > +#include <linux/compiler.h>
>
> It may be overdoing things a bit to explicitly include compiler.h.
> It's hard to conceive of any .c file which doesn't already include it.
Stick to Rule 1 :-)
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] mm: use macros from compiler.h instead of __attribute__((...))
2014-03-02 13:39 ` [PATCH 1/1] mm: use macros from compiler.h instead of __attribute__((...)) Gideon Israel Dsouza
@ 2014-03-04 21:26 ` Andrew Morton
2014-03-04 23:27 ` Stephen Rothwell
0 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2014-03-04 21:26 UTC (permalink / raw)
To: Gideon Israel Dsouza; +Cc: linux-mm, linux-kernel, geert
On Sun, 2 Mar 2014 19:09:58 +0530 Gideon Israel Dsouza <gidisrael@gmail.com> wrote:
> To increase compiler portability there is <linux/compiler.h> which
> provides convenience macros for various gcc constructs. Eg: __weak
> for __attribute__((weak)). I've replaced all instances of gcc
> attributes with the right macro in the memory management
> (/mm) subsystem.
>
> ...
>
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -13,6 +13,7 @@
> #include <linux/nodemask.h>
> #include <linux/pagemap.h>
> #include <linux/mempolicy.h>
> +#include <linux/compiler.h>
It may be overdoing things a bit to explicitly include compiler.h.
It's hard to conceive of any .c file which doesn't already include it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/1] mm: use macros from compiler.h instead of __attribute__((...))
2014-03-02 13:39 [PATCH 0/1] mm: Use macros from compiler.h instead of gcc specific attribute Gideon Israel Dsouza
@ 2014-03-02 13:39 ` Gideon Israel Dsouza
2014-03-04 21:26 ` Andrew Morton
0 siblings, 1 reply; 6+ messages in thread
From: Gideon Israel Dsouza @ 2014-03-02 13:39 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, linux-kernel, geert, Gideon Israel Dsouza
To increase compiler portability there is <linux/compiler.h> which
provides convenience macros for various gcc constructs. Eg: __weak
for __attribute__((weak)). I've replaced all instances of gcc
attributes with the right macro in the memory management
(/mm) subsystem.
Signed-off-by: Gideon Israel Dsouza <gidisrael@gmail.com>
---
mm/hugetlb.c | 3 ++-
mm/nommu.c | 3 ++-
mm/sparse.c | 4 +++-
mm/util.c | 5 +++--
mm/vmalloc.c | 4 +++-
5 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index c01cb9f..2870e19 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -13,6 +13,7 @@
#include <linux/nodemask.h>
#include <linux/pagemap.h>
#include <linux/mempolicy.h>
+#include <linux/compiler.h>
#include <linux/cpuset.h>
#include <linux/mutex.h>
#include <linux/bootmem.h>
@@ -3446,7 +3447,7 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
#else /* !CONFIG_ARCH_WANT_GENERAL_HUGETLB */
/* Can be overriden by architectures */
-__attribute__((weak)) struct page *
+__weak struct page *
follow_huge_pud(struct mm_struct *mm, unsigned long address,
pud_t *pud, int write)
{
diff --git a/mm/nommu.c b/mm/nommu.c
index 8740213..6556792 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -24,6 +24,7 @@
#include <linux/vmalloc.h>
#include <linux/blkdev.h>
#include <linux/backing-dev.h>
+#include <linux/compiler.h>
#include <linux/mount.h>
#include <linux/personality.h>
#include <linux/security.h>
@@ -459,7 +460,7 @@ EXPORT_SYMBOL_GPL(vm_unmap_aliases);
* Implement a stub for vmalloc_sync_all() if the architecture chose not to
* have one.
*/
-void __attribute__((weak)) vmalloc_sync_all(void)
+void __weak vmalloc_sync_all(void)
{
}
diff --git a/mm/sparse.c b/mm/sparse.c
index 63c3ea5..68ad7da 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -5,10 +5,12 @@
#include <linux/slab.h>
#include <linux/mmzone.h>
#include <linux/bootmem.h>
+#include <linux/compiler.h>
#include <linux/highmem.h>
#include <linux/export.h>
#include <linux/spinlock.h>
#include <linux/vmalloc.h>
+
#include "internal.h"
#include <asm/dma.h>
#include <asm/pgalloc.h>
@@ -461,7 +463,7 @@ static struct page __init *sparse_early_mem_map_alloc(unsigned long pnum)
}
#endif
-void __attribute__((weak)) __meminit vmemmap_populate_print_last(void)
+void __weak __meminit vmemmap_populate_print_last(void)
{
}
diff --git a/mm/util.c b/mm/util.c
index a24aa22..d7813e6 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -1,6 +1,7 @@
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/string.h>
+#include <linux/compiler.h>
#include <linux/export.h>
#include <linux/err.h>
#include <linux/sched.h>
@@ -307,7 +308,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
* If the architecture not support this function, simply return with no
* page pinned
*/
-int __attribute__((weak)) __get_user_pages_fast(unsigned long start,
+int __weak __get_user_pages_fast(unsigned long start,
int nr_pages, int write, struct page **pages)
{
return 0;
@@ -338,7 +339,7 @@ EXPORT_SYMBOL_GPL(__get_user_pages_fast);
* callers need to carefully consider what to use. On many architectures,
* get_user_pages_fast simply falls back to get_user_pages.
*/
-int __attribute__((weak)) get_user_pages_fast(unsigned long start,
+int __weak get_user_pages_fast(unsigned long start,
int nr_pages, int write, struct page **pages)
{
struct mm_struct *mm = current->mm;
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 0fdf968..a7b522f 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -27,7 +27,9 @@
#include <linux/pfn.h>
#include <linux/kmemleak.h>
#include <linux/atomic.h>
+#include <linux/compiler.h>
#include <linux/llist.h>
+
#include <asm/uaccess.h>
#include <asm/tlbflush.h>
#include <asm/shmparam.h>
@@ -2181,7 +2183,7 @@ EXPORT_SYMBOL(remap_vmalloc_range);
* Implement a stub for vmalloc_sync_all() if the architecture chose not to
* have one.
*/
-void __attribute__((weak)) vmalloc_sync_all(void)
+void __weak vmalloc_sync_all(void)
{
}
--
1.8.5.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-03-04 23:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-01 16:02 [PATCH 0/1] Use macros from compiler.h instead of gcc specific attributes Gideon Israel Dsouza
2014-03-01 16:02 ` [PATCH 1/1] mm: use macros from compiler.h instead of __attribute__((...)) Gideon Israel Dsouza
2014-03-01 17:38 ` Geert Uytterhoeven
2014-03-02 13:39 [PATCH 0/1] mm: Use macros from compiler.h instead of gcc specific attribute Gideon Israel Dsouza
2014-03-02 13:39 ` [PATCH 1/1] mm: use macros from compiler.h instead of __attribute__((...)) Gideon Israel Dsouza
2014-03-04 21:26 ` Andrew Morton
2014-03-04 23:27 ` Stephen Rothwell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).