* Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue)
@ 2003-04-07 15:39 Robert Williamson
2003-04-07 17:38 ` Robert Love
0 siblings, 1 reply; 8+ messages in thread
From: Robert Williamson @ 2003-04-07 15:39 UTC (permalink / raw)
To: Aniruddha M Marathe, linux-kernel; +Cc: ltp-list
[-- Attachment #1: Type: text/plain, Size: 4406 bytes --]
Sorry for the delay in response.....I was very busy with this month's
release. I reviewed the testcase, and you have coded it the correct way
using __syscall. I believe the problem is that we need to define
__NR_timer_create/delete in the test itself. I tried this and the test
compiled and executed correctly. However, I looked at the kernel, and it
seems that there is a BUG in the code....there are different numbers
assigned to the timer system calls for different archs:
# grep -r __NR_timer_create /usr/src/linux-2.5.66/include/*
/usr/src/linux-2.5.66/include/asm-i386/unistd.h:#define __NR_timer_create
259
/usr/src/linux-2.5.66/include/asm-ppc/unistd.h:#define __NR_timer_create
240
/usr/src/linux-2.5.66/include/asm-ppc64/unistd.h:#define __NR_timer_create
240
/usr/src/linux-2.5.66/include/asm-x86_64/unistd.h:#define __NR_timer_create
222
# grep -r __NR_timer_delete /usr/src/linux-2.5.66/include/*
/usr/src/linux-2.5.66/include/asm-i386/unistd.h:#define __NR_timer_delete
(__NR_timer_create+4)
/usr/src/linux-2.5.66/include/asm-ppc/unistd.h:#define __NR_timer_delete
244
/usr/src/linux-2.5.66/include/asm-ppc64/unistd.h:#define __NR_timer_delete
244
/usr/src/linux-2.5.66/include/asm-x86_64/unistd.h:#define __NR_timer_delete
226
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
the testcase with my changes....which will only work on i386.
- Robbie
Robert V. Williamson <robbiew@us.ibm.com>
Linux Test Project
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
(See attached file: timer_delete01.c)(See attached file: Makefile)
"Aniruddha M
Marathe" To: Robert Williamson/Austin/IBM@IBMUS
<aniruddha.marathe cc:
@wipro.com> Subject: Makefile issue
04/03/2003 05:27
AM
Hi,
I am writing testcases for system calls that were recently added in the 2.5
versions of kernel. Since there are some new header files / added
definitions in other header files in 2.5 versions, I have to give something
like
-I/src/ (kernel that supports new definitions/include in makefile for clean
compilation.
I am attaching a test case for timer_delete(2) and a Makefile to give you
an exact idea of the problem.
Please see the makefile
Now if I remove "-I/usr/src/linux-2.5.64/include" from CFLAGS, the
compilation will fail as:
timer_delete01.c: In function `timer_create':
timer_delete01.c:86: `__NR_timer_create' undeclared (first use in this
function)
Since I can't generalize any such path, these test cases will fail for
others. Note that its not issue of kernel version. I can check kernel
version with uname -r in makefile and then compile it (or do not compile
it). The issue is of path.
Can you suggest any way out?
Thanks,
Aniruddha.
#### Makefile has been removed from this note on April 07, 2003 by Robert
Williamson
#### timer_delete01.c has been removed from this note on April 07, 2003 by
Robert Williamson
[-- Attachment #2: timer_delete01.c --]
[-- Type: application/octet-stream, Size: 4668 bytes --]
/*
* Copyright (c) Wipro Technologies Ltd, 2003. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
*
*/
/**************************************************************************
*
* TEST IDENTIFIER : timer_delete01
*
* EXECUTED BY : anyone
*
* TEST TITLE : Basic test for timer_delete(2)
*
* TEST CASE TOTAL : 1
*
* AUTHOR : Aniruddha Marathe <aniruddha.marathe@wipro.com>
*
* SIGNALS
* Uses SIGUSR1 to pause before test if option set.
* (See the parse_opts(3) man page).
*
* DESCRIPTION
* This is a Phase I test for the timer_delete(2) system call.
* It is intended to provide a limited exposure of the system call.
*
* Setup:
* Setup signal handling.
* Pause for SIGUSR1 if option specified.
*
* Test:
* Loop if the proper options are given.
* Create a POSIX timer
* Execute system call
* Check return code, if system call failed (return=-1)
* Log the errno and Issue a FAIL message.
* Otherwise, Issue a PASS message.
*
* Cleanup:
* Print errno log and/or timing stats if options given
*
* USAGE: <for command-line>
* timer_delete01 [-c n] [-e] [-i n] [-I x] [-P x] [-t] [-p]
* where:
* -c n : Run n copies simultaneously.
* -e : Turn on errno logging.
* -i n : Execute test n times.
* -I x : Execute test for x seconds.
* -p : Pause for SIGUSR1 before starting
* -P x : Pause for x seconds between iterations.
* -t : Turn on syscall timing.
*
*RESTRICTIONS:
* This system call is implemented in kernel 2.5.63. Test case will break for
* Kernel versions less than 2.5.63
*****************************************************************************/
#include "test.h"
#include "usctest.h"
#include <errno.h>
#include <syscall.h>
#include <time.h>
#ifndef CLOCK_REALTIME
#define CLOCK_REALTIME 0
#endif
#define __NR_timer_create 259
#define __NR_timer_delete (__NR_timer_create + 4)
static void setup ();
static void cleanup ();
char *TCID = "timer_delete01"; /* Test program identifier. */
int TST_TOTAL = 1; /* Total number of test cases. */
extern int Tst_count; /* Test Case counter for tst_* routines */
timer_t timer_id;
_syscall3 (int, timer_create, clockid_t, which_clock, struct sigevent *,
timer_event_spec, timer_t *, timer_id);
_syscall1 (int, timer_delete, timer_t, timer_id);
int
main (int ac, char **av)
{
int lc, i; /* loop counter */
char *msg; /* message returned from parse_opts */
if (tst_kvercmp (2, 5, 63) < 0) {
tst_brkm (TBROK, tst_exit, "This system call is not implemented"
" in the running kernel version");
}
/* parse standard options */
if ((msg = parse_opts (ac, av, (option_t *) NULL, NULL)) !=
(char *) NULL) {
tst_brkm (TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
}
/* perform global setup for test */
setup ();
/* check looping state if -i option given */
for (lc = 0; TEST_LOOPING (lc); lc++) {
/* reset Tst_count in case we are looping. */
Tst_count = 0;
for (i = 0; i < TST_TOTAL; i++) {
/* Create a Posix timer*/
if(timer_create(CLOCK_REALTIME, NULL, &timer_id) < 0) {
tst_brkm(TBROK, cleanup, "timer_create"
" failed");
}
TEST (timer_delete(timer_id));
if (TEST_RETURN == -1) {
TEST_ERROR_LOG (TEST_ERRNO);
tst_resm (TFAIL, "timer_delete(2) Failed and"
" set errno to %d", TEST_ERRNO);
} else {
tst_resm (TPASS, "timer_delete(2) Passed");
}
} /*End of TEST CASE LOOPING */
} /*End for TEST_LOOPING */
/*Clean up and exit */
cleanup ();
/*NOTREACHED*/
return 0;
}
/* setup() - performs all ONE TIME setup for this test */
void
setup ()
{
/* capture signals */
tst_sig (NOFORK, DEF_HANDLER, cleanup);
/* Pause if that option was specified */
TEST_PAUSE;
} /* End setup() */
/*
* cleanup() - Performs one time cleanup for this test at
* completion or premature exit
*/
void
cleanup ()
{
/*
* print timing stats if that option was specified.
* print errno log if that option was specified.
*/
TEST_CLEANUP;
/* exit with return code appropriate for results */
tst_exit ();
} /* End cleanup() */
[-- Attachment #3: Makefile --]
[-- Type: application/octet-stream, Size: 1321 bytes --]
#
# Copyright (c) International Business Machines Corp., 2001
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
###########################################################################
# name of file : Makefile #
###########################################################################
CFLAGS+= -Wall -I../../../../include
LDFLAGS+= -L../../../../lib -lltp
SRCS=$(wildcard *.c)
TARGETS=$(patsubst %.c,%,$(SRCS))
all: $(TARGETS)
$(TARGETS): $(SRCS)
$(CC) -o $@ $@.c $(CFLAGS) $(LDFLAGS)
install: all
@set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
clean:
rm -f $(TARGETS)
^ 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)
[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 ` 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 15:39 Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue) Robert Williamson
@ 2003-04-07 17:38 ` Robert Love
0 siblings, 0 replies; 8+ messages in thread
From: Robert Love @ 2003-04-07 17:38 UTC (permalink / raw)
To: Robert Williamson; +Cc: Aniruddha M Marathe, linux-kernel, ltp-list
On Mon, 2003-04-07 at 11:39, Robert Williamson wrote:
> However, I looked at the kernel, and it seems that there is a
> BUG in the code....there are different numbers assigned to the
> timer system calls for different archs:
Syscall numbers are supposed to be unique to each architecture... they
are per-arch.
Robert Love
^ 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 ` Andi Kleen
2003-04-07 16:26 ` Robert Williamson
@ 2003-04-08 2:23 ` Werner Almesberger
1 sibling, 0 replies; 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
end of thread, other threads:[~2003-04-08 2:12 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-07 15:39 Same syscall is defined to different numbers on 3 different archs(was Re: Makefile issue) Robert Williamson
2003-04-07 17:38 ` Robert Love
[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-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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox