public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: libc-alpha@sourceware.org
Subject: [PATCH 1/3] x86-64: Move LP_SIZE definition to its own header
Date: Thu, 13 Oct 2022 14:20:35 +0200	[thread overview]
Message-ID: <350d9d552bc44b1df01e567135ff9eed4569164f.1665663395.git.fweimer@redhat.com> (raw)
In-Reply-To: <cover.1665663395.git.fweimer@redhat.com>

This way, we can define the pointer guard macros without including
<sysdep.h> on x86-64.  Other architectures will not have such an
inclusion dependency, and the implied header file inclusion would
create a porting hazard.
---
 sysdeps/x86_64/sysdep.h          |  7 +------
 sysdeps/x86_64/x32/sysdep.h      |  6 +-----
 sysdeps/x86_64/x32/x86-lp_size.h | 23 +++++++++++++++++++++++
 sysdeps/x86_64/x86-lp_size.h     | 23 +++++++++++++++++++++++
 4 files changed, 48 insertions(+), 11 deletions(-)
 create mode 100644 sysdeps/x86_64/x32/x86-lp_size.h
 create mode 100644 sysdeps/x86_64/x86-lp_size.h

diff --git a/sysdeps/x86_64/sysdep.h b/sysdeps/x86_64/sysdep.h
index 7f5defa4ec..d1a43dc14c 100644
--- a/sysdeps/x86_64/sysdep.h
+++ b/sysdeps/x86_64/sysdep.h
@@ -20,6 +20,7 @@
 #define _X86_64_SYSDEP_H 1
 
 #include <sysdeps/x86/sysdep.h>
+#include <x86-lp_size.h>
 
 #ifdef	__ASSEMBLER__
 
@@ -68,9 +69,6 @@ lose:									      \
 # define JUMPTARGET(name)	name
 #endif
 
-/* Long and pointer size in bytes.  */
-#define LP_SIZE	8
-
 /* Instruction to operate on long and pointer.  */
 #define LP_OP(insn) insn##q
 
@@ -137,9 +135,6 @@ lose:									      \
 
 #else	/* __ASSEMBLER__ */
 
-/* Long and pointer size in bytes.  */
-#define LP_SIZE "8"
-
 /* Instruction to operate on long and pointer.  */
 #define LP_OP(insn) #insn "q"
 
diff --git a/sysdeps/x86_64/x32/sysdep.h b/sysdeps/x86_64/x32/sysdep.h
index 645ea4ae69..92d987780d 100644
--- a/sysdeps/x86_64/x32/sysdep.h
+++ b/sysdeps/x86_64/x32/sysdep.h
@@ -17,8 +17,8 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <sysdeps/x86_64/sysdep.h>
+#include <x86-lp_size.h>
 
-#undef LP_SIZE
 #undef LP_OP
 #undef ASM_ADDR
 
@@ -41,8 +41,6 @@
 
 #ifdef	__ASSEMBLER__
 
-# define LP_SIZE 4
-
 # define LP_OP(insn) insn##l
 
 # define ASM_ADDR .long
@@ -66,8 +64,6 @@
 
 #else	/* __ASSEMBLER__ */
 
-# define LP_SIZE "4"
-
 # define LP_OP(insn) #insn "l"
 
 # define ASM_ADDR ".long"
diff --git a/sysdeps/x86_64/x32/x86-lp_size.h b/sysdeps/x86_64/x32/x86-lp_size.h
new file mode 100644
index 0000000000..ad03eb66b2
--- /dev/null
+++ b/sysdeps/x86_64/x32/x86-lp_size.h
@@ -0,0 +1,23 @@
+/* Pointer size definition for x86-64 x42.
+   Copyright (C) 2022 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifdef __ASSEMBLER__
+# define LP_SIZE 4
+#else
+# define LP_SIZE "4"
+#endif
diff --git a/sysdeps/x86_64/x86-lp_size.h b/sysdeps/x86_64/x86-lp_size.h
new file mode 100644
index 0000000000..76877240e8
--- /dev/null
+++ b/sysdeps/x86_64/x86-lp_size.h
@@ -0,0 +1,23 @@
+/* Pointer size definition for x86-64.
+   Copyright (C) 2022 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifdef __ASSEMBLER__
+# define LP_SIZE 8
+#else
+# define LP_SIZE "8"
+#endif
-- 
2.37.3



  reply	other threads:[~2022-10-13 12:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13 12:20 [PATCH 0/3] PTR_MANGLE/PTR_DEMANGLE refactoring Florian Weimer
2022-10-13 12:20 ` Florian Weimer [this message]
2022-10-17 16:03   ` [PATCH 1/3] x86-64: Move LP_SIZE definition to its own header Adhemerval Zanella Netto
2022-10-13 12:20 ` [PATCH 2/3] Introduce <pointer_guard.h>, extracted from <sysdep.h> Florian Weimer
2022-10-14  3:30   ` DJ Delorie
2022-10-14  8:14     ` Florian Weimer
2022-10-17 16:13   ` Adhemerval Zanella Netto
2022-10-18 15:03     ` Florian Weimer
2022-10-13 12:20 ` [PATCH 3/3] Use PTR_MANGLE and PTR_DEMANGLE unconditionally in C sources Florian Weimer
2022-10-17 16:15   ` Adhemerval Zanella Netto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=350d9d552bc44b1df01e567135ff9eed4569164f.1665663395.git.fweimer@redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).