12 void fio_spinlock_remove(struct fio_spinlock *lock)
15 munmap((void *) lock, sizeof(*lock));
18 struct fio_spinlock *fio_spinlock_init(void)
20 char spinlock_name[] = "/tmp/.fio_spinlock.XXXXXX";
21 struct fio_spinlock *lock = NULL;
24 fd = mkstemp(spinlock_name);
26 perror("open spinlock");
30 if (ftruncate(fd, sizeof(struct fio_spinlock)) < 0) {
31 perror("ftruncate spinlock");
35 lock = (void *) mmap(NULL, sizeof(struct fio_spinlock),
36 PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
37 if (lock == MAP_FAILED) {
38 perror("mmap spinlock");
44 unlink(spinlock_name);
46 spin_lock_init(&lock->slock);
51 fio_spinlock_remove(lock);
53 unlink(spinlock_name);