* Re: Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue) [not found] <OF51DE965A.FDCB6DBE-ON85256D01.005201B1-86256D01.005610CF@pok.ibm.com.suse.lists.linux.kernel> @ 2003-04-07 15:54 ` Andi Kleen 2003-04-07 16:26 ` Robert Williamson 2003-04-08 2:23 ` Werner Almesberger 0 siblings, 2 replies; 8+ messages in thread From: Andi Kleen @ 2003-04-07 15:54 UTC (permalink / raw) To: Robert Williamson; +Cc: linux-kernel, aniruddha.marathe, ltp-list "Robert Williamson" <robbiew@us.ibm.com> writes: > > Obviously, we could add additional code to check for the running arch and > define the syscall accordingly, however I'm not sure this is the correct > way to go. I'm copying our list, as well as the kernel mailing list about > this, because I "think" the system calls should be defined to the same > numbers across all architectures....but I'm not positive. BTW, I attached No. Linux has traditionally used different syscall numbers for different architectures. The original ports (alpha etc.) always used the syscall numbers of the "native" Unix, so the numbering was often completely different. Newer ports who weren't concered about such compatibility often did a renumbering too. For example x86-64 has a completely new "cache line optimized" ordering. What should work on most architectures is (most = someone told me it doesn't work properly on IA64) #include </path/to/kernel/source/include/asm-<arch>/unistd.h> (you need the version in the kernel source because many glibc packagers in their infinite wisdom use an old outdated copy of asm/ usually from the last stable kernel only) _syscallN(...) -Andi ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue) 2003-04-07 15:54 ` Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue) Andi Kleen @ 2003-04-07 16:26 ` Robert Williamson 2003-04-07 18:08 ` David Mosberger 2003-04-08 2:23 ` Werner Almesberger 1 sibling, 1 reply; 8+ messages in thread From: Robert Williamson @ 2003-04-07 16:26 UTC (permalink / raw) To: Andi Kleen; +Cc: ak, aniruddha.marathe, linux-kernel, ltp-list Hmmm...so I guess the only viable solution for a single test to cover as many archs as possible, is to explicitly define the number for each arch. Here's how I would do it Aniruddha: ------------------------------------------ #ifdef __i386__ #define __NR_timer_create 259 #endif #ifdef __x86_64__ #define __NR_timer_create 222 #endif #if defined(__ppc__) || defined(__ppc64__) #define __NR_timer_create 240 #else /* Not defined on this architecture */ #include "test.h" #include "usctest.h" int TST_TOTAL = 0; /* Total number of testcases */ int main() { tst_resm(TCONF,"This system call is not defined for this architecture."); tst_exit(); /* NOT REACHED */ return(0); } #endif /* Not defined on this architecture */ <REST OF TEST HERE> ------------------------------------------ Any comments??? - Robbie Robert V. Williamson <robbiew@us.ibm.com> Linux Test Project IBM Linux Technology Center Phone: (512) 838-9295 T/L: 678-9295 Fax: (512) 838-4603 Web: http://ltp.sourceforge.net IRC: #ltp on freenode.irc.net ==================== "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." -Albert Einstein Andi Kleen <ak@suse.de> To: Robert Williamson/Austin/IBM@IBMUS Sent by: cc: linux-kernel@vger.kernel.org, aniruddha.marathe@wipro.com, ak@suse.de ltp-list@lists.sourceforge.net Subject: Re: Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue) 04/07/2003 10:54 AM "Robert Williamson" <robbiew@us.ibm.com> writes: > > Obviously, we could add additional code to check for the running arch and > define the syscall accordingly, however I'm not sure this is the correct > way to go. I'm copying our list, as well as the kernel mailing list about > this, because I "think" the system calls should be defined to the same > numbers across all architectures....but I'm not positive. BTW, I attached No. Linux has traditionally used different syscall numbers for different architectures. The original ports (alpha etc.) always used the syscall numbers of the "native" Unix, so the numbering was often completely different. Newer ports who weren't concered about such compatibility often did a renumbering too. For example x86-64 has a completely new "cache line optimized" ordering. What should work on most architectures is (most = someone told me it doesn't work properly on IA64) #include </path/to/kernel/source/include/asm-<arch>/unistd.h> (you need the version in the kernel source because many glibc packagers in their infinite wisdom use an old outdated copy of asm/ usually from the last stable kernel only) _syscallN(...) -Andi ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue) 2003-04-07 16:26 ` Robert Williamson @ 2003-04-07 18:08 ` David Mosberger 2003-04-07 18:16 ` Robert Williamson 0 siblings, 1 reply; 8+ messages in thread From: David Mosberger @ 2003-04-07 18:08 UTC (permalink / raw) To: Robert Williamson; +Cc: Andi Kleen, aniruddha.marathe, linux-kernel, ltp-list >>>>> On Mon, 7 Apr 2003 11:26:49 -0500, "Robert Williamson" <robbiew@us.ibm.com> said: Robert> Hmmm...so I guess the only viable solution for a single test Robert> to cover as many archs as possible, is to explicitly define Robert> the number for each arch. Robert> Here's how I would do it Aniruddha: Robert> ------------------------------------------ Robert> #ifdef __i386__ Robert> #define __NR_timer_create 259 Robert> #endif Robert> #ifdef __x86_64__ Robert> #define __NR_timer_create 222 Robert> #endif Robert> #if defined(__ppc__) || defined(__ppc64__) Robert> #define __NR_timer_create 240 Robert> #else /* Not defined on this architecture */ Robert> #include "test.h" Robert> #include "usctest.h" Robert> int TST_TOTAL = 0; /* Total number of testcases */ Robert> int main() Robert> { Robert> tst_resm(TCONF,"This system call is not defined for this architecture."); Robert> tst_exit(); Robert> /* NOT REACHED */ Robert> return(0); Robert> } Robert> #endif /* Not defined on this architecture */ Robert> <REST OF TEST HERE> Robert> ------------------------------------------ Robert> Any comments??? Why use such ugly, platform-dependent code when syscall(3) will do it just fine? (AFAIK, there is no man-page for syscall(3), but the glibc info manual documents it in detail.) --david ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue) 2003-04-07 18:08 ` David Mosberger @ 2003-04-07 18:16 ` Robert Williamson 2003-04-07 18:49 ` David Mosberger 0 siblings, 1 reply; 8+ messages in thread From: Robert Williamson @ 2003-04-07 18:16 UTC (permalink / raw) To: davidm; +Cc: Andi Kleen, aniruddha.marathe, linux-kernel, ltp-list The original note had the testcases in question, which uses _syscall3......but since this was left off I'll summarize. The author did use the following: _syscall3 (int, timer_create, clockid_t, which_clock, struct sigevent *, timer_event_spec, timer_t *, timer_id); but compilation failed with: timer_delete01.c: In function `timer_create': timer_delete01.c:86: `__NR_timer_create' undeclared (first use in this function) The only way we were able to resolve this was to either to add the kernel includes to the include path: "-I /usr/src/linux-2.5.66/include". Obviously, this option will not work for the LTP and our users who frequently change kernel levels and install locations, we have to use "such ugly, platform-dependent code" - Robbie Robert V. Williamson <robbiew@us.ibm.com> Linux Test Project IBM Linux Technology Center Phone: (512) 838-9295 T/L: 678-9295 Fax: (512) 838-4603 Web: http://ltp.sourceforge.net IRC: #ltp on freenode.irc.net ==================== "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." -Albert Einstein David Mosberger <davidm@napali.hp To: Robert Williamson/Austin/IBM@IBMUS l.hp.com> cc: Andi Kleen <ak@suse.de>, aniruddha.marathe@wipro.com, linux-kernel@vger.kernel.org, ltp-list@lists.sourceforge.net 04/07/2003 01:08 Subject: Re: Same syscall is defined to different numbers on 3 different archs(was PM Re: Makefile issue) Please respond to davidm >>>>> On Mon, 7 Apr 2003 11:26:49 -0500, "Robert Williamson" <robbiew@us.ibm.com> said: Robert> Hmmm...so I guess the only viable solution for a single test Robert> to cover as many archs as possible, is to explicitly define Robert> the number for each arch. Robert> Here's how I would do it Aniruddha: Robert> ------------------------------------------ Robert> #ifdef __i386__ Robert> #define __NR_timer_create 259 Robert> #endif Robert> #ifdef __x86_64__ Robert> #define __NR_timer_create 222 Robert> #endif Robert> #if defined(__ppc__) || defined(__ppc64__) Robert> #define __NR_timer_create 240 Robert> #else /* Not defined on this architecture */ Robert> #include "test.h" Robert> #include "usctest.h" Robert> int TST_TOTAL = 0; /* Total number of testcases */ Robert> int main() Robert> { Robert> tst_resm(TCONF,"This system call is not defined for this architecture."); Robert> tst_exit(); Robert> /* NOT REACHED */ Robert> return(0); Robert> } Robert> #endif /* Not defined on this architecture */ Robert> <REST OF TEST HERE> Robert> ------------------------------------------ Robert> Any comments??? Why use such ugly, platform-dependent code when syscall(3) will do it just fine? (AFAIK, there is no man-page for syscall(3), but the glibc info manual documents it in detail.) --david ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue) 2003-04-07 18:16 ` Robert Williamson @ 2003-04-07 18:49 ` David Mosberger 0 siblings, 0 replies; 8+ messages in thread From: David Mosberger @ 2003-04-07 18:49 UTC (permalink / raw) To: Robert Williamson Cc: davidm, Andi Kleen, aniruddha.marathe, linux-kernel, ltp-list >>>>> On Mon, 7 Apr 2003 13:16:21 -0500, "Robert Williamson" <robbiew@us.ibm.com> said: Robert> The original note had the testcases in question, which uses Robert> _syscall3......but since this was left off I'll summarize. Robert> The author did use the following: Robert> _syscall3 (int, timer_create, clockid_t, which_clock, struct sigevent *, Robert> timer_event_spec, timer_t *, timer_id); Robert> but compilation failed with: Robert> timer_delete01.c: In function `timer_create': Robert> timer_delete01.c:86: `__NR_timer_create' undeclared (first use in this Robert> function) Robert> The only way we were able to resolve this was to either to Robert> add the kernel includes to the include path: "-I Robert> /usr/src/linux-2.5.66/include". Obviously, this option will Robert> not work for the LTP and our users who frequently change Robert> kernel levels and install locations, we have to use "such Robert> ugly, platform-dependent code" But you still can use syscall() instead of the non-portable syscallN() macros. Also, it should go something like this: #include <sys/syscall.h> #ifndef SYS_timer_create # if defined(__i386) # define SYS_timer_create 259 # elif defined(...) ... # endif #endif --david ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue) 2003-04-07 15:54 ` Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue) Andi Kleen 2003-04-07 16:26 ` Robert Williamson @ 2003-04-08 2:23 ` Werner Almesberger 2003-04-08 13:30 ` [LTP] " Paul Larson 1 sibling, 1 reply; 8+ messages in thread From: Werner Almesberger @ 2003-04-08 2:23 UTC (permalink / raw) To: Andi Kleen; +Cc: Robert Williamson, linux-kernel, aniruddha.marathe, ltp-list Andi Kleen wrote: > #include </path/to/kernel/source/include/asm-<arch>/unistd.h> > (you need the version in the kernel source because many glibc packagers > in their infinite wisdom use an old outdated copy of asm/ usually from > the last stable kernel only) Do we need a /proc/syscalls ? :-) - Werner -- _________________________________________________________________________ / Werner Almesberger, Buenos Aires, Argentina wa@almesberger.net / /_http://www.almesberger.net/____________________________________________/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] Re: Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue) 2003-04-08 2:23 ` Werner Almesberger @ 2003-04-08 13:30 ` Paul Larson 2003-04-08 19:47 ` Werner Almesberger 0 siblings, 1 reply; 8+ messages in thread From: Paul Larson @ 2003-04-08 13:30 UTC (permalink / raw) To: Werner Almesberger Cc: Andi Kleen, Robert Williamson, lkml, aniruddha.marathe, ltp-list [-- Attachment #1: Type: text/plain, Size: 691 bytes --] On Mon, 2003-04-07 at 21:23, Werner Almesberger wrote: > Andi Kleen wrote: > > #include </path/to/kernel/source/include/asm-<arch>/unistd.h> > > (you need the version in the kernel source because many glibc packagers > > in their infinite wisdom use an old outdated copy of asm/ usually from > > the last stable kernel only) > > Do we need a /proc/syscalls ? :-) I don't think so. Apps should be accessing things through libraries anyway. The only reason we don't in some cases like this is that it's new and not in libs on any distro yet. Besides, I don't think having a /proc/syscalls would be any better than having to do ifdefs or use kernel headers. -Paul Larson [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 240 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] Re: Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue) 2003-04-08 13:30 ` [LTP] " Paul Larson @ 2003-04-08 19:47 ` Werner Almesberger 0 siblings, 0 replies; 8+ messages in thread From: Werner Almesberger @ 2003-04-08 19:47 UTC (permalink / raw) To: Paul Larson Cc: Andi Kleen, Robert Williamson, lkml, aniruddha.marathe, ltp-list Paul Larson wrote: > I don't think so. Apps should be accessing things through libraries > anyway. The only reason we don't in some cases like this is that it's > new and not in libs on any distro yet. Well yes, if the syscall is correctly implemented in the library, there's no problem. > Besides, I don't think having a > /proc/syscalls would be any better than having to do ifdefs or use > kernel headers. #ifdef may be hard pressed to identify a specific kernel with a specific patch. Kernel headers are obviously a solution (although this violates the "user space must never include kernel headers" pseudo-rule), but add the problem of needing to identify the "current" source tree, which is a configuration step almost always requiring manual intervention. My suggestion for /proc/syscalls isn't entirely serious, but it would be nice if we could eventually solve this problem ... - Werner -- _________________________________________________________________________ / Werner Almesberger, Buenos Aires, Argentina wa@almesberger.net / /_http://www.almesberger.net/____________________________________________/ ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2003-04-08 19:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <OF51DE965A.FDCB6DBE-ON85256D01.005201B1-86256D01.005610CF@pok.ibm.com.suse.lists.linux.kernel>
2003-04-07 15:54 ` Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue) Andi Kleen
2003-04-07 16:26 ` Robert Williamson
2003-04-07 18:08 ` David Mosberger
2003-04-07 18:16 ` Robert Williamson
2003-04-07 18:49 ` David Mosberger
2003-04-08 2:23 ` Werner Almesberger
2003-04-08 13:30 ` [LTP] " Paul Larson
2003-04-08 19:47 ` Werner Almesberger
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®