diff mbox series

[1/3] microblaze: Replace NR_syscalls macro from asm/unistd.h

Message ID 1533792466-4227-2-git-send-email-firoz.khan@linaro.org
State Superseded
Headers show
Series System call table generation support | expand

Commit Message

Firoz Khan Aug. 9, 2018, 5:27 a.m. UTC
__NR_syscalls macro holds the number of system call exist in this
architecture. This macro is currently the part of asm/unistd.h file.
We have change the value of __NR_syscalls, if we add or delete a
system call.

One of the patch in this patch series has a script which will
generate a uapi header based on syscall.tbl file. The syscall.tbl
file contains the number of system call information. So we have
two option to update __NR_syscalls value.

1. Update __NR_syscalls in asm/unistd.h manually by counting the
   no.of system calls. No need to update __NR_syscalls untill
   we either add a new system call or delete an existing system
   call.

2. We can keep this feature it above mentioned script, that'll
   count the number of syscalls and keep it in a generated file.
   In this case we don't need to explicitly update __NR_syscalls
   in asm/unistd.h file.

The 2nd option will be the recommended one. For that, I moved the
NR_syscalls macro from asm/unistd.h to uapi/asm/unistd.h. The macro
name also changed form NR_syscalls to __NR_syscalls for making the
name convention same across all architecture. While __NR_syscalls
isn't strictly part of the uapi, having it as part of the generated
header to simplifies the implementation.

Signed-off-by: Firoz Khan <firoz.khan@linaro.org>

---
 arch/microblaze/include/asm/unistd.h      | 2 --
 arch/microblaze/include/uapi/asm/unistd.h | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
1.9.1

Comments

Michal Simek Aug. 9, 2018, 6:48 a.m. UTC | #1
On 9.8.2018 07:27, Firoz Khan wrote:
> __NR_syscalls macro holds the number of system call exist in this

> architecture. This macro is currently the part of asm/unistd.h file.

> We have change the value of __NR_syscalls, if we add or delete a

> system call.

> 

> One of the patch in this patch series has a script which will

> generate a uapi header based on syscall.tbl file. The syscall.tbl

> file contains the number of system call information. So we have

> two option to update __NR_syscalls value.

> 

> 1. Update __NR_syscalls in asm/unistd.h manually by counting the

>    no.of system calls. No need to update __NR_syscalls untill

>    we either add a new system call or delete an existing system

>    call.

> 

> 2. We can keep this feature it above mentioned script, that'll

>    count the number of syscalls and keep it in a generated file.

>    In this case we don't need to explicitly update __NR_syscalls

>    in asm/unistd.h file.

> 

> The 2nd option will be the recommended one. For that, I moved the

> NR_syscalls macro from asm/unistd.h to uapi/asm/unistd.h. The macro

> name also changed form NR_syscalls to __NR_syscalls for making the

> name convention same across all architecture. While __NR_syscalls

> isn't strictly part of the uapi, having it as part of the generated

> header to simplifies the implementation.


This macro was in unistd.h in past but it was moved out because it was
causing problem with strace.

commit 40c2702a02b755e0183b702778331b351f3be20c
Author:     Michal Simek <michal.simek@xilinx.com>
AuthorDate: Mon Jul 8 09:50:24 2013 +0200
Commit:     Michal Simek <michal.simek@xilinx.com>
CommitDate: Wed Jul 10 07:32:09 2013 +0200

    microblaze: Move __NR_syscalls from uapi


That's why I don't think this is the right thing to do.
I have grepped strace and glibc and none is using this macro that's why
I think it shouldn't be exported via uapi.

Thanks,
Michal
Firoz Khan Sept. 18, 2018, 6:37 a.m. UTC | #2
On 9 August 2018 at 12:18, Michal Simek <michal.simek@xilinx.com> wrote:
> On 9.8.2018 07:27, Firoz Khan wrote:

>> __NR_syscalls macro holds the number of system call exist in this

>> architecture. This macro is currently the part of asm/unistd.h file.

>> We have change the value of __NR_syscalls, if we add or delete a

>> system call.

>>

>> One of the patch in this patch series has a script which will

>> generate a uapi header based on syscall.tbl file. The syscall.tbl

>> file contains the number of system call information. So we have

>> two option to update __NR_syscalls value.

>>

>> 1. Update __NR_syscalls in asm/unistd.h manually by counting the

>>    no.of system calls. No need to update __NR_syscalls untill

>>    we either add a new system call or delete an existing system

>>    call.

>>

>> 2. We can keep this feature it above mentioned script, that'll

>>    count the number of syscalls and keep it in a generated file.

