Define gettid for old glibc versions
This commit is contained in:
parent
3dc03ee5d7
commit
39b65b1e67
40
compat.h
Normal file
40
compat.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2022 Barcelona Supercomputing Center (BSC)
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef COMPAT_H
|
||||||
|
#define COMPAT_H
|
||||||
|
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
/* Define gettid for older glibc versions (below 2.30) */
|
||||||
|
#if defined(__GLIBC__) && !__GLIBC_PREREQ(2, 30)
|
||||||
|
static inline pid_t gettid(void)
|
||||||
|
{
|
||||||
|
return (pid_t)syscall(SYS_gettid);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // COMPAT_H
|
6
ovni.c
6
ovni.c
@ -37,11 +37,7 @@
|
|||||||
#include "ovni.h"
|
#include "ovni.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "parson.h"
|
#include "parson.h"
|
||||||
|
#include "compat.h"
|
||||||
#ifndef gettid
|
|
||||||
# include <sys/syscall.h>
|
|
||||||
# define gettid() ((pid_t)syscall(SYS_gettid))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Data per process */
|
/* Data per process */
|
||||||
struct ovni_rproc rproc = {0};
|
struct ovni_rproc rproc = {0};
|
||||||
|
@ -28,14 +28,7 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include "ovni.h"
|
#include "ovni.h"
|
||||||
|
#include "compat.h"
|
||||||
// Define gettid for older glibc versions (below 2.30)
|
|
||||||
#if !__GLIBC_PREREQ(2, 30)
|
|
||||||
static inline pid_t gettid(void)
|
|
||||||
{
|
|
||||||
return (pid_t)syscall(SYS_gettid);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
init(void)
|
init(void)
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
#include "ovni.h"
|
#include "ovni.h"
|
||||||
|
#include "compat.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
#include "ovni.h"
|
#include "ovni.h"
|
||||||
|
#include "compat.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
@ -27,11 +27,7 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#include "ovni.h"
|
#include "ovni.h"
|
||||||
|
#include "compat.h"
|
||||||
#ifndef gettid
|
|
||||||
# include <sys/syscall.h>
|
|
||||||
# define gettid() ((pid_t)syscall(SYS_gettid))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
init(void)
|
init(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user