The following patches make the type of handles in libdrm
more consistent.
They allow us to later change the type of drm_handle_t
from unsigned long to unsigned int to allow 32bit and 64bit
clients and Xservers to share data structures.
Included are two patches: one for libdrm as part of DRM
and one for the libdrm parts (xf86drm.[ch]) in Mesa.
Once this has gotten accepted I will commit these files
in X myself.
Egbert.
Index: libdrm/xf86drm.c
===================================================================
RCS file: /cvs/dri/drm/libdrm/xf86drm.c,v
retrieving revision 1.51
diff -u -r1.51 xf86drm.c
--- libdrm/xf86drm.c 4 Apr 2005 04:08:29 -0000 1.51
+++ libdrm/xf86drm.c 15 Jul 2005 10:30:22 -0000
@@ -888,7 +888,7 @@
map.type = type;
map.flags = flags;
if (ioctl(fd, DRM_IOCTL_ADD_MAP, &map)) return -errno;
- if (handle) *handle = (drm_handle_t)map.handle;
+ if (handle) *handle = (drm_handle_t)(unsigned long)map.handle;
return 0;
}
@@ -896,7 +896,7 @@
{
drm_map_t map;
- map.handle = (void *)handle;
+ map.handle = (void *)(unsigned long)handle;
if(ioctl(fd, DRM_IOCTL_RM_MAP, &map)) return -errno;
return 0;
@@ -1499,7 +1499,7 @@
* arguments in a drm_agp_buffer structure.
*/
int drmAgpAlloc(int fd, unsigned long size, unsigned long type,
- unsigned long *address, unsigned long *handle)
+ unsigned long *address, drm_handle_t *handle)
{
drm_agp_buffer_t b;
@@ -1526,7 +1526,7 @@
* This function is a wrapper around the DRM_IOCTL_AGP_FREE ioctl, passing the
* argument in a drm_agp_buffer structure.
*/
-int drmAgpFree(int fd, unsigned long handle)
+int drmAgpFree(int fd, drm_handle_t handle)
{
drm_agp_buffer_t b;
@@ -1550,7 +1550,7 @@
* This function is a wrapper around the DRM_IOCTL_AGP_BIND ioctl, passing the
* argument in a drm_agp_binding structure.
*/
-int drmAgpBind(int fd, unsigned long handle, unsigned long offset)
+int drmAgpBind(int fd, drm_handle_t handle, unsigned long offset)
{
drm_agp_binding_t b;
@@ -1573,7 +1573,7 @@
* This function is a wrapper around the DRM_IOCTL_AGP_UNBIND ioctl, passing
* the argument in a drm_agp_binding structure.
*/
-int drmAgpUnbind(int fd, unsigned long handle)
+int drmAgpUnbind(int fd, drm_handle_t handle)
{
drm_agp_binding_t b;
@@ -1763,7 +1763,7 @@
return i.id_device;
}
-int drmScatterGatherAlloc(int fd, unsigned long size, unsigned long *handle)
+int drmScatterGatherAlloc(int fd, unsigned long size, drm_handle_t *handle)
{
drm_scatter_gather_t sg;
@@ -1775,7 +1775,7 @@
return 0;
}
-int drmScatterGatherFree(int fd, unsigned long handle)
+int drmScatterGatherFree(int fd, drm_handle_t handle)
{
drm_scatter_gather_t sg;
@@ -1942,7 +1942,7 @@
drm_ctx_priv_map_t map;
map.ctx_id = ctx_id;
- map.handle = (void *)handle;
+ map.handle = (void *)(unsigned long)handle;
if (ioctl(fd, DRM_IOCTL_SET_SAREA_CTX, &map)) return -errno;
return 0;
@@ -1955,7 +1955,7 @@
map.ctx_id = ctx_id;
if (ioctl(fd, DRM_IOCTL_GET_SAREA_CTX, &map)) return -errno;
- if (handle) *handle = (drm_handle_t)map.handle;
+ if (handle) *handle = (drm_handle_t)(unsigned long)map.handle;
return 0;
}
@@ -1972,7 +1972,7 @@
*size = map.size;
*type = map.type;
*flags = map.flags;
- *handle = (unsigned long)map.handle;
+ *handle = (drm_handle_t)(unsigned long)map.handle;
*mtrr = map.mtrr;
return 0;
}
@@ -1995,7 +1995,7 @@
int drmGetStats(int fd, drmStatsT *stats)
{
drm_stats_t s;
- int i;
+ unsigned int i;
if (ioctl(fd, DRM_IOCTL_GET_STATS, &s)) return -errno;
Index: libdrm/xf86drm.h
===================================================================
RCS file: /cvs/dri/drm/libdrm/xf86drm.h,v
retrieving revision 1.6
diff -u -r1.6 xf86drm.h
--- libdrm/xf86drm.h 1 Feb 2005 22:09:46 -0000 1.6
+++ libdrm/xf86drm.h 15 Jul 2005 10:30:22 -0000
@@ -577,11 +577,11 @@
extern int drmAgpEnable(int fd, unsigned long mode);
extern int drmAgpAlloc(int fd, unsigned long size,
unsigned long type, unsigned long *address,
- unsigned long *handle);
-extern int drmAgpFree(int fd, unsigned long handle);
-extern int drmAgpBind(int fd, unsigned long handle,
+ drm_handle_t *handle);
+extern int drmAgpFree(int fd, drm_handle_t handle);
+extern int drmAgpBind(int fd, drm_handle_t handle,
unsigned long offset);
-extern int drmAgpUnbind(int fd, unsigned long handle);
+extern int drmAgpUnbind(int fd, drm_handle_t handle);
/* AGP/GART info: authenticated client and/or X */
extern int drmAgpVersionMajor(int fd);
@@ -596,8 +596,8 @@
/* PCI scatter/gather support: X server (root) only */
extern int drmScatterGatherAlloc(int fd, unsigned long size,
- unsigned long *handle);
-extern int drmScatterGatherFree(int fd, unsigned long handle);
+ drm_handle_t *handle);
+extern int drmScatterGatherFree(int fd, drm_handle_t handle);
extern int drmWaitVBlank(int fd, drmVBlankPtr vbl);
Index: src/mesa/drivers/dri/dri_client/xf86drm.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/dri_client/xf86drm.c,v
retrieving revision 1.3
diff -u -r1.3 xf86drm.c
--- src/mesa/drivers/dri/dri_client/xf86drm.c 22 Mar 2005 13:34:27 -0000
1.3
+++ src/mesa/drivers/dri/dri_client/xf86drm.c 15 Jul 2005 09:48:04 -0000
@@ -892,7 +892,7 @@
map.type = type;
map.flags = flags;
if (ioctl(fd, DRM_IOCTL_ADD_MAP, &map)) return -errno;
- if (handle) *handle = (drm_handle_t)map.handle;
+ if (handle) *handle = (drm_handle_t)(unsigned long)map.handle;
return 0;
}
@@ -900,7 +900,7 @@
{
drm_map_t map;
- map.handle = (void *)handle;
+ map.handle = (void *)(unsigned long)handle;
if(ioctl(fd, DRM_IOCTL_RM_MAP, &map)) return -errno;
return 0;
@@ -1045,7 +1045,7 @@
{
static unsigned long pagesize_mask = 0;
- if (fd < 0) return -EINVAL;
+ if (fd < 0) return -EINVAL;
if (!pagesize_mask)
pagesize_mask = getpagesize() - 1;
@@ -1503,7 +1503,7 @@
* arguments in a drm_agp_buffer structure.
*/
int drmAgpAlloc(int fd, unsigned long size, unsigned long type,
- unsigned long *address, unsigned long *handle)
+ unsigned long *address, drm_handle_t *handle)
{
drm_agp_buffer_t b;
@@ -1530,7 +1530,7 @@
* This function is a wrapper around the DRM_IOCTL_AGP_FREE ioctl, passing the
* argument in a drm_agp_buffer structure.
*/
-int drmAgpFree(int fd, unsigned long handle)
+int drmAgpFree(int fd, drm_handle_t handle)
{
drm_agp_buffer_t b;
@@ -1554,7 +1554,7 @@
* This function is a wrapper around the DRM_IOCTL_AGP_BIND ioctl, passing the
* argument in a drm_agp_binding structure.
*/
-int drmAgpBind(int fd, unsigned long handle, unsigned long offset)
+int drmAgpBind(int fd, drm_handle_t handle, unsigned long offset)
{
drm_agp_binding_t b;
@@ -1577,7 +1577,7 @@
* This function is a wrapper around the DRM_IOCTL_AGP_UNBIND ioctl, passing
* the argument in a drm_agp_binding structure.
*/
-int drmAgpUnbind(int fd, unsigned long handle)
+int drmAgpUnbind(int fd, drm_handle_t handle)
{
drm_agp_binding_t b;
@@ -1767,7 +1767,7 @@
return i.id_device;
}
-int drmScatterGatherAlloc(int fd, unsigned long size, unsigned long *handle)
+int drmScatterGatherAlloc(int fd, unsigned long size, drm_handle_t *handle)
{
drm_scatter_gather_t sg;
@@ -1779,7 +1779,7 @@
return 0;
}
-int drmScatterGatherFree(int fd, unsigned long handle)
+int drmScatterGatherFree(int fd, drm_handle_t handle)
{
drm_scatter_gather_t sg;
@@ -1946,7 +1946,7 @@
drm_ctx_priv_map_t map;
map.ctx_id = ctx_id;
- map.handle = (void *)handle;
+ map.handle = (void *)(unsigned long)handle;
if (ioctl(fd, DRM_IOCTL_SET_SAREA_CTX, &map)) return -errno;
return 0;
@@ -1959,7 +1959,7 @@
map.ctx_id = ctx_id;
if (ioctl(fd, DRM_IOCTL_GET_SAREA_CTX, &map)) return -errno;
- if (handle) *handle = (drm_handle_t)map.handle;
+ if (handle) *handle = (drm_handle_t)(unsigned long)map.handle;
return 0;
}
@@ -1976,7 +1976,7 @@
*size = map.size;
*type = map.type;
*flags = map.flags;
- *handle = (unsigned long)map.handle;
+ *handle = (drm_handle_t)(unsigned long)map.handle;
*mtrr = map.mtrr;
return 0;
}
@@ -1999,7 +1999,7 @@
int drmGetStats(int fd, drmStatsT *stats)
{
drm_stats_t s;
- int i;
+ unsigned int i;
if (ioctl(fd, DRM_IOCTL_GET_STATS, &s)) return -errno;
Index: src/mesa/drivers/dri/dri_client/imports/xf86drm.h
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/dri_client/imports/xf86drm.h,v
retrieving revision 1.3
diff -u -r1.3 xf86drm.h
--- src/mesa/drivers/dri/dri_client/imports/xf86drm.h 14 Feb 2005 06:57:27
-0000 1.3
+++ src/mesa/drivers/dri/dri_client/imports/xf86drm.h 15 Jul 2005 09:48:04
-0000
@@ -575,11 +575,11 @@
extern int drmAgpEnable(int fd, unsigned long mode);
extern int drmAgpAlloc(int fd, unsigned long size,
unsigned long type, unsigned long *address,
- unsigned long *handle);
-extern int drmAgpFree(int fd, unsigned long handle);
-extern int drmAgpBind(int fd, unsigned long handle,
+ drm_handle_t *handle);
+extern int drmAgpFree(int fd, drm_handle_t handle);
+extern int drmAgpBind(int fd, drm_handle_t handle,
unsigned long offset);
-extern int drmAgpUnbind(int fd, unsigned long handle);
+extern int drmAgpUnbind(int fd, drm_handle_t handle);
/* AGP/GART info: authenticated client and/or X */
extern int drmAgpVersionMajor(int fd);
@@ -594,8 +594,8 @@
/* PCI scatter/gather support: X server (root) only */
extern int drmScatterGatherAlloc(int fd, unsigned long size,
- unsigned long *handle);
-extern int drmScatterGatherFree(int fd, unsigned long handle);
+ drm_handle_t *handle);
+extern int drmScatterGatherFree(int fd, drm_handle_t handle);
extern int drmWaitVBlank(int fd, drmVBlankPtr vbl);