* [PATCH 0/4] improve -m32/-m64
@ 2017-02-07 20:04 Luc Van Oostenryck
2017-02-07 20:04 ` [PATCH 1/4] define __LP64__ & _LP64 if arch_m64 is enabled Luc Van Oostenryck
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Luc Van Oostenryck @ 2017-02-07 20:04 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck
This series aims to make -m32/-m64 more useful and
to extend these flags to also support LLP64 model.
- patch 1 & 3 are quite straightforward.
- patch 2 is more code reorg/preparatory step
- patch 4 add support for LLP64 and is more a RFC
Luc Van Oostenryck (4):
define __LP64__ & _LP64 if arch_m64 is enabled
add an helper for common predefined macros
define __LONG_MAX__ & __SIZEOF_POINTER__
add support for LLP64 arch
lib.c | 45 ++++++++++++++++++++++++++++++++++++---------
1 file changed, 36 insertions(+), 9 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/4] define __LP64__ & _LP64 if arch_m64 is enabled
2017-02-07 20:04 [PATCH 0/4] improve -m32/-m64 Luc Van Oostenryck
@ 2017-02-07 20:04 ` Luc Van Oostenryck
2017-02-07 20:04 ` [PATCH 2/4] add an helper for common predefined macros Luc Van Oostenryck
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Luc Van Oostenryck @ 2017-02-07 20:04 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck
They're part of GCC's common predefined macros and some
code & header files depend on them.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
lib.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib.c b/lib.c
index 3abc3e64b..3996c5673 100644
--- a/lib.c
+++ b/lib.c
@@ -406,6 +406,8 @@ 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 __LP64__ 1\n");
+ add_pre_buffer("#weak_define _LP64 1\n");
#ifdef __x86_64__
add_pre_buffer("#weak_define __x86_64__ 1\n");
#endif
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/4] add an helper for common predefined macros
2017-02-07 20:04 [PATCH 0/4] improve -m32/-m64 Luc Van Oostenryck
2017-02-07 20:04 ` [PATCH 1/4] define __LP64__ & _LP64 if arch_m64 is enabled Luc Van Oostenryck
@ 2017-02-07 20:04 ` Luc Van Oostenryck
2017-02-07 20:04 ` [PATCH 3/4] define __LONG_MAX__ & __SIZEOF_POINTER__ Luc Van Oostenryck
2017-02-07 20:04 ` [RFC,PATCH 4/4] add support for LLP64 arch Luc Van Oostenryck
3 siblings, 0 replies; 9+ messages in thread
From: Luc Van Oostenryck @ 2017-02-07 20:04 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck
Eventually, most of what GCC predefine (gcc -E -dM)
should be defined here.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
lib.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib.c b/lib.c
index 3996c5673..018fa145e 100644
--- a/lib.c
+++ b/lib.c
@@ -802,6 +802,11 @@ static char **handle_switch(char *arg, char **next)
return next;
}
+static void predefined_macros(void)
+{
+ add_pre_buffer("#define __CHECKER__ 1\n");
+}
+
void declare_builtin_functions(void)
{
/* Gaah. gcc knows tons of builtin <string.h> functions */
@@ -1154,7 +1159,7 @@ struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list
init_ctype();
create_builtin_stream();
- add_pre_buffer("#define __CHECKER__ 1\n");
+ predefined_macros();
if (!preprocess_only)
declare_builtin_functions();
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/4] define __LONG_MAX__ & __SIZEOF_POINTER__
2017-02-07 20:04 [PATCH 0/4] improve -m32/-m64 Luc Van Oostenryck
2017-02-07 20:04 ` [PATCH 1/4] define __LP64__ & _LP64 if arch_m64 is enabled Luc Van Oostenryck
2017-02-07 20:04 ` [PATCH 2/4] add an helper for common predefined macros Luc Van Oostenryck
@ 2017-02-07 20:04 ` Luc Van Oostenryck
2017-02-07 20:04 ` [RFC,PATCH 4/4] add support for LLP64 arch Luc Van Oostenryck
3 siblings, 0 replies; 9+ messages in thread
From: Luc Van Oostenryck @ 2017-02-07 20:04 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck
They're part of GCC's common predefined macros and some
code & header files depends on them.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
lib.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib.c b/lib.c
index 018fa145e..2a1bbac87 100644
--- a/lib.c
+++ b/lib.c
@@ -804,7 +804,13 @@ static char **handle_switch(char *arg, char **next)
static void predefined_macros(void)
{
+ unsigned long long val;
+
add_pre_buffer("#define __CHECKER__ 1\n");
+
+ val = (1ULL << (bits_in_long-1)) - 1;
+ add_pre_buffer("#weak_define __LONG_MAX__ %#llxLL\n", val);
+ add_pre_buffer("#weak_define __SIZEOF_POINTER__ %d\n", bits_in_pointer/8);
}
void declare_builtin_functions(void)
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [RFC,PATCH 4/4] add support for LLP64 arch
2017-02-07 20:04 [PATCH 0/4] improve -m32/-m64 Luc Van Oostenryck
` (2 preceding siblings ...)
2017-02-07 20:04 ` [PATCH 3/4] define __LONG_MAX__ & __SIZEOF_POINTER__ Luc Van Oostenryck
@ 2017-02-07 20:04 ` Luc Van Oostenryck
2017-02-08 21:24 ` Christopher Li
3 siblings, 1 reply; 9+ messages in thread
From: Luc Van Oostenryck @ 2017-02-07 20:04 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck, Dibyendu Majumdar
There was recently on the mailing list some questions
and a need to support LLP64 model.
This patch add is by adjusting a few size-related variables
under the control of a new flag: -msize-llp64 (ugly name
but we already have we have '-msize-long').
CC: Dibyendu Majumdar <mobile@majumdar.org.uk>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
lib.c | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/lib.c b/lib.c
index 2a1bbac87..6e740839c 100644
--- a/lib.c
+++ b/lib.c
@@ -257,10 +257,14 @@ static enum { STANDARD_C89,
STANDARD_GNU89,
STANDARD_GNU99, } standard = STANDARD_GNU89;
+#define ARCH_LP32 0
+#define ARCH_LP64 1
+#define ARCH_LLP64 2
+
#ifdef __x86_64__
-#define ARCH_M64_DEFAULT 1
+#define ARCH_M64_DEFAULT ARCH_LP64
#else
-#define ARCH_M64_DEFAULT 0
+#define ARCH_M64_DEFAULT ARCH_LP32
#endif
int arch_m64 = ARCH_M64_DEFAULT;
@@ -387,9 +391,11 @@ static char **handle_multiarch_dir(char *arg, char **next)
static char **handle_switch_m(char *arg, char **next)
{
if (!strcmp(arg, "m64")) {
- arch_m64 = 1;
+ arch_m64 = ARCH_LP64;
} else if (!strcmp(arg, "m32")) {
- arch_m64 = 0;
+ arch_m64 = ARCH_LP32;
+ } else if (!strcmp(arg, "msize-llp64")) {
+ arch_m64 = ARCH_LLP64;
} else if (!strcmp(arg, "msize-long")) {
arch_msize_long = 1;
} else if (!strcmp(arg, "multiarch-dir"))
@@ -400,14 +406,22 @@ static char **handle_switch_m(char *arg, char **next)
static void handle_arch_m64_finalize(void)
{
if (arch_m64) {
- bits_in_long = 64;
- max_int_alignment = 8;
bits_in_pointer = 64;
pointer_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");
+ if (arch_m64 == ARCH_LP64) {
+ bits_in_long = 64;
+ 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");
+ } else {
+ bits_in_long = 32;
+ max_int_alignment = 4;
+ size_t_ctype = &ullong_ctype;
+ ssize_t_ctype = &llong_ctype;
+ add_pre_buffer("#weak_define __LLP64__ 1\n");
+ }
#ifdef __x86_64__
add_pre_buffer("#weak_define __x86_64__ 1\n");
#endif
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [RFC,PATCH 4/4] add support for LLP64 arch
2017-02-07 20:04 ` [RFC,PATCH 4/4] add support for LLP64 arch Luc Van Oostenryck
@ 2017-02-08 21:24 ` Christopher Li
2017-02-08 22:01 ` Luc Van Oostenryck
2017-02-08 22:15 ` [PATCH v2] " Luc Van Oostenryck
0 siblings, 2 replies; 9+ messages in thread
From: Christopher Li @ 2017-02-08 21:24 UTC (permalink / raw)
To: Luc Van Oostenryck; +Cc: Linux-Sparse, Dibyendu Majumdar
The patch as already apply in sparse-next.
On Wed, Feb 8, 2017 at 4:04 AM, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> There was recently on the mailing list some questions
> and a need to support LLP64 model.
>
> This patch add is by adjusting a few size-related variables
> under the control of a new flag: -msize-llp64 (ugly name
> but we already have we have '-msize-long').
I am wondering how does gcc windows handle such situation.
Should we some flag some arch thing like "mingw64" which
turn on the LLP64 mode. If gcc has such a flag for cross compile
mingw, we should borrow that instead.
]> + if (arch_m64 == ARCH_LP64) {
> + bits_in_long = 64;
> + 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");
> + } else {
It works as it is. But we might want to test against arch_m64==ARCH_LLP64
just to make the code section clear what it was for.
Again, ff there is a new version of patch. I will replace this one in
sparse-next.
Chris
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [RFC,PATCH 4/4] add support for LLP64 arch
2017-02-08 21:24 ` Christopher Li
@ 2017-02-08 22:01 ` Luc Van Oostenryck
2017-02-08 22:15 ` [PATCH v2] " Luc Van Oostenryck
1 sibling, 0 replies; 9+ messages in thread
From: Luc Van Oostenryck @ 2017-02-08 22:01 UTC (permalink / raw)
To: Christopher Li; +Cc: Linux-Sparse, Dibyendu Majumdar
On Thu, Feb 09, 2017 at 05:24:01AM +0800, Christopher Li wrote:
> The patch as already apply in sparse-next.
>
> On Wed, Feb 8, 2017 at 4:04 AM, Luc Van Oostenryck
> <luc.vanoostenryck@gmail.com> wrote:
> > There was recently on the mailing list some questions
> > and a need to support LLP64 model.
> >
> > This patch add is by adjusting a few size-related variables
> > under the control of a new flag: -msize-llp64 (ugly name
> > but we already have we have '-msize-long').
>
> I am wondering how does gcc windows handle such situation.
>
> Should we some flag some arch thing like "mingw64" which
> turn on the LLP64 mode. If gcc has such a flag for cross compile
> mingw, we should borrow that instead.
Well, I suppose GCC is configured for MinGW at build time (and
I understood that cygwin on x86-64 is LP64).
Anyway, I don't any kind of option in GCC that would correspond
to this.
I propose to leave it as such or to simply drop this patch as
I'm planning to change somewhat this part anyway (essentially
because 99% of the time I'm doing cross-compile development
and the current situation doesn't suit me at all. And when
hacking on sparse, I'm much much more interested in the output
of test-linearize than sparse in itself, so cgcc is useless
for me. This serie is just the minimal to make my live easier and
this LLP64 is just something closely related someone had a need for).
> ]> + if (arch_m64 == ARCH_LP64) {
> > + bits_in_long = 64;
> > + 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");
> > + } else {
>
> It works as it is. But we might want to test against arch_m64==ARCH_LLP64
> just to make the code section clear what it was for.
>
> Again, ff there is a new version of patch. I will replace this one in
> sparse-next.
>
> Chris
Yes, it was what I wanted to do first but then I realised it will hardly
be a third choice and so I did it this way.
A new version is coming.
Luc
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2] add support for LLP64 arch
2017-02-08 21:24 ` Christopher Li
2017-02-08 22:01 ` Luc Van Oostenryck
@ 2017-02-08 22:15 ` Luc Van Oostenryck
2017-02-08 22:33 ` Christopher Li
1 sibling, 1 reply; 9+ messages in thread
From: Luc Van Oostenryck @ 2017-02-08 22:15 UTC (permalink / raw)
To: linux-sparse; +Cc: Christopher Li, Luc Van Oostenryck, Dibyendu Majumdar
There was recently on the mailing list some questions
and a need to support LLP64 model.
This patch add is by adjusting a few size-related variables
under the control of a new flag: -msize-llp64 (ugly name
but we already have we have '-msize-long').
CC: Dibyendu Majumdar <mobile@majumdar.org.uk>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
lib.c | 34 +++++++++++++++++++++++++++-------
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/lib.c b/lib.c
index 2a1bbac87..467e040be 100644
--- a/lib.c
+++ b/lib.c
@@ -257,10 +257,14 @@ static enum { STANDARD_C89,
STANDARD_GNU89,
STANDARD_GNU99, } standard = STANDARD_GNU89;
+#define ARCH_LP32 0
+#define ARCH_LP64 1
+#define ARCH_LLP64 2
+
#ifdef __x86_64__
-#define ARCH_M64_DEFAULT 1
+#define ARCH_M64_DEFAULT ARCH_LP64
#else
-#define ARCH_M64_DEFAULT 0
+#define ARCH_M64_DEFAULT ARCH_LP32
#endif
int arch_m64 = ARCH_M64_DEFAULT;
@@ -387,9 +391,11 @@ static char **handle_multiarch_dir(char *arg, char **next)
static char **handle_switch_m(char *arg, char **next)
{
if (!strcmp(arg, "m64")) {
- arch_m64 = 1;
+ arch_m64 = ARCH_LP64;
} else if (!strcmp(arg, "m32")) {
- arch_m64 = 0;
+ arch_m64 = ARCH_LP32;
+ } else if (!strcmp(arg, "msize-llp64")) {
+ arch_m64 = ARCH_LLP64;
} else if (!strcmp(arg, "msize-long")) {
arch_msize_long = 1;
} else if (!strcmp(arg, "multiarch-dir"))
@@ -399,18 +405,32 @@ static char **handle_switch_m(char *arg, char **next)
static void handle_arch_m64_finalize(void)
{
- if (arch_m64) {
+ switch (arch_m64) {
+ case ARCH_LP32:
+ /* default values */
+ return;
+ case ARCH_LP64:
bits_in_long = 64;
max_int_alignment = 8;
- bits_in_pointer = 64;
- pointer_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");
+ goto case_64bit_common;
+ case ARCH_LLP64:
+ bits_in_long = 32;
+ max_int_alignment = 4;
+ size_t_ctype = &ullong_ctype;
+ ssize_t_ctype = &llong_ctype;
+ add_pre_buffer("#weak_define __LLP64__ 1\n");
+ goto case_64bit_common;
+ case_64bit_common:
+ bits_in_pointer = 64;
+ pointer_alignment = 8;
#ifdef __x86_64__
add_pre_buffer("#weak_define __x86_64__ 1\n");
#endif
+ break;
}
}
--
2.11.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2] add support for LLP64 arch
2017-02-08 22:15 ` [PATCH v2] " Luc Van Oostenryck
@ 2017-02-08 22:33 ` Christopher Li
0 siblings, 0 replies; 9+ messages in thread
From: Christopher Li @ 2017-02-08 22:33 UTC (permalink / raw)
To: Luc Van Oostenryck; +Cc: Linux-Sparse, Dibyendu Majumdar
On Thu, Feb 9, 2017 at 6:15 AM, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> There was recently on the mailing list some questions
> and a need to support LLP64 model.
>
> This patch add is by adjusting a few size-related variables
> under the control of a new flag: -msize-llp64 (ugly name
> but we already have we have '-msize-long').
That looks much better. Applied on sparse-next.
Thanks
Chris
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-02-08 23:02 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-07 20:04 [PATCH 0/4] improve -m32/-m64 Luc Van Oostenryck
2017-02-07 20:04 ` [PATCH 1/4] define __LP64__ & _LP64 if arch_m64 is enabled Luc Van Oostenryck
2017-02-07 20:04 ` [PATCH 2/4] add an helper for common predefined macros Luc Van Oostenryck
2017-02-07 20:04 ` [PATCH 3/4] define __LONG_MAX__ & __SIZEOF_POINTER__ Luc Van Oostenryck
2017-02-07 20:04 ` [RFC,PATCH 4/4] add support for LLP64 arch Luc Van Oostenryck
2017-02-08 21:24 ` Christopher Li
2017-02-08 22:01 ` Luc Van Oostenryck
2017-02-08 22:15 ` [PATCH v2] " Luc Van Oostenryck
2017-02-08 22:33 ` Christopher Li
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).