Re: [PATCH v2 4/7] builtin: directly predefine builtin macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 08/06/18 17:44, Luc Van Oostenryck wrote:
> Use the newly created predefine()/predefinef() to

predefinef() is no more.

> define the builtin macros.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> ---
>  lib.c | 83 ++++++++++++++++++++++++++++++++---------------------------
>  1 file changed, 45 insertions(+), 38 deletions(-)
> 
> diff --git a/lib.c b/lib.c
> index 30d1cf6d1..ae7508e05 100644
> --- a/lib.c
> +++ b/lib.c
> @@ -477,8 +477,8 @@ static void handle_arch_m64_finalize(void)
>  	switch (arch_m64) {
>  	case ARCH_X32:
>  		max_int_alignment = 8;
> -		add_pre_buffer("#weak_define __ILP32__ 1\n");
> -		add_pre_buffer("#weak_define _ILP32 1\n");
> +		predefine("__ILP32__", 1, "1");
> +		predefine("_ILP32", 1, "1");
>  		goto case_x86_64;
>  	case ARCH_LP32:
>  		/* default values */
> @@ -488,15 +488,15 @@ static void handle_arch_m64_finalize(void)
>  		max_int_alignment = 8;
>  		size_t_ctype = &ulong_ctype;
>  		ssize_t_ctype = &long_ctype;
> -		add_pre_buffer("#weak_define __LP64__ 1\n");
> -		add_pre_buffer("#weak_define _LP64 1\n");
> +		predefine("__LP64__", 1, "1");
> +		predefine("_LP64", 1, "1");
>  		goto case_64bit_common;
>  	case ARCH_LLP64:
>  		bits_in_long = 32;
>  		max_int_alignment = 8;
>  		size_t_ctype = &ullong_ctype;
>  		ssize_t_ctype = &llong_ctype;
> -		add_pre_buffer("#weak_define __LLP64__ 1\n");
> +		predefine("__LLP64__", 1, "1");
>  		goto case_64bit_common;
>  	case_64bit_common:
>  		bits_in_pointer = 64;
> @@ -504,8 +504,8 @@ static void handle_arch_m64_finalize(void)
>  		/* fall through */
>  	case_x86_64:
>  #if defined(__x86_64__) || defined(__x86_64)
> -		add_pre_buffer("#weak_define __x86_64__ 1\n");
> -		add_pre_buffer("#weak_define __x86_64   1\n");
> +		predefine("__x86_64__", 1, "1");
> +		predefine("__x86_64", 1, "1");
>  #endif
>  		break;
>  	}
> @@ -1111,14 +1111,19 @@ static char **handle_switch(char *arg, char **next)
>  
>  static void predefined_sizeof(const char *name, unsigned bits)
>  {
> -	add_pre_buffer("#weak_define __SIZEOF_%s__ %d\n", name, bits/8);
> +	char buf[32];
> +
> +	snprintf(buf, sizeof(buf), "__SIZEOF_%s__", name);
> +	predefine(buf, 1, "%d", bits/8);

$ gcc -dM -E - </dev/null | grep SIZEOF | cut -d' ' -f2 | awk 'length($1) >  max { max = length($1); maxline = $0 } END { print max, maxline }'
22 __SIZEOF_LONG_DOUBLE__
$ 

OK.

>  }
>  
>  static void predefined_max(const char *name, const char *suffix, unsigned bits)
>  {
>  	unsigned long long max = (1ULL << (bits - 1 )) - 1;
> +	char buf[32];
>  
> -	add_pre_buffer("#weak_define __%s_MAX__ %#llx%s\n", name, max, suffix);
> +	snprintf(buf, sizeof(buf), "__%s_MAX__", name);
> +	predefine(buf, 1, "%#llx%s", max, suffix);

$ gcc -dM -E - </dev/null | grep MAX | cut -d' ' -f2 | awk 'length($1) >  max { max = length($1); maxline = $0 } END { print max, maxline }'
20 __UINT_LEAST16_MAX__
$ 

OK.

ATB,
Ramsay Jones
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux