mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	atomic-test: unbreak on FreeBSD (cpuset_t)
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/277>
This commit is contained in:
		
							parent
							
								
									72792db74c
								
							
						
					
					
						commit
						379fd67c1c
					
				
					 1 changed files with 9 additions and 2 deletions
				
			
		| 
						 | 
					@ -47,6 +47,9 @@
 | 
				
			||||||
#include <pulse/xmalloc.h>
 | 
					#include <pulse/xmalloc.h>
 | 
				
			||||||
#include <pulsecore/semaphore.h>
 | 
					#include <pulsecore/semaphore.h>
 | 
				
			||||||
#include <pthread.h>
 | 
					#include <pthread.h>
 | 
				
			||||||
 | 
					#ifdef __FreeBSD__
 | 
				
			||||||
 | 
					#include <pthread_np.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
#include <pulsecore/atomic.h>
 | 
					#include <pulsecore/atomic.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define MEMORY_SIZE (8 * 2 * 1024 * 1024)
 | 
					#define MEMORY_SIZE (8 * 2 * 1024 * 1024)
 | 
				
			||||||
| 
						 | 
					@ -55,14 +58,18 @@
 | 
				
			||||||
typedef struct io_t {
 | 
					typedef struct io_t {
 | 
				
			||||||
   pa_atomic_t *flag;
 | 
					   pa_atomic_t *flag;
 | 
				
			||||||
   char* memory;
 | 
					   char* memory;
 | 
				
			||||||
 | 
					#ifdef __FreeBSD__
 | 
				
			||||||
 | 
					   cpuset_t cpuset;
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
   cpu_set_t cpuset;
 | 
					   cpu_set_t cpuset;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
} io_t;
 | 
					} io_t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void read_func(void* data) {
 | 
					static void read_func(void* data) {
 | 
				
			||||||
   io_t *io = (io_t *) data;
 | 
					   io_t *io = (io_t *) data;
 | 
				
			||||||
   size_t expect = 0;
 | 
					   size_t expect = 0;
 | 
				
			||||||
   size_t value = 0;
 | 
					   size_t value = 0;
 | 
				
			||||||
   pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &io->cpuset);
 | 
					   pthread_setaffinity_np(pthread_self(), sizeof(io->cpuset), &io->cpuset);
 | 
				
			||||||
   while(1) {
 | 
					   while(1) {
 | 
				
			||||||
      if(pa_atomic_load(io->flag) == 1) {
 | 
					      if(pa_atomic_load(io->flag) == 1) {
 | 
				
			||||||
         memcpy(&value, io->memory, sizeof(value));
 | 
					         memcpy(&value, io->memory, sizeof(value));
 | 
				
			||||||
| 
						 | 
					@ -76,7 +83,7 @@ static void read_func(void* data) {
 | 
				
			||||||
static void write_func(void* data) {
 | 
					static void write_func(void* data) {
 | 
				
			||||||
   io_t *io = (io_t *) data;
 | 
					   io_t *io = (io_t *) data;
 | 
				
			||||||
   size_t value = 0;
 | 
					   size_t value = 0;
 | 
				
			||||||
   pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &io->cpuset);
 | 
					   pthread_setaffinity_np(pthread_self(), sizeof(io->cpuset), &io->cpuset);
 | 
				
			||||||
   while(1) {
 | 
					   while(1) {
 | 
				
			||||||
      if(pa_atomic_load(io->flag) == 0) {
 | 
					      if(pa_atomic_load(io->flag) == 0) {
 | 
				
			||||||
         memcpy(io->memory, &value, sizeof(value));
 | 
					         memcpy(io->memory, &value, sizeof(value));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue