Continuing from this commit: 
52f5684c8e1e
("kernel: use macros from compiler.h instead of __attribute__((...))")
I submitted 4 total patches. They are part of task I've taken up to
increase compiler portability in the kernel. I've cleaned up the
subsystems under /kernel /mm /block and /security, this patch targets
/crypto.
There is <linux/compiler.h> which provides macros for various gcc specific
constructs. Eg: __weak for __attribute__((weak)). I've cleaned all
instances of gcc specific attributes with the right macros for the crypto
subsystem.
I had to make one additional change into compiler-gcc.h for the case when
one wants to use this: __attribute__((aligned) and not specify an alignment
factor. From the gcc docs, this will result in the largest alignment for
that data type on the target machine so I've named the macro
__aligned_largest. Please advise if another name is more appropriate.
Signed-off-by: Gideon Israel Dsouza <gidisrael@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
 #include <linux/slab.h>
 #include <linux/seq_file.h>
 #include <linux/cryptouser.h>
+#include <linux/compiler.h>
 #include <net/netlink.h>
 
 #include <crypto/scatterwalk.h>
 #endif
 
 static void crypto_ablkcipher_show(struct seq_file *m, struct crypto_alg *alg)
-       __attribute__ ((unused));
+       __maybe_unused;
 static void crypto_ablkcipher_show(struct seq_file *m, struct crypto_alg *alg)
 {
        struct ablkcipher_alg *ablkcipher = &alg->cra_ablkcipher;
 #endif
 
 static void crypto_givcipher_show(struct seq_file *m, struct crypto_alg *alg)
-       __attribute__ ((unused));
+       __maybe_unused;
 static void crypto_givcipher_show(struct seq_file *m, struct crypto_alg *alg)
 {
        struct ablkcipher_alg *ablkcipher = &alg->cra_ablkcipher;
 
 #include <linux/crypto.h>
 #include <crypto/algapi.h>
 #include <linux/cryptouser.h>
+#include <linux/compiler.h>
 #include <net/netlink.h>
 #include <crypto/internal/acompress.h>
 #include <crypto/internal/scompress.h>
 #endif
 
 static void crypto_acomp_show(struct seq_file *m, struct crypto_alg *alg)
-       __attribute__ ((unused));
+       __maybe_unused;
 
 static void crypto_acomp_show(struct seq_file *m, struct crypto_alg *alg)
 {
 
 #include <linux/slab.h>
 #include <linux/seq_file.h>
 #include <linux/cryptouser.h>
+#include <linux/compiler.h>
 #include <net/netlink.h>
 
 #include "internal.h"
 #endif
 
 static void crypto_aead_show(struct seq_file *m, struct crypto_alg *alg)
-       __attribute__ ((unused));
+       __maybe_unused;
 static void crypto_aead_show(struct seq_file *m, struct crypto_alg *alg)
 {
        struct aead_alg *aead = container_of(alg, struct aead_alg, base);
 
 #include <linux/slab.h>
 #include <linux/seq_file.h>
 #include <linux/cryptouser.h>
+#include <linux/compiler.h>
 #include <net/netlink.h>
 
 #include "internal.h"
 #endif
 
 static void crypto_ahash_show(struct seq_file *m, struct crypto_alg *alg)
-       __attribute__ ((unused));
+       __maybe_unused;
 static void crypto_ahash_show(struct seq_file *m, struct crypto_alg *alg)
 {
        seq_printf(m, "type         : ahash\n");
 
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/crypto.h>
+#include <linux/compiler.h>
 #include <crypto/algapi.h>
 #include <linux/cryptouser.h>
 #include <net/netlink.h>
 #endif
 
 static void crypto_akcipher_show(struct seq_file *m, struct crypto_alg *alg)
-       __attribute__ ((unused));
+       __maybe_unused;
 
 static void crypto_akcipher_show(struct seq_file *m, struct crypto_alg *alg)
 {
 
 /*
  * Block chaining cipher operations.
- * 
+ *
  * Generic encrypt/decrypt wrapper for ciphers, handles operations across
  * multiple page boundaries by using temporary blocks.  In user context,
  * the kernel is given a chance to schedule us once per page.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option) 
+ * Software Foundation; either version 2 of the License, or (at your option)
  * any later version.
  *
  */
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/cryptouser.h>
+#include <linux/compiler.h>
 #include <net/netlink.h>
 
 #include "internal.h"
 #endif
 
 static void crypto_blkcipher_show(struct seq_file *m, struct crypto_alg *alg)
-       __attribute__ ((unused));
+       __maybe_unused;
 static void crypto_blkcipher_show(struct seq_file *m, struct crypto_alg *alg)
 {
        seq_printf(m, "type         : blkcipher\n");
 
 #include <linux/scatterlist.h>
 #include <crypto/scatterwalk.h>
 #include <linux/slab.h>
+#include <linux/compiler.h>
 
 struct crypto_cts_ctx {
        struct crypto_skcipher *child;
        struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
        struct skcipher_request *subreq = &rctx->subreq;
        int bsize = crypto_skcipher_blocksize(tfm);
-       u8 d[bsize * 2] __attribute__ ((aligned(__alignof__(u32))));
+       u8 d[bsize * 2] __aligned(__alignof__(u32));
        struct scatterlist *sg;
        unsigned int offset;
        int lastn;
        struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
        struct skcipher_request *subreq = &rctx->subreq;
        int bsize = crypto_skcipher_blocksize(tfm);
-       u8 d[bsize * 2] __attribute__ ((aligned(__alignof__(u32))));
+       u8 d[bsize * 2] __aligned(__alignof__(u32));
        struct scatterlist *sg;
        unsigned int offset;
        u8 *space;
 
 #include <linux/crypto.h>
 #include <crypto/algapi.h>
 #include <linux/cryptouser.h>
+#include <linux/compiler.h>
 #include <net/netlink.h>
 #include <crypto/kpp.h>
 #include <crypto/internal/kpp.h>
 #endif
 
 static void crypto_kpp_show(struct seq_file *m, struct crypto_alg *alg)
-       __attribute__ ((unused));
+       __maybe_unused;
 
 static void crypto_kpp_show(struct seq_file *m, struct crypto_alg *alg)
 {
 
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/compiler.h>
 
 struct crypto_pcbc_ctx {
        struct crypto_cipher *child;
        unsigned int nbytes = walk->nbytes;
        u8 *src = walk->src.virt.addr;
        u8 *iv = walk->iv;
-       u8 tmpbuf[bsize] __attribute__ ((aligned(__alignof__(u32))));
+       u8 tmpbuf[bsize] __aligned(__alignof__(u32));
 
        do {
                memcpy(tmpbuf, src, bsize);
 
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/cryptouser.h>
+#include <linux/compiler.h>
 #include <net/netlink.h>
 
 #include "internal.h"
 #endif
 
 static void crypto_rng_show(struct seq_file *m, struct crypto_alg *alg)
-       __attribute__ ((unused));
+       __maybe_unused;
 static void crypto_rng_show(struct seq_file *m, struct crypto_alg *alg)
 {
        seq_printf(m, "type         : rng\n");
 
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/crypto.h>
+#include <linux/compiler.h>
 #include <linux/vmalloc.h>
 #include <crypto/algapi.h>
 #include <linux/cryptouser.h>
 #endif
 
 static void crypto_scomp_show(struct seq_file *m, struct crypto_alg *alg)
-       __attribute__ ((unused));
+       __maybe_unused;
 
 static void crypto_scomp_show(struct seq_file *m, struct crypto_alg *alg)
 {
 
 #include <linux/seq_file.h>
 #include <linux/cryptouser.h>
 #include <net/netlink.h>
+#include <linux/compiler.h>
 
 #include "internal.h"
 
 static inline unsigned int shash_align_buffer_size(unsigned len,
                                                   unsigned long mask)
 {
-       typedef u8 __attribute__ ((aligned)) u8_aligned;
+       typedef u8 __aligned_largest u8_aligned;
        return len + (mask & ~(__alignof__(u8_aligned) - 1));
 }
 
        unsigned int unaligned_len = alignmask + 1 -
                                     ((unsigned long)data & alignmask);
        u8 ubuf[shash_align_buffer_size(unaligned_len, alignmask)]
-               __attribute__ ((aligned));
+               __aligned_largest;
        u8 *buf = PTR_ALIGN(&ubuf[0], alignmask + 1);
        int err;
 
        struct shash_alg *shash = crypto_shash_alg(tfm);
        unsigned int ds = crypto_shash_digestsize(tfm);
        u8 ubuf[shash_align_buffer_size(ds, alignmask)]
-               __attribute__ ((aligned));
+               __aligned_largest;
        u8 *buf = PTR_ALIGN(&ubuf[0], alignmask + 1);
        int err;
 
 #endif
 
 static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg)
-       __attribute__ ((unused));
+       __maybe_unused;
 static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg)
 {
        struct shash_alg *salg = __crypto_shash_alg(alg);
 
 #include <crypto/scatterwalk.h>
 #include <linux/bug.h>
 #include <linux/cryptouser.h>
+#include <linux/compiler.h>
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/rtnetlink.h>
 }
 
 static void crypto_skcipher_show(struct seq_file *m, struct crypto_alg *alg)
-       __attribute__ ((unused));
+       __maybe_unused;
 static void crypto_skcipher_show(struct seq_file *m, struct crypto_alg *alg)
 {
        struct skcipher_alg *skcipher = container_of(alg, struct skcipher_alg,
 
  */
 #define __pure                 __attribute__((pure))
 #define __aligned(x)           __attribute__((aligned(x)))
+#define __aligned_largest      __attribute__((aligned))
 #define __printf(a, b)         __attribute__((format(printf, a, b)))
 #define __scanf(a, b)          __attribute__((format(scanf, a, b)))
 #define __attribute_const__    __attribute__((__const__))