Changeset e8e9052 for lib


Ignore:
Timestamp:
05/18/18 14:54:59 (3 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
cachetimestamps, develop, master, rc-4.0.4, ringdecrementfix, ringperformance
Children:
5577521
Parents:
a7e4f40
Message:

Fix build error on older kernels that don't have memfd_create

We now fall back to shm_open() if memfd_create isn't available.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/data-struct/simple_circular_buffer.c

    r25c305d re8e9052  
    77#include <stdio.h>
    88#include <sys/syscall.h>
     9#include <sys/stat.h>
     10#include <fcntl.h>
    911#include <sys/socket.h>
    1012
     
    2123
    2224        snprintf(anonname, 32, "lt_scb_%u", id);
     25#ifdef HAVE_MEMFD_CREATE
    2326        buf->fd = syscall(__NR_memfd_create, anonname, 0);
     27#else
     28        buf->fd = shm_open(anonname, O_RDWR | O_CREAT, 0600);
     29#endif
    2430        ftruncate(buf->fd, size);
    2531
     
    3642
    3743DLLEXPORT void libtrace_scb_destroy(libtrace_scb_t *buf) {
     44        /* TODO shm_unlink the file name if we used shm_open? */
     45
    3846        munmap(buf->address, buf->count_bytes * 2);
     47        close(buf->fd);
    3948}
    4049
Note: See TracChangeset for help on using the changeset viewer.