>>    In this case we don't need to explicitly update __NR_syscalls

>>    in asm/unistd.h file.

>>

>> The 2nd option will be the recommended one. For that, I moved the

>> NR_syscalls macro from asm/unistd.h to uapi/asm/unistd.h. The macro

>> name also changed form NR_syscalls to __NR_syscalls for making the

>> name convention same across all architecture. While __NR_syscalls

>> isn't strictly part of the uapi, having it as part of the generated

>> header to simplifies the implementation.

>

> This macro was in unistd.h in past but it was moved out because it was

> causing problem with strace.

>

> commit 40c2702a02b755e0183b702778331b351f3be20c

> Author:     Michal Simek <michal.simek@xilinx.com>

> AuthorDate: Mon Jul 8 09:50:24 2013 +0200

> Commit:     Michal Simek <michal.simek@xilinx.com>

> CommitDate: Wed Jul 10 07:32:09 2013 +0200

>

>     microblaze: Move __NR_syscalls from uapi

>

>

> That's why I don't think this is the right thing to do.

> I have grepped strace and glibc and none is using this macro that's why

> I think it shouldn't be exported via uapi.



Thanks for you reply :)
Sorry for the delayed response :(

I would like to keep __NR_syscalls macro to uapi header in order to simplify
the system call table generation script. Otherwise the __NR_syscalls
macro need to update manually. That become a problem.

Please check the below implementation in uapi file make sense?
It is an easy workaround to leave __NR_syscalls macro in uapi/asm/unistd.h
and enclose it in #ifdef __KERNEL__

...
...
#define __NR_pkey_free  397
#define __NR_statx      398

#ifdef __KERNEL__
#define __NR_syscalls   399
#endif
...
...

- Firoz
Michal Simek Oct. 2, 2018, 7:07 a.m. UTC | #3
On 18.9.2018 08:37, Firoz Khan wrote:
> On 9 August 2018 at 12:18, Michal Simek <michal.simek@xilinx.com> wrote:

>> On 9.8.2018 07:27, Firoz Khan wrote:

>>> __NR_syscalls macro holds the number of system call exist in this

>>> architecture. This macro is currently the part of asm/unistd.h file.

>>> We have change the value of __NR_syscalls, if we add or delete a

>>> system call.

>>>

>>> One of the patch in this patch series has a script which will

>>> generate a uapi header based on syscall.tbl file. The syscall.tbl

>>> file contains the number of system call information. So we have

>>> two option to update __NR_syscalls value.

>>>

>>> 1. Update __NR_syscalls in asm/unistd.h manually by counting the

>>>    no.of system calls. No need to update __NR_syscalls untill

>>>    we either add a new system call or delete an existing system

>>>    call.

>>>

>>> 2. We can keep this feature it above mentioned script, that'll

>>>    count the number of syscalls and keep it in a generated file.

>>>    In this case we don't need to explicitly update __NR_syscalls

>>>    in asm/unistd.h file.

>>>

>>> The 2nd option will be the recommended one. For that, I moved the

>>> NR_syscalls macro from asm/unistd.h to uapi/asm/unistd.h. The macro

>>> name also changed form NR_syscalls to __NR_syscalls for making the

>>> name convention same across all architecture. While __NR_syscalls

>>> isn't strictly part of the uapi, having it as part of the generated

>>> header to simplifies the implementation.

>>

>> This macro was in unistd.h in past but it was moved out because it was

>> causing problem with strace.

>>

>> commit 40c2702a02b755e0183b702778331b351f3be20c

>> Author:     Michal Simek <michal.simek@xilinx.com>

>> AuthorDate: Mon Jul 8 09:50:24 2013 +0200

>> Commit:     Michal Simek <michal.simek@xilinx.com>

>> CommitDate: Wed Jul 10 07:32:09 2013 +0200

>>

>>     microblaze: Move __NR_syscalls from uapi

>>

>>

>> That's why I don't think this is the right thing to do.

>> I have grepped strace and glibc and none is using this macro that's why

>> I think it shouldn't be exported via uapi.

> 

> 

> Thanks for you reply :)

