#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/shm.h>
-#include <asm/page.h>
#include "pcm_local.h"
#include "../control/control_local.h"
#define F_SETSIG 10
#endif
-#ifndef PAGE_ALIGN
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-#endif
-
typedef struct {
int fd;
int card, device, subdevice;
{
snd_pcm_hw_t *hw = pcm->private_data;
void *ptr;
- ptr = mmap(NULL, PAGE_ALIGN(sizeof(struct sndrv_pcm_mmap_status)), PROT_READ, MAP_FILE|MAP_SHARED,
+ ptr = mmap(NULL, page_align(sizeof(struct sndrv_pcm_mmap_status)), PROT_READ, MAP_FILE|MAP_SHARED,
hw->fd, SND_PCM_MMAP_OFFSET_STATUS);
if (ptr == MAP_FAILED || ptr == NULL) {
SYSERR("status mmap failed");
{
snd_pcm_hw_t *hw = pcm->private_data;
void *ptr;
- ptr = mmap(NULL, PAGE_ALIGN(sizeof(struct sndrv_pcm_mmap_control)), PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED,
+ ptr = mmap(NULL, page_align(sizeof(struct sndrv_pcm_mmap_control)), PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED,
hw->fd, SND_PCM_MMAP_OFFSET_CONTROL);
if (ptr == MAP_FAILED || ptr == NULL) {
SYSERR("control mmap failed");
static int snd_pcm_hw_munmap_status(snd_pcm_t *pcm)
{
snd_pcm_hw_t *hw = pcm->private_data;
- if (munmap((void*)hw->mmap_status, PAGE_ALIGN(sizeof(*hw->mmap_status))) < 0) {
+ if (munmap((void*)hw->mmap_status, page_align(sizeof(*hw->mmap_status))) < 0) {
SYSERR("status munmap failed");
return -errno;
}
static int snd_pcm_hw_munmap_control(snd_pcm_t *pcm)
{
snd_pcm_hw_t *hw = pcm->private_data;
- if (munmap(hw->mmap_control, PAGE_ALIGN(sizeof(*hw->mmap_control))) < 0) {
+ if (munmap(hw->mmap_control, page_align(sizeof(*hw->mmap_control))) < 0) {
SYSERR("control munmap failed");
return -errno;
}
#include <sys/poll.h>
#include <sys/mman.h>
#include <sys/shm.h>
-#include <asm/page.h>
#include "pcm_local.h"
+size_t page_size(void)
+{
+ long s = sysconf(_SC_PAGE_SIZE);
+ assert(s > 0);
+ return s;
+}
-#ifndef PAGE_ALIGN
-#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-#endif
-
+size_t page_align(size_t size)
+{
+ size_t r;
+ long psz = sysconf(_SC_PAGE_SIZE);
+ assert(psz > 0);
+ r = size % psz;
+ if (r)
+ return size + psz - r;
+ return size;
+}
const snd_pcm_channel_area_t *snd_pcm_mmap_running_areas(snd_pcm_t *pcm)
{
size = s;
}
size = (size + 7) / 8;
- size = PAGE_ALIGN(size);
+ size = page_align(size);
switch (i->type) {
case SND_PCM_AREA_MMAP:
ptr = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, i->u.mmap.fd, i->u.mmap.offset);
size = s;
}
size = (size + 7) / 8;
- size = PAGE_ALIGN(size);
+ size = page_align(size);
switch (i->type) {
case SND_PCM_AREA_MMAP:
#if 0