|
Packit |
6639f8 |
// Copyright(c) 2018-2020, Intel Corporation
|
|
Packit |
6639f8 |
//
|
|
Packit |
6639f8 |
// Redistribution and use in source and binary forms, with or without
|
|
Packit |
6639f8 |
// modification, are permitted provided that the following conditions are met:
|
|
Packit |
6639f8 |
//
|
|
Packit |
6639f8 |
// * Redistributions of source code must retain the above copyright notice,
|
|
Packit |
6639f8 |
// this list of conditions and the following disclaimer.
|
|
Packit |
6639f8 |
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
Packit |
6639f8 |
// this list of conditions and the following disclaimer in the documentation
|
|
Packit |
6639f8 |
// and/or other materials provided with the distribution.
|
|
Packit |
6639f8 |
// * Neither the name of Intel Corporation nor the names of its contributors
|
|
Packit |
6639f8 |
// may be used to endorse or promote products derived from this software
|
|
Packit |
6639f8 |
// without specific prior written permission.
|
|
Packit |
6639f8 |
//
|
|
Packit |
6639f8 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
6639f8 |
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
6639f8 |
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit |
6639f8 |
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
Packit |
6639f8 |
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
Packit |
6639f8 |
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
Packit |
6639f8 |
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
Packit |
6639f8 |
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
Packit |
6639f8 |
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit |
6639f8 |
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
Packit |
6639f8 |
// POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
#ifndef __FPGAD_FPGAD_H__
|
|
Packit |
6639f8 |
#define __FPGAD_FPGAD_H__
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
#ifndef __USE_GNU
|
|
Packit |
6639f8 |
#define __USE_GNU
|
|
Packit |
6639f8 |
#endif
|
|
Packit |
6639f8 |
#ifndef _GNU_SOURCE
|
|
Packit |
6639f8 |
#define _GNU_SOURCE
|
|
Packit |
6639f8 |
#endif
|
|
Packit |
6639f8 |
#include <stdlib.h>
|
|
Packit |
6639f8 |
#include <stdbool.h>
|
|
Packit |
6639f8 |
#include <stdint.h>
|
|
Packit |
6639f8 |
#include <string.h>
|
|
Packit |
6639f8 |
#include <pthread.h>
|
|
Packit |
6639f8 |
#include <stdarg.h>
|
|
Packit |
6639f8 |
#include <errno.h>
|
|
Packit |
6639f8 |
#include <sys/stat.h>
|
|
Packit |
6639f8 |
#include <fcntl.h>
|
|
Packit |
6639f8 |
#include <signal.h>
|
|
Packit |
6639f8 |
#include <opae/fpga.h>
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
#include "opae_int.h"
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
#include "api/logging.h"
|
|
Packit |
6639f8 |
#include "command_line.h"
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
int daemonize(void (*hndlr)(int, siginfo_t *, void *),
|
|
Packit |
6639f8 |
mode_t mask,
|
|
Packit |
6639f8 |
const char *dir);
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
#define fpgad_mutex_lock(__res, __mtx_ptr) \
|
|
Packit |
6639f8 |
({ \
|
|
Packit |
6639f8 |
(__res) = pthread_mutex_lock(__mtx_ptr); \
|
|
Packit |
6639f8 |
if (__res) \
|
|
Packit |
6639f8 |
LOG("pthread_mutex_lock failed: %s", \
|
|
Packit |
6639f8 |
strerror(errno)); \
|
|
Packit |
6639f8 |
__res; \
|
|
Packit |
6639f8 |
})
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
#define fpgad_mutex_unlock(__res, __mtx_ptr) \
|
|
Packit |
6639f8 |
({ \
|
|
Packit |
6639f8 |
(__res) = pthread_mutex_unlock(__mtx_ptr); \
|
|
Packit |
6639f8 |
if (__res) \
|
|
Packit |
6639f8 |
LOG("pthread_mutex_unlock failed: %s", \
|
|
Packit |
6639f8 |
strerror(errno)); \
|
|
Packit |
6639f8 |
__res; \
|
|
Packit |
6639f8 |
})
|
|
Packit |
6639f8 |
|
|
Packit |
6639f8 |
#endif /* __FPGAD_FPGAD_H__ */
|