summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>2003-01-15 02:15:57 +0000
committermdodd <mdodd@FreeBSD.org>2003-01-15 02:15:57 +0000
commit4faf7cdff594ef0c66a6083953f94acd78f13d0c (patch)
tree891db78291a739652635f985ce52d61f12a3d3fd
parent3f76186ccea51c706ffda5d0f7d84b0c5185349d (diff)
downloadFreeBSD-src-4faf7cdff594ef0c66a6083953f94acd78f13d0c.zip
FreeBSD-src-4faf7cdff594ef0c66a6083953f94acd78f13d0c.tar.gz
- GC a few more hand-rolled 'abs' macros.
- GC a few hand-rolled min()/max() macros while I'm here.
-rw-r--r--sys/dev/atkbdc/psm.c23
-rw-r--r--sys/dev/sound/isa/mss.c1
-rw-r--r--sys/isa/psm.c23
-rw-r--r--sys/sparc64/sparc64/db_disasm.c2
4 files changed, 14 insertions, 35 deletions
diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c
index 5e95cb5..6da38fda 100644
--- a/sys/dev/atkbdc/psm.c
+++ b/sys/dev/atkbdc/psm.c
@@ -129,15 +129,6 @@
#define PSM_NBLOCKIO(dev) (minor(dev) & 1)
#define PSM_MKMINOR(unit,block) (((unit) << 1) | ((block) ? 0:1))
-#ifndef max
-#define max(x,y) ((x) > (y) ? (x) : (y))
-#endif
-#ifndef min
-#define min(x,y) ((x) < (y) ? (x) : (y))
-#endif
-
-#define abs(x) (((x) < 0) ? -(x) : (x))
-
/* ring buffer */
typedef struct ringbuf {
int count; /* # of valid elements in the buffer */
@@ -1491,24 +1482,24 @@ tame_mouse(struct psm_softc *sc, mousestatus_t *status, unsigned char *buf)
mapped |= MOUSE_BUTTON1DOWN;
status->button = mapped;
buf[0] = MOUSE_PS2_SYNC | butmapps2[mapped & MOUSE_STDBUTTONS];
- i = max(min(status->dx, 255), -256);
+ i = imax(imin(status->dx, 255), -256);
if (i < 0)
buf[0] |= MOUSE_PS2_XNEG;
buf[1] = i;
- i = max(min(status->dy, 255), -256);
+ i = imax(imin(status->dy, 255), -256);
if (i < 0)
buf[0] |= MOUSE_PS2_YNEG;
buf[2] = i;
return MOUSE_PS2_PACKETSIZE;
} else if (sc->mode.level == PSM_LEVEL_STANDARD) {
buf[0] = MOUSE_MSC_SYNC | butmapmsc[status->button & MOUSE_STDBUTTONS];
- i = max(min(status->dx, 255), -256);
+ i = imax(imin(status->dx, 255), -256);
buf[1] = i >> 1;
buf[3] = i - buf[1];
- i = max(min(status->dy, 255), -256);
+ i = imax(imin(status->dy, 255), -256);
buf[2] = i >> 1;
buf[4] = i - buf[2];
- i = max(min(status->dz, 127), -128);
+ i = imax(imin(status->dz, 127), -128);
buf[5] = (i >> 1) & 0x7f;
buf[6] = (i - (i >> 1)) & 0x7f;
buf[7] = (~status->button >> 3) & 0x7f;
@@ -1553,7 +1544,7 @@ psmread(dev_t dev, struct uio *uio, int flag)
/* copy data to the user land */
while ((sc->queue.count > 0) && (uio->uio_resid > 0)) {
s = spltty();
- l = min(sc->queue.count, uio->uio_resid);
+ l = imin(sc->queue.count, uio->uio_resid);
if (l > sizeof(buf))
l = sizeof(buf);
if (l > sizeof(sc->queue.buf) - sc->queue.head) {
@@ -2363,7 +2354,7 @@ psmintr(void *arg)
/* queue data */
if (sc->queue.count + sc->inputbytes < sizeof(sc->queue.buf)) {
- l = min(sc->inputbytes, sizeof(sc->queue.buf) - sc->queue.tail);
+ l = imin(sc->inputbytes, sizeof(sc->queue.buf) - sc->queue.tail);
bcopy(&sc->ipacket[0], &sc->queue.buf[sc->queue.tail], l);
if (sc->inputbytes > l)
bcopy(&sc->ipacket[l], &sc->queue.buf[0], sc->inputbytes - l);
diff --git a/sys/dev/sound/isa/mss.c b/sys/dev/sound/isa/mss.c
index 35e24c0..8f7a378 100644
--- a/sys/dev/sound/isa/mss.c
+++ b/sys/dev/sound/isa/mss.c
@@ -39,7 +39,6 @@ SND_DECLARE_FILE("$FreeBSD$");
#include "mixer_if.h"
#define MSS_DEFAULT_BUFSZ (4096)
-#define abs(x) (((x) < 0) ? -(x) : (x))
#define MSS_INDEXED_REGS 0x20
#define OPL_INDEXED_REGS 0x19
diff --git a/sys/isa/psm.c b/sys/isa/psm.c
index 5e95cb5..6da38fda 100644
--- a/sys/isa/psm.c
+++ b/sys/isa/psm.c
@@ -129,15 +129,6 @@
#define PSM_NBLOCKIO(dev) (minor(dev) & 1)
#define PSM_MKMINOR(unit,block) (((unit) << 1) | ((block) ? 0:1))
-#ifndef max
-#define max(x,y) ((x) > (y) ? (x) : (y))
-#endif
-#ifndef min
-#define min(x,y) ((x) < (y) ? (x) : (y))
-#endif
-
-#define abs(x) (((x) < 0) ? -(x) : (x))
-
/* ring buffer */
typedef struct ringbuf {
int count; /* # of valid elements in the buffer */
@@ -1491,24 +1482,24 @@ tame_mouse(struct psm_softc *sc, mousestatus_t *status, unsigned char *buf)
mapped |= MOUSE_BUTTON1DOWN;
status->button = mapped;
buf[0] = MOUSE_PS2_SYNC | butmapps2[mapped & MOUSE_STDBUTTONS];
- i = max(min(status->dx, 255), -256);
+ i = imax(imin(status->dx, 255), -256);
if (i < 0)
buf[0] |= MOUSE_PS2_XNEG;
buf[1] = i;
- i = max(min(status->dy, 255), -256);
+ i = imax(imin(status->dy, 255), -256);
if (i < 0)
buf[0] |= MOUSE_PS2_YNEG;
buf[2] = i;
return MOUSE_PS2_PACKETSIZE;
} else if (sc->mode.level == PSM_LEVEL_STANDARD) {
buf[0] = MOUSE_MSC_SYNC | butmapmsc[status->button & MOUSE_STDBUTTONS];
- i = max(min(status->dx, 255), -256);
+ i = imax(imin(status->dx, 255), -256);
buf[1] = i >> 1;
buf[3] = i - buf[1];
- i = max(min(status->dy, 255), -256);
+ i = imax(imin(status->dy, 255), -256);
buf[2] = i >> 1;
buf[4] = i - buf[2];
- i = max(min(status->dz, 127), -128);
+ i = imax(imin(status->dz, 127), -128);
buf[5] = (i >> 1) & 0x7f;
buf[6] = (i - (i >> 1)) & 0x7f;
buf[7] = (~status->button >> 3) & 0x7f;
@@ -1553,7 +1544,7 @@ psmread(dev_t dev, struct uio *uio, int flag)
/* copy data to the user land */
while ((sc->queue.count > 0) && (uio->uio_resid > 0)) {
s = spltty();
- l = min(sc->queue.count, uio->uio_resid);
+ l = imin(sc->queue.count, uio->uio_resid);
if (l > sizeof(buf))
l = sizeof(buf);
if (l > sizeof(sc->queue.buf) - sc->queue.head) {
@@ -2363,7 +2354,7 @@ psmintr(void *arg)
/* queue data */
if (sc->queue.count + sc->inputbytes < sizeof(sc->queue.buf)) {
- l = min(sc->inputbytes, sizeof(sc->queue.buf) - sc->queue.tail);
+ l = imin(sc->inputbytes, sizeof(sc->queue.buf) - sc->queue.tail);
bcopy(&sc->ipacket[0], &sc->queue.buf[sc->queue.tail], l);
if (sc->inputbytes > l)
bcopy(&sc->ipacket[l], &sc->queue.buf[0], sc->inputbytes - l);
diff --git a/sys/sparc64/sparc64/db_disasm.c b/sys/sparc64/sparc64/db_disasm.c
index 7d047cc..bf12b71 100644
--- a/sys/sparc64/sparc64/db_disasm.c
+++ b/sys/sparc64/sparc64/db_disasm.c
@@ -40,8 +40,6 @@
#include <machine/db_machdep.h>
#include <machine/instr.h>
-#define abs(v) ((v) > 0 ? (v) : -(v))
-
#define SIGN(v) (((v)<0)?"-":"")
/*
OpenPOWER on IntegriCloud