public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* 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
[parent not found: <OF51DE965A.FDCB6DBE-ON85256D01.005201B1-86256D01.005610CF@pok.ibm.com.suse.lists.linux.kernel>]

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