> Sorry for the delayed response :(

> 

> I would like to keep __NR_syscalls macro to uapi header in order to simplify

> the system call table generation script. Otherwise the __NR_syscalls

> macro need to update manually. That become a problem.

> 

> Please check the below implementation in uapi file make sense?

> It is an easy workaround to leave __NR_syscalls macro in uapi/asm/unistd.h

> and enclose it in #ifdef __KERNEL__

> 

> ...

> ...

> #define __NR_pkey_free  397

> #define __NR_statx      398

> 

> #ifdef __KERNEL__

> #define __NR_syscalls   399

> #endif

> ...

> ...


This should be fine.

M
Firoz Khan Oct. 3, 2018, 5:09 a.m. UTC | #4
Hi Michal,

On Tue, 2 Oct 2018 at 12:37, Michal Simek <michal.simek@xilinx.com> wrote:
>

> On 18.9.2018 08:37, Firoz Khan wrote:

> > On 9 August 2018 at 12:18, Michal Simek <michal.simek@xilinx.com> wrote:

> >> On 9.8.2018 07:27, Firoz Khan wrote:

> >>> __NR_syscalls macro holds the number of system call exist in this

> >>> architecture. This macro is currently the part of asm/unistd.h file.

> >>> We have change the value of __NR_syscalls, if we add or delete a

> >>> system call.

> >>>

> >>> One of the patch in this patch series has a script which will

> >>> generate a uapi header based on syscall.tbl file. The syscall.tbl

> >>> file contains the number of system call information. So we have

> >>> two option to update __NR_syscalls value.

> >>>

> >>> 1. Update __NR_syscalls in asm/unistd.h manually by counting the

> >>>    no.of system calls. No need to update __NR_syscalls untill

> >>>    we either add a new system call or delete an existing system

> >>>    call.

> >>>

> >>> 2. We can keep this feature it above mentioned script, that'll

> >>>    count the number of syscalls and keep it in a generated file.

> >>>    In this case we don't need to explicitly update __NR_syscalls

> >>>    in asm/unistd.h file.

> >>>

> >>> The 2nd option will be the recommended one. For that, I moved the

> >>> NR_syscalls macro from asm/unistd.h to uapi/asm/unistd.h. The macro

> >>> name also changed form NR_syscalls to __NR_syscalls for making the

> >>> name convention same across all architecture. While __NR_syscalls

> >>> isn't strictly part of the uapi, having it as part of the generated

> >>> header to simplifies the implementation.

> >>

> >> This macro was in unistd.h in past but it was moved out because it was

> >> causing problem with strace.

> >>

> >> commit 40c2702a02b755e0183b702778331b351f3be20c

> >> Author:     Michal Simek <michal.simek@xilinx.com>

> >> AuthorDate: Mon Jul 8 09:50:24 2013 +0200

> >> Commit:     Michal Simek <michal.simek@xilinx.com>

> >> CommitDate: Wed Jul 10 07:32:09 2013 +0200

> >>

> >>     microblaze: Move __NR_syscalls from uapi

> >>

> >>

> >> That's why I don't think this is the right thing to do.

> >> I have grepped strace and glibc and none is using this macro that's why

> >> I think it shouldn't be exported via uapi.

> >

> >

> > Thanks for you reply :)

> > Sorry for the delayed response :(

> >

> > I would like to keep __NR_syscalls macro to uapi header in order to simplify

> > the system call table generation script. Otherwise the __NR_syscalls

> > macro need to update manually. That become a problem.

> >

> > Please check the below implementation in uapi file make sense?

> > It is an easy workaround to leave __NR_syscalls macro in uapi/asm/unistd.h

> > and enclose it in #ifdef __KERNEL__

> >

> > ...

> > ...

> > #define __NR_pkey_free  397

> > #define __NR_statx      398

> >

> > #ifdef __KERNEL__

> > #define __NR_syscalls   399

> > #endif

> > ...

> > ...

>

> This should be fine.


Thanks for the confirmation!

- Firoz
>

> M
diff mbox series

Patch

diff --git a/arch/microblaze/include/asm/unistd.h b/arch/microblaze/include/asm/unistd.h
index a62d094..e19550f 100644
--- a/arch/microblaze/include/asm/unistd.h
+++ b/arch/microblaze/include/asm/unistd.h
@@ -38,6 +38,4 @@ 
 
 #endif /* __ASSEMBLY__ */
 
-#define __NR_syscalls         401
-
 #endif /* _ASM_MICROBLAZE_UNISTD_H */
diff --git a/arch/microblaze/include/uapi/asm/unistd.h b/arch/microblaze/include/uapi/asm/unistd.h
index 7a9f16a..bde6b38 100644
--- a/arch/microblaze/include/uapi/asm/unistd.h
+++ b/arch/microblaze/include/uapi/asm/unistd.h
@@ -418,4 +418,6 @@ 
 #define __NR_io_pgetevents	399
 #define __NR_rseq		400
 
+#define __NR_syscalls         401
+
 #endif /* _UAPI_ASM_MICROBLAZE_UNISTD_H */