mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	move page helpers to common code
If you build with --disable-pcm, the rawmidi code fails to link because it uses the page_size helper declared in local.h, but the page_* funcs are in the pcm mmap module. Move these funcs into conf.c so that they are always available to the rest of the system. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
		
							parent
							
								
									8985742d91
								
							
						
					
					
						commit
						5a24987575
					
				
					 2 changed files with 36 additions and 36 deletions
				
			
		
							
								
								
									
										36
									
								
								src/conf.c
									
										
									
									
									
								
							
							
						
						
									
										36
									
								
								src/conf.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -4876,3 +4876,39 @@ static void _snd_config_end(void)
 | 
			
		|||
	files_info_count = 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
size_t page_size(void)
 | 
			
		||||
{
 | 
			
		||||
	long s = sysconf(_SC_PAGE_SIZE);
 | 
			
		||||
	assert(s > 0);
 | 
			
		||||
	return s;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t page_align(size_t size)
 | 
			
		||||
{
 | 
			
		||||
	size_t r;
 | 
			
		||||
	long psz = page_size();
 | 
			
		||||
	r = size % psz;
 | 
			
		||||
	if (r)
 | 
			
		||||
		return size + psz - r;
 | 
			
		||||
	return size;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t page_ptr(size_t object_offset, size_t object_size, size_t *offset, size_t *mmap_offset)
 | 
			
		||||
{
 | 
			
		||||
	size_t r;
 | 
			
		||||
	long psz = page_size();
 | 
			
		||||
	assert(offset);
 | 
			
		||||
	assert(mmap_offset);
 | 
			
		||||
	*mmap_offset = object_offset;
 | 
			
		||||
	object_offset %= psz;
 | 
			
		||||
	*mmap_offset -= object_offset;
 | 
			
		||||
	object_size += object_offset;
 | 
			
		||||
	r = object_size % psz;
 | 
			
		||||
	if (r)
 | 
			
		||||
		r = object_size + psz - r;
 | 
			
		||||
	else
 | 
			
		||||
		r = object_size;
 | 
			
		||||
	*offset = object_offset;
 | 
			
		||||
	return r;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue