summaryrefslogtreecommitdiff
path: root/setpci.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1998-06-08 07:57:54 +0000
committerMartin Mares <mj@ucw.cz>2006-05-05 14:09:52 +0200
commit7aad822bcbe5b893df871f5531e7802b598cbb4f (patch)
tree085165f4fec2dc6b20295cd8567c54d45b4758f1 /setpci.c
parent27e209111bfe389cf4d3aaecd70e76afe2464249 (diff)
downloadpciutils-7aad822bcbe5b893df871f5531e7802b598cbb4f.tar.gz
pread()/pwrite() now should work even with glibc on Alpha.
"--version".
Diffstat (limited to 'setpci.c')
-rw-r--r--setpci.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/setpci.c b/setpci.c
index b13ddb4..f65b4d6 100644
--- a/setpci.c
+++ b/setpci.c
@@ -1,5 +1,5 @@
/*
- * $Id: setpci.c,v 1.2 1998/04/19 11:02:29 mj Exp $
+ * $Id: setpci.c,v 1.3 1998/06/08 07:57:54 mj Exp $
*
* Linux PCI Utilities -- Manipulate PCI Configuration Registers
*
@@ -8,15 +8,21 @@
* Can be freely distributed and used under the terms of the GNU GPL.
*/
+#define _GNU_SOURCE
+
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
-#include <asm/unistd.h>
#include <asm/byteorder.h>
+#include <asm/unistd.h>
+#ifdef __GLIBC__
+#include <syscall-list.h>
+#endif
+
#include "pciutils.h"
static int force; /* Don't complain if no devices match */
@@ -59,8 +65,22 @@ xmalloc(unsigned int howmuch)
* As libc doesn't support pread/pwrite yet, we have to call them directly
* or use lseek/read/write instead.
*/
+#ifdef __GLIBC__
+static int
+pread(unsigned int fd, void *buf, size_t size, loff_t where)
+{
+ return syscall(SYS_pread, fd, buf, size, where);
+}
+
+static int
+pwrite(unsigned int fd, void *buf, size_t size, loff_t where)
+{
+ return syscall(SYS_pwrite, fd, buf, size, where);
+}
+#else
static _syscall4(int, pread, unsigned int, fd, void *, buf, size_t, size, loff_t, where);
static _syscall4(int, pwrite, unsigned int, fd, void *, buf, size_t, size, loff_t, where);
+#endif
static void
scan_devices(void)
@@ -333,6 +353,11 @@ main(int argc, char **argv)
struct pci_filter filter;
struct device **selected_devices = NULL;
+ if (argc == 2 && !strcmp(argv[1], "--version"))
+ {
+ puts("setpci version " PCIUTILS_VERSION);
+ return 0;
+ }
argc--;
argv++;
while (argc && argv[0][0] == '-')