All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] make -m32/-m64 more useful
@ 2016-12-07 17:38 Luc Van Oostenryck
  2017-02-07  2:28 ` Christopher Li
  0 siblings, 1 reply; 2+ messages in thread
From: Luc Van Oostenryck @ 2016-12-07 17:38 UTC (permalink / raw)
  To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck

The option -m64 to just set the size of longs & pointers to 64 bits.

This patch makes this option much more effective by:
- adding define for LONG_MAX & SIZEOF_POINTER
- define __LP64__
- let the dual option, -m32, do the same as -m64 but for 32 bit
---
 lib.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib.c b/lib.c
index d5b56b01..e5b0bb63 100644
--- a/lib.c
+++ b/lib.c
@@ -402,9 +402,21 @@ static void handle_arch_m64_finalize(void)
 		pointer_alignment = 8;
 		size_t_ctype = &ulong_ctype;
 		ssize_t_ctype = &long_ctype;
+		add_pre_buffer("#weak_define __LONG_MAX__ 0x7fffffffffffffff\n");
+		add_pre_buffer("#weak_define __SIZEOF_POINTER__ 8\n");
+		add_pre_buffer("#weak_define __LP64__ 1\n");
 #ifdef __x86_64__
 		add_pre_buffer("#weak_define __x86_64__ 1\n");
 #endif
+	} else {
+		bits_in_long = 32;
+		max_int_alignment = 4;
+		bits_in_pointer = 32;
+		pointer_alignment = 4;
+		size_t_ctype = &ulong_ctype;
+		ssize_t_ctype = &long_ctype;
+		add_pre_buffer("#weak_define __LONG_MAX__ 0x7fffffff\n");
+		add_pre_buffer("#weak_define __SIZEOF_POINTER__ 4\n");
 	}
 }
 
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] make -m32/-m64 more useful
  2016-12-07 17:38 [PATCH] make -m32/-m64 more useful Luc Van Oostenryck
@ 2017-02-07  2:28 ` Christopher Li
  0 siblings, 0 replies; 2+ messages in thread
From: Christopher Li @ 2017-02-07  2:28 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: Linux-Sparse

On Thu, Dec 8, 2016 at 1:38 AM, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> The option -m64 to just set the size of longs & pointers to 64 bits.
>
> This patch makes this option much more effective by:
> - adding define for LONG_MAX & SIZEOF_POINTER
> - define __LP64__

I like this two change.

> - let the dual option, -m32, do the same as -m64 but for 32 bit

 +               max_int_alignment = 4;
 +               bits_in_long = 32;

This a feel a bit tricky is that, those value has its initial value
in target.c. It is strange to overwrite it with the exact same value.
It will have the effect change to the init value in target.c has no
impact on the later part of the code.

Maybe remove the init value in target.c and comment it
is overwrite during the -m64 finalize if we do it this way.

Chris

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-07  2:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-07 17:38 [PATCH] make -m32/-m64 more useful Luc Van Oostenryck
2017-02-07  2:28 ` Christopher Